Rename sorted_filetypes filetypes_by_title, and add to GeanyData
for plugin API access. Fix order of filetypes in Save Actions Instant Save configuration dialog. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/reorder-filetypes@3677 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
		
							parent
							
								
									6d34508059
								
							
						
					
					
						commit
						26d27cbd2e
					
				
							
								
								
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							@ -1,3 +1,13 @@
 | 
			
		||||
2009-04-02  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 | 
			
		||||
 | 
			
		||||
 * src/templates.c, src/dialogs.c, src/plugindata.h, src/filetypes.c,
 | 
			
		||||
   src/filetypes.h, src/plugins.c, plugins/saveactions.c:
 | 
			
		||||
   Rename sorted_filetypes filetypes_by_title, and add to GeanyData
 | 
			
		||||
   for plugin API access.
 | 
			
		||||
   Fix order of filetypes in Save Actions Instant Save configuration
 | 
			
		||||
   dialog.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
2009-03-31  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 | 
			
		||||
 | 
			
		||||
 * src/templates.c, src/utils.h, src/dialogs.c, src/filetypes.c,
 | 
			
		||||
 | 
			
		||||
@ -603,6 +603,8 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 | 
			
		||||
	{
 | 
			
		||||
		GtkWidget *combo;
 | 
			
		||||
		guint i;
 | 
			
		||||
		GSList *node;
 | 
			
		||||
		GeanyFiletype *ft;
 | 
			
		||||
 | 
			
		||||
		notebook_vbox = gtk_vbox_new(FALSE, 2);
 | 
			
		||||
		inner_vbox = gtk_vbox_new(FALSE, 5);
 | 
			
		||||
@ -624,14 +626,14 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 | 
			
		||||
		gtk_box_pack_start(GTK_BOX(inner_vbox), label, FALSE, FALSE, 0);
 | 
			
		||||
 | 
			
		||||
		pref_widgets.instantsave_ft_combo = combo = gtk_combo_box_new_text();
 | 
			
		||||
		for (i = 0; i < geany->filetypes_array->len; i++)
 | 
			
		||||
		i = 0;
 | 
			
		||||
		foreach_slist(ft, node, geany->filetypes_by_title)
 | 
			
		||||
		{
 | 
			
		||||
			GeanyFiletype *ft = filetypes_index(i);
 | 
			
		||||
 | 
			
		||||
			gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ft->name);
 | 
			
		||||
 | 
			
		||||
			if (utils_str_equal(ft->name, instantsave_default_ft))
 | 
			
		||||
				gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i);
 | 
			
		||||
			i++;
 | 
			
		||||
		}
 | 
			
		||||
		gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combo), 3);
 | 
			
		||||
		gtk_label_set_mnemonic_widget(GTK_LABEL(label), combo);
 | 
			
		||||
 | 
			
		||||
@ -91,7 +91,7 @@ on_file_open_dialog_response           (GtkDialog *dialog,
 | 
			
		||||
 | 
			
		||||
		/* ignore detect from file item */
 | 
			
		||||
		if (filetype_idx > 0 && filetype_idx < GEANY_MAX_BUILT_IN_FILETYPES)
 | 
			
		||||
			ft = g_slist_nth_data(sorted_filetypes, filetype_idx);
 | 
			
		||||
			ft = g_slist_nth_data(filetypes_by_title, filetype_idx);
 | 
			
		||||
		if (encoding_idx >= 0 && encoding_idx < GEANY_ENCODINGS_MAX)
 | 
			
		||||
			charset = encodings[encoding_idx].charset;
 | 
			
		||||
 | 
			
		||||
@ -216,7 +216,7 @@ static void create_open_file_dialog(void)
 | 
			
		||||
	/* now create meta filter "All Source" */
 | 
			
		||||
	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
 | 
			
		||||
				filetypes_create_file_filter_all_source());
 | 
			
		||||
	foreach_slist(ft, node, sorted_filetypes)
 | 
			
		||||
	foreach_slist(ft, node, filetypes_by_title)
 | 
			
		||||
	{
 | 
			
		||||
		if (ft->id == GEANY_FILETYPES_NONE)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
@ -69,11 +69,11 @@ GPtrArray *filetypes_array = NULL;	/* Dynamic array of filetype pointers */
 | 
			
		||||
 | 
			
		||||
static GHashTable *filetypes_hash = NULL;	/* Hash of filetype pointers based on name keys */
 | 
			
		||||
 | 
			
		||||
/* List of filetype pointers sorted by name, with ft[GEANY_FILETYPES_NONE] first, as this
 | 
			
		||||
 * is usually treated specially.
 | 
			
		||||
 * The list does not change after filetypes have been initialized, so you can use
 | 
			
		||||
 * @code g_slist_nth_data(sorted_filetypes, n) @endcode and expect the same result at different times. */
 | 
			
		||||
GSList *sorted_filetypes = NULL;
 | 
			
		||||
/** List of filetype pointers sorted by name, but with @c filetypes_index(GEANY_FILETYPES_NONE)
 | 
			
		||||
 * first, as this is usually treated specially.
 | 
			
		||||
 * The list does not change (after filetypes have been initialized), so you can use
 | 
			
		||||
 * @code g_slist_nth_data(filetypes_by_title, n) @endcode and expect the same result at different times. */
 | 
			
		||||
GSList *filetypes_by_title = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void create_radio_menu_item(GtkWidget *menu, GeanyFiletype *ftype);
 | 
			
		||||
@ -618,7 +618,7 @@ static void filetype_add(GeanyFiletype *ft)
 | 
			
		||||
	g_ptr_array_add(filetypes_array, ft);
 | 
			
		||||
	g_hash_table_insert(filetypes_hash, ft->name, ft);
 | 
			
		||||
 | 
			
		||||
	sorted_filetypes = g_slist_insert_sorted(sorted_filetypes, ft, cmp_filetype);
 | 
			
		||||
	filetypes_by_title = g_slist_insert_sorted(filetypes_by_title, ft, cmp_filetype);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1487,7 +1487,7 @@ void filetypes_foreach_named(GFunc callback, gpointer user_data)
 | 
			
		||||
	GSList *node;
 | 
			
		||||
	GeanyFiletype *ft;
 | 
			
		||||
 | 
			
		||||
	foreach_slist(ft, node, sorted_filetypes)
 | 
			
		||||
	foreach_slist(ft, node, filetypes_by_title)
 | 
			
		||||
	{
 | 
			
		||||
		if (ft->id != GEANY_FILETYPES_NONE)
 | 
			
		||||
			callback(ft, user_data);
 | 
			
		||||
 | 
			
		||||
@ -144,7 +144,7 @@ extern GPtrArray *filetypes_array;
 | 
			
		||||
 * Example: filetypes[GEANY_FILETYPES_C]->name = ...; */
 | 
			
		||||
#define filetypes	((GeanyFiletype **)filetypes_array->pdata)
 | 
			
		||||
 | 
			
		||||
extern GSList *sorted_filetypes;
 | 
			
		||||
extern GSList *filetypes_by_title;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
 | 
			
		||||
 | 
			
		||||
@ -45,7 +45,7 @@
 | 
			
		||||
enum {
 | 
			
		||||
	/** The Application Programming Interface (API) version, incremented
 | 
			
		||||
	 * whenever any plugin data types are modified or appended to. */
 | 
			
		||||
	GEANY_API_VERSION = 135,
 | 
			
		||||
	GEANY_API_VERSION = 136,
 | 
			
		||||
 | 
			
		||||
	/** The Application Binary Interface (ABI) version, incremented whenever
 | 
			
		||||
	 * existing fields in the plugin data types have to be changed or reordered. */
 | 
			
		||||
@ -188,6 +188,7 @@ typedef struct GeanyData
 | 
			
		||||
	struct GeanyToolPrefs		*tool_prefs;		/**< Tool settings */
 | 
			
		||||
	struct GeanyTemplatePrefs	*template_prefs;	/**< Template settings */
 | 
			
		||||
	struct GeanyBuildInfo		*build_info;		/**< Current build information */
 | 
			
		||||
	GSList						*filetypes_by_title; /**< See filetypes.h#filetypes_by_title. */
 | 
			
		||||
}
 | 
			
		||||
GeanyData;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -347,7 +347,8 @@ geany_data_init(void)
 | 
			
		||||
		&search_prefs,
 | 
			
		||||
		&tool_prefs,
 | 
			
		||||
		&template_prefs,
 | 
			
		||||
		&build_info
 | 
			
		||||
		&build_info,
 | 
			
		||||
		filetypes_by_title
 | 
			
		||||
	};
 | 
			
		||||
	memcpy(&geany_data, &gd, sizeof(GeanyData));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -365,7 +365,7 @@ static void create_new_menu_items(void)
 | 
			
		||||
	GeanyFiletype *ft;
 | 
			
		||||
	GSList *node;
 | 
			
		||||
 | 
			
		||||
	foreach_slist(ft, node, sorted_filetypes)
 | 
			
		||||
	foreach_slist(ft, node, filetypes_by_title)
 | 
			
		||||
	{
 | 
			
		||||
		filetype_id ft_id = ft->id;
 | 
			
		||||
		GtkWidget *tmp_menu, *tmp_button;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user