sort the file procedures by their menu labels.
2004-07-16 Sven Neumann <sven@gimp.org> * app/plug-in/plug-ins.c (plug_ins_init): sort the file procedures by their menu labels. * app/widgets/gimpfileprocview.c: removed the sort function here.
This commit is contained in:
parent
ccf8ed69e7
commit
5222925694
4 changed files with 119 additions and 79 deletions
|
|
@ -1,3 +1,10 @@
|
|||
2004-07-16 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/plug-in/plug-ins.c (plug_ins_init): sort the file procedures
|
||||
by their menu labels.
|
||||
|
||||
* app/widgets/gimpfileprocview.c: removed the sort function here.
|
||||
|
||||
2004-07-16 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
|
|
|
|||
|
|
@ -70,12 +70,15 @@ struct _PlugInHelpDomainDef
|
|||
};
|
||||
|
||||
|
||||
static void plug_ins_init_file (const GimpDatafileData *file_data,
|
||||
gpointer user_data);
|
||||
static void plug_ins_add_to_db (Gimp *gimp,
|
||||
GimpContext *context);
|
||||
static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp,
|
||||
PlugInProcDef *proc_def);
|
||||
static void plug_ins_init_file (const GimpDatafileData *file_data,
|
||||
gpointer data);
|
||||
static void plug_ins_add_to_db (Gimp *gimp,
|
||||
GimpContext *context);
|
||||
static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp,
|
||||
PlugInProcDef *proc_def);
|
||||
static gint plug_ins_file_proc_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
|
@ -311,7 +314,16 @@ plug_ins_init (Gimp *gimp,
|
|||
}
|
||||
|
||||
if (! gimp->no_interface)
|
||||
gimp_menus_init (gimp, gimp->plug_in_defs, STD_PLUGINS_DOMAIN);
|
||||
{
|
||||
gimp->load_procs = g_slist_sort_with_data (gimp->load_procs,
|
||||
plug_ins_file_proc_compare,
|
||||
gimp);
|
||||
gimp->save_procs = g_slist_sort_with_data (gimp->save_procs,
|
||||
plug_ins_file_proc_compare,
|
||||
gimp);
|
||||
|
||||
gimp_menus_init (gimp, gimp->plug_in_defs, STD_PLUGINS_DOMAIN);
|
||||
}
|
||||
|
||||
/* build list of automatically started extensions */
|
||||
for (list = gimp->plug_in_proc_defs, nth = 0; list; list = list->next, nth++)
|
||||
|
|
@ -871,14 +883,12 @@ plug_ins_image_types_parse (gchar *image_types)
|
|||
|
||||
static void
|
||||
plug_ins_init_file (const GimpDatafileData *file_data,
|
||||
gpointer user_data)
|
||||
gpointer data)
|
||||
{
|
||||
PlugInDef *plug_in_def;
|
||||
GSList **plug_in_defs;
|
||||
GSList **plug_in_defs = data;
|
||||
GSList *list;
|
||||
|
||||
plug_in_defs = (GSList **) user_data;
|
||||
|
||||
for (list = *plug_in_defs; list; list = list->next)
|
||||
{
|
||||
gchar *plug_in_name;
|
||||
|
|
@ -978,3 +988,38 @@ plug_ins_proc_def_insert (Gimp *gimp,
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
plug_ins_file_proc_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer data)
|
||||
{
|
||||
Gimp *gimp = data;
|
||||
const PlugInProcDef *proc_a = a;
|
||||
const PlugInProcDef *proc_b = b;
|
||||
gchar *label_a;
|
||||
gchar *label_b;
|
||||
gint retval = 0;
|
||||
|
||||
if (strncmp (proc_a->prog, "gimp_xcf", 8) == 0)
|
||||
return -1;
|
||||
if (strncmp (proc_b->prog, "gimp_xcf", 8) == 0)
|
||||
return 1;
|
||||
|
||||
label_a = plug_in_proc_def_get_label (proc_a,
|
||||
plug_ins_locale_domain (gimp,
|
||||
proc_a->prog,
|
||||
NULL));
|
||||
label_b = plug_in_proc_def_get_label (proc_b,
|
||||
plug_ins_locale_domain (gimp,
|
||||
proc_b->prog,
|
||||
NULL));
|
||||
|
||||
if (label_a && label_b)
|
||||
retval = g_utf8_collate (label_a, label_b);
|
||||
|
||||
g_free (label_a);
|
||||
g_free (label_b);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,12 +70,15 @@ struct _PlugInHelpDomainDef
|
|||
};
|
||||
|
||||
|
||||
static void plug_ins_init_file (const GimpDatafileData *file_data,
|
||||
gpointer user_data);
|
||||
static void plug_ins_add_to_db (Gimp *gimp,
|
||||
GimpContext *context);
|
||||
static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp,
|
||||
PlugInProcDef *proc_def);
|
||||
static void plug_ins_init_file (const GimpDatafileData *file_data,
|
||||
gpointer data);
|
||||
static void plug_ins_add_to_db (Gimp *gimp,
|
||||
GimpContext *context);
|
||||
static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp,
|
||||
PlugInProcDef *proc_def);
|
||||
static gint plug_ins_file_proc_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
|
@ -311,7 +314,16 @@ plug_ins_init (Gimp *gimp,
|
|||
}
|
||||
|
||||
if (! gimp->no_interface)
|
||||
gimp_menus_init (gimp, gimp->plug_in_defs, STD_PLUGINS_DOMAIN);
|
||||
{
|
||||
gimp->load_procs = g_slist_sort_with_data (gimp->load_procs,
|
||||
plug_ins_file_proc_compare,
|
||||
gimp);
|
||||
gimp->save_procs = g_slist_sort_with_data (gimp->save_procs,
|
||||
plug_ins_file_proc_compare,
|
||||
gimp);
|
||||
|
||||
gimp_menus_init (gimp, gimp->plug_in_defs, STD_PLUGINS_DOMAIN);
|
||||
}
|
||||
|
||||
/* build list of automatically started extensions */
|
||||
for (list = gimp->plug_in_proc_defs, nth = 0; list; list = list->next, nth++)
|
||||
|
|
@ -871,14 +883,12 @@ plug_ins_image_types_parse (gchar *image_types)
|
|||
|
||||
static void
|
||||
plug_ins_init_file (const GimpDatafileData *file_data,
|
||||
gpointer user_data)
|
||||
gpointer data)
|
||||
{
|
||||
PlugInDef *plug_in_def;
|
||||
GSList **plug_in_defs;
|
||||
GSList **plug_in_defs = data;
|
||||
GSList *list;
|
||||
|
||||
plug_in_defs = (GSList **) user_data;
|
||||
|
||||
for (list = *plug_in_defs; list; list = list->next)
|
||||
{
|
||||
gchar *plug_in_name;
|
||||
|
|
@ -978,3 +988,38 @@ plug_ins_proc_def_insert (Gimp *gimp,
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
plug_ins_file_proc_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer data)
|
||||
{
|
||||
Gimp *gimp = data;
|
||||
const PlugInProcDef *proc_a = a;
|
||||
const PlugInProcDef *proc_b = b;
|
||||
gchar *label_a;
|
||||
gchar *label_b;
|
||||
gint retval = 0;
|
||||
|
||||
if (strncmp (proc_a->prog, "gimp_xcf", 8) == 0)
|
||||
return -1;
|
||||
if (strncmp (proc_b->prog, "gimp_xcf", 8) == 0)
|
||||
return 1;
|
||||
|
||||
label_a = plug_in_proc_def_get_label (proc_a,
|
||||
plug_ins_locale_domain (gimp,
|
||||
proc_a->prog,
|
||||
NULL));
|
||||
label_b = plug_in_proc_def_get_label (proc_b,
|
||||
plug_ins_locale_domain (gimp,
|
||||
proc_b->prog,
|
||||
NULL));
|
||||
|
||||
if (label_a && label_b)
|
||||
retval = g_utf8_collate (label_a, label_b);
|
||||
|
||||
g_free (label_a);
|
||||
g_free (label_b);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,10 +59,6 @@ static void gimp_file_proc_view_class_init (GimpFileProcViewClass *klass);
|
|||
|
||||
static void gimp_file_proc_view_selection_changed (GtkTreeSelection *selection,
|
||||
GimpFileProcView *view);
|
||||
static gint gimp_file_proc_view_iter_compare (GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static guint view_signals[LAST_SIGNAL] = { 0 };
|
||||
|
|
@ -133,16 +129,6 @@ gimp_file_proc_view_new (Gimp *gimp,
|
|||
G_TYPE_STRING, /* COLUMN_STOCK_ID */
|
||||
GDK_TYPE_PIXBUF); /* COLUMN_PIXBUF */
|
||||
|
||||
|
||||
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
|
||||
COLUMN_LABEL,
|
||||
gimp_file_proc_view_iter_compare,
|
||||
NULL, NULL);
|
||||
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
|
||||
COLUMN_LABEL,
|
||||
GTK_SORT_ASCENDING);
|
||||
|
||||
for (list = procedures; list; list = g_slist_next (list))
|
||||
{
|
||||
PlugInProcDef *proc = list->data;
|
||||
|
|
@ -303,46 +289,3 @@ gimp_file_proc_view_selection_changed (GtkTreeSelection *selection,
|
|||
{
|
||||
g_signal_emit (view, view_signals[CHANGED], 0);
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_file_proc_view_iter_compare (GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer data)
|
||||
{
|
||||
PlugInProcDef *proc_a;
|
||||
PlugInProcDef *proc_b;
|
||||
gchar *label_a;
|
||||
gchar *label_b;
|
||||
gint retval;
|
||||
|
||||
gtk_tree_model_get (model, a,
|
||||
COLUMN_PROC, &proc_a,
|
||||
COLUMN_LABEL, &label_a,
|
||||
-1);
|
||||
gtk_tree_model_get (model, b,
|
||||
COLUMN_PROC, &proc_b,
|
||||
COLUMN_LABEL, &label_b,
|
||||
-1);
|
||||
|
||||
if (proc_a && proc_b)
|
||||
{
|
||||
if (strncmp (proc_a->prog, "gimp_xcf", 8) == 0)
|
||||
retval = -1;
|
||||
else if (strncmp (proc_b->prog, "gimp_xcf", 8) == 0)
|
||||
retval = 1;
|
||||
else
|
||||
retval = g_utf8_collate (label_a, label_b);
|
||||
}
|
||||
else if (proc_a)
|
||||
retval = 1;
|
||||
else if (proc_b)
|
||||
retval = -1;
|
||||
else
|
||||
retval = 0;
|
||||
|
||||
g_free (label_a);
|
||||
g_free (label_b);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue