static void plug_in_actions_add_proc (GimpActionGroup *group, GimpPlugInProcedure *proc) { GimpProcedureActionEntry entry; const gchar *locale_domain; GList *list; locale_domain = gimp_plug_in_procedure_get_locale_domain (proc); entry.name = gimp_object_get_name (proc); entry.icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (proc)); entry.label = gimp_procedure_get_menu_label (GIMP_PROCEDURE (proc)); entry.accelerator = NULL; entry.tooltip = gimp_procedure_get_blurb (GIMP_PROCEDURE (proc)); entry.procedure = GIMP_PROCEDURE (proc); entry.help_id = gimp_procedure_get_help_id (GIMP_PROCEDURE (proc)); gimp_action_group_add_procedure_actions (group, &entry, 1, G_CALLBACK (plug_in_run_cmd_callback)); for (list = proc->menu_paths; list; list = g_list_next (list)) { const gchar *original = list->data; const gchar *translated = dgettext (locale_domain, original); if (plug_in_actions_check_translation (original, translated)) plug_in_actions_build_path (group, original, translated); else plug_in_actions_build_path (group, original, original); } if (proc->image_types_val) { GimpContext *context = gimp_get_user_context (group->gimp); GimpImage *image = gimp_context_get_image (context); GimpDrawable *drawable = NULL; gboolean sensitive; const gchar *tooltip; if (image) drawable = gimp_image_get_active_drawable (image); sensitive = gimp_procedure_get_sensitive (GIMP_PROCEDURE (proc), GIMP_OBJECT (drawable), &tooltip); gimp_action_group_set_action_sensitive (group, gimp_object_get_name (proc), sensitive); if (! sensitive && drawable && tooltip) gimp_action_group_set_action_tooltip (group, gimp_object_get_name (proc), tooltip); } }
GtkWidget * gimp_file_proc_view_new (Gimp *gimp, GSList *procedures, const gchar *automatic, const gchar *automatic_help_id) { GtkTreeView *view; GtkTreeViewColumn *column; GtkCellRenderer *cell; GtkListStore *store; GSList *list; GtkTreeIter iter; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); store = gtk_list_store_new (N_COLUMNS, GIMP_TYPE_PLUG_IN_PROCEDURE, /* COLUMN_PROC */ G_TYPE_STRING, /* COLUMN_LABEL */ G_TYPE_STRING, /* COLUMN_EXTENSIONS */ G_TYPE_STRING); /* COLUMN_HELP_ID */ view = g_object_new (GIMP_TYPE_FILE_PROC_VIEW, "model", store, "rules-hint", TRUE, NULL); g_object_unref (store); for (list = procedures; list; list = g_slist_next (list)) { GimpPlugInProcedure *proc = list->data; if (! proc->prefixes_list) /* skip URL loaders */ { const gchar *label = gimp_procedure_get_label (GIMP_PROCEDURE (proc)); const gchar *help_id = gimp_procedure_get_help_id (GIMP_PROCEDURE (proc)); GSList *list2; if (label) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_PROC, proc, COLUMN_LABEL, label, COLUMN_EXTENSIONS, proc->extensions, COLUMN_HELP_ID, help_id, -1); } for (list2 = proc->extensions_list; list2; list2 = g_slist_next (list2)) { GimpFileProcView *proc_view = GIMP_FILE_PROC_VIEW (view); const gchar *ext = list2->data; const gchar *dot = strchr (ext, '.'); if (dot && dot != ext) proc_view->meta_extensions = g_list_append (proc_view->meta_extensions, g_strdup (dot + 1)); } } } if (automatic) { gtk_list_store_prepend (store, &iter); gtk_list_store_set (store, &iter, COLUMN_PROC, NULL, COLUMN_LABEL, automatic, COLUMN_HELP_ID, automatic_help_id, -1); } column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("File Type")); gtk_tree_view_column_set_expand (column, TRUE); cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, TRUE); gtk_tree_view_column_set_attributes (column, cell, "text", COLUMN_LABEL, NULL); gtk_tree_view_append_column (view, column); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Extensions")); cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, TRUE); gtk_tree_view_column_set_attributes (column, cell, "text", COLUMN_EXTENSIONS, NULL); gtk_tree_view_append_column (view, column); g_signal_connect (gtk_tree_view_get_selection (view), "changed", G_CALLBACK (gimp_file_proc_view_selection_changed), view); return GTK_WIDGET (view); }