gimp r25867 - in trunk: . app/actions app/dialogs



Author: neo
Date: Fri May 30 10:17:35 2008
New Revision: 25867
URL: http://svn.gnome.org/viewvc/gimp?rev=25867&view=rev

Log:
2008-05-30  Sven Neumann  <sven gimp org>

	* app/dialogs/module-dialog.c: cleaned up the UI a bit. Removed
	some information and a button that was not really useful. Only
	show the error state when there is actually an error.

	* app/actions/dialogs-actions.c: changed menu item to "Module
	Manager".


Modified:
   trunk/ChangeLog
   trunk/app/actions/dialogs-actions.c
   trunk/app/dialogs/module-dialog.c

Modified: trunk/app/actions/dialogs-actions.c
==============================================================================
--- trunk/app/actions/dialogs-actions.c	(original)
+++ trunk/app/actions/dialogs-actions.c	Fri May 30 10:17:35 2008
@@ -197,7 +197,7 @@
     GIMP_HELP_KEYBOARD_SHORTCUTS },
 
   { "dialogs-module-dialog", GTK_STOCK_EXECUTE,
-    N_("_Modules"), NULL,
+    N_("_Module Manager"), NULL,
     N_("Open the module manager dialog"),
     "gimp-module-dialog",
     GIMP_HELP_MODULE_DIALOG },

Modified: trunk/app/dialogs/module-dialog.c
==============================================================================
--- trunk/app/dialogs/module-dialog.c	(original)
+++ trunk/app/dialogs/module-dialog.c	Fri May 30 10:17:35 2008
@@ -40,13 +40,13 @@
 
 
 #define RESPONSE_REFRESH  1
-#define NUM_INFO_LINES    9
+#define NUM_INFO_LINES    5
 
 enum
 {
-  PATH_COLUMN,
-  AUTO_COLUMN,
-  MODULE_COLUMN,
+  COLUMN_NAME,
+  COLUMN_ENABLE,
+  COLUMN_MODULE,
   NUM_COLUMNS
 };
 
@@ -59,38 +59,36 @@
 
   GtkWidget    *table;
   GtkWidget    *label[NUM_INFO_LINES];
-  GtkWidget    *button;
-  GtkWidget    *button_label;
+  GtkWidget    *error_box;
+  GtkWidget    *error_label;
 } ModuleDialog;
 
 
 /*  local function prototypes  */
 
-static void   dialog_response              (GtkWidget             *widget,
-                                            gint                   response_id,
-                                            ModuleDialog          *dialog);
-static void   dialog_destroy_callback      (GtkWidget             *widget,
-                                            ModuleDialog          *dialog);
-static void   dialog_select_callback       (GtkTreeSelection      *sel,
-                                            ModuleDialog          *dialog);
-static void   dialog_autoload_toggled      (GtkCellRendererToggle *celltoggle,
-                                            gchar                 *path_string,
-                                            ModuleDialog          *dialog);
-static void   dialog_load_unload_callback  (GtkWidget             *widget,
-                                            ModuleDialog          *dialog);
-static void   make_list_item               (gpointer               data,
-                                            gpointer               user_data);
-static void   dialog_info_add              (GimpModuleDB          *db,
-                                            GimpModule            *module,
-                                            ModuleDialog          *dialog);
-static void   dialog_info_remove           (GimpModuleDB          *db,
-                                            GimpModule            *module,
-                                            ModuleDialog          *dialog);
-static void   dialog_info_update           (GimpModuleDB          *db,
-                                            GimpModule            *module,
-                                            ModuleDialog          *dialog);
-static void   dialog_info_init             (ModuleDialog          *dialog,
-                                            GtkWidget             *table);
+static void   dialog_response         (GtkWidget             *widget,
+                                       gint                   response_id,
+                                       ModuleDialog          *dialog);
+static void   dialog_destroy_callback (GtkWidget             *widget,
+                                       ModuleDialog          *dialog);
+static void   dialog_select_callback  (GtkTreeSelection      *sel,
+                                       ModuleDialog          *dialog);
+static void   dialog_enabled_toggled  (GtkCellRendererToggle *celltoggle,
+                                       const gchar           *path_string,
+                                       ModuleDialog          *dialog);
+static void   make_list_item          (gpointer               data,
+                                       gpointer               user_data);
+static void   dialog_info_add         (GimpModuleDB          *db,
+                                       GimpModule            *module,
+                                       ModuleDialog          *dialog);
+static void   dialog_info_remove      (GimpModuleDB          *db,
+                                       GimpModule            *module,
+                                       ModuleDialog          *dialog);
+static void   dialog_info_update      (GimpModuleDB          *db,
+                                       GimpModule            *module,
+                                       ModuleDialog          *dialog);
+static void   dialog_info_init        (ModuleDialog          *dialog,
+                                       GtkWidget             *table);
 
 
 /*  public functions  */
@@ -99,10 +97,10 @@
 module_dialog_new (Gimp *gimp)
 {
   GtkWidget         *shell;
-  GtkWidget         *hbox;
   GtkWidget         *vbox;
   GtkWidget         *listbox;
-  GtkWidget         *tv;
+  GtkWidget         *view;
+  GtkWidget         *image;
   ModuleDialog      *dialog;
   GtkTreeSelection  *sel;
   GtkTreeIter        iter;
@@ -115,7 +113,7 @@
 
   dialog->gimp = gimp;
 
-  shell = gimp_dialog_new (_("Manage Loadable Modules"),
+  shell = gimp_dialog_new (_("Module Manager"),
                            "gimp-modules", NULL, 0,
                            gimp_standard_help_func, GIMP_HELP_MODULE_DIALOG,
 
@@ -145,64 +143,64 @@
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
   gtk_box_pack_start (GTK_BOX (vbox), listbox, TRUE, TRUE, 0);
-  gtk_widget_set_size_request (listbox, 125, 100);
+  gtk_widget_set_size_request (listbox, 124, 100);
   gtk_widget_show (listbox);
 
   dialog->list = gtk_list_store_new (NUM_COLUMNS,
                                      G_TYPE_STRING,
                                      G_TYPE_BOOLEAN,
                                      GIMP_TYPE_MODULE);
-  tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list));
+  view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list));
   g_object_unref (dialog->list);
 
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
+
   g_list_foreach (gimp->module_db->modules, make_list_item, dialog);
 
   rend = gtk_cell_renderer_toggle_new ();
 
   g_signal_connect (rend, "toggled",
-                    G_CALLBACK (dialog_autoload_toggled),
+                    G_CALLBACK (dialog_enabled_toggled),
                     dialog);
 
   col = gtk_tree_view_column_new ();
-  gtk_tree_view_column_set_title (col, _("Autoload"));
   gtk_tree_view_column_pack_start (col, rend, FALSE);
-  gtk_tree_view_column_add_attribute (col, rend, "active", AUTO_COLUMN);
+  gtk_tree_view_column_add_attribute (col, rend, "active", COLUMN_ENABLE);
 
-  gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
 
-  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv), 1,
-                                               _("Module Path"),
+  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), 1,
+                                               _("Module"),
                                                gtk_cell_renderer_text_new (),
-                                               "text", PATH_COLUMN,
+                                               "text", COLUMN_NAME,
                                                NULL);
 
-  gtk_container_add (GTK_CONTAINER (listbox), tv);
-  gtk_widget_show (tv);
+  gtk_container_add (GTK_CONTAINER (listbox), view);
+  gtk_widget_show (view);
 
   dialog->table = gtk_table_new (2, NUM_INFO_LINES, FALSE);
-  gtk_table_set_col_spacings (GTK_TABLE (dialog->table), 4);
+  gtk_table_set_col_spacings (GTK_TABLE (dialog->table), 6);
   gtk_box_pack_start (GTK_BOX (vbox), dialog->table, FALSE, FALSE, 0);
   gtk_widget_show (dialog->table);
 
-  hbox = gtk_hbutton_box_new ();
-  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
-  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-  gtk_widget_show (hbox);
-
-  dialog->button = gtk_button_new_with_label ("");
-  dialog->button_label = gtk_bin_get_child (GTK_BIN (dialog->button));
-  gtk_container_add (GTK_CONTAINER (hbox), dialog->button);
-  gtk_widget_show (dialog->button);
+  dialog->error_box = gtk_hbox_new (FALSE, 6);
+  gtk_box_pack_start (GTK_BOX (vbox), dialog->error_box, FALSE, FALSE, 0);
 
-  g_signal_connect (dialog->button, "clicked",
-                    G_CALLBACK (dialog_load_unload_callback),
-                    dialog);
+  image = gtk_image_new_from_stock (GIMP_STOCK_WARNING, GTK_ICON_SIZE_BUTTON);
+  gtk_box_pack_start (GTK_BOX (dialog->error_box), image, FALSE, FALSE, 0);
+  gtk_widget_show (image);
+
+  dialog->error_label = gtk_label_new (NULL);
+  gtk_misc_set_alignment (GTK_MISC (dialog->error_label), 0.0, 0.5);
+  gtk_box_pack_start (GTK_BOX (dialog->error_box),
+                      dialog->error_label, TRUE, TRUE, 0);
+  gtk_widget_show (dialog->error_label);
 
   dialog_info_init (dialog, dialog->table);
 
   dialog_info_update (gimp->module_db, dialog->last_update, dialog);
 
-  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
+  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
 
   g_signal_connect (sel, "changed",
                     G_CALLBACK (dialog_select_callback),
@@ -271,7 +269,7 @@
 
   gtk_tree_selection_get_selected (sel, NULL, &iter);
   gtk_tree_model_get (GTK_TREE_MODEL (dialog->list), &iter,
-                      MODULE_COLUMN, &module, -1);
+                      COLUMN_MODULE, &module, -1);
 
   if (module)
     g_object_unref (module);
@@ -285,63 +283,45 @@
 }
 
 static void
-dialog_autoload_toggled (GtkCellRendererToggle *celltoggle,
-                         gchar                 *path_string,
-                         ModuleDialog          *dialog)
+dialog_enabled_toggled (GtkCellRendererToggle *celltoggle,
+                        const gchar           *path_string,
+                        ModuleDialog          *dialog)
 {
   GtkTreePath *path;
   GtkTreeIter  iter;
-  gboolean     active = FALSE;
+  gboolean     enable = FALSE;
   GimpModule  *module = NULL;
 
   path = gtk_tree_path_new_from_string (path_string);
+
   if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->list), &iter, path))
     {
       g_warning ("%s: bad tree path?", G_STRFUNC);
       return;
     }
+
   gtk_tree_path_free (path);
 
   gtk_tree_model_get (GTK_TREE_MODEL (dialog->list), &iter,
-                      AUTO_COLUMN,   &active,
-                      MODULE_COLUMN, &module,
+                      COLUMN_ENABLE, &enable,
+                      COLUMN_MODULE, &module,
                       -1);
 
   if (module)
     {
       g_object_unref (module);
 
-      gimp_module_set_load_inhibit (module, active);
+      gimp_module_set_load_inhibit (module, enable);
 
       dialog->gimp->write_modulerc = TRUE;
 
       gtk_list_store_set (GTK_LIST_STORE (dialog->list), &iter,
-                          AUTO_COLUMN, ! active,
+                          COLUMN_ENABLE, ! enable,
                           -1);
     }
 }
 
 static void
-dialog_load_unload_callback (GtkWidget    *widget,
-                             ModuleDialog *dialog)
-{
-  if (dialog->last_update->state != GIMP_MODULE_STATE_LOADED)
-    {
-      if (dialog->last_update->info)
-        {
-          if (g_type_module_use (G_TYPE_MODULE (dialog->last_update)))
-            g_type_module_unuse (G_TYPE_MODULE (dialog->last_update));
-        }
-      else
-        {
-          gimp_module_query_module (dialog->last_update);
-        }
-    }
-
-  gimp_module_modified (dialog->last_update);
-}
-
-static void
 make_list_item (gpointer data,
                 gpointer user_data)
 {
@@ -354,9 +334,11 @@
 
   gtk_list_store_append (dialog->list, &iter);
   gtk_list_store_set (dialog->list, &iter,
-                      PATH_COLUMN, module->filename,
-                      AUTO_COLUMN, ! module->load_inhibit,
-                      MODULE_COLUMN, module,
+                      COLUMN_NAME,   (module->info ?
+                                      gettext (module->info->purpose) :
+                                      gimp_filename_to_utf8 (module->filename)),
+                      COLUMN_ENABLE, ! module->load_inhibit,
+                      COLUMN_MODULE, module,
                       -1);
 }
 
@@ -370,11 +352,10 @@
 
 static void
 dialog_info_remove (GimpModuleDB *db,
-                    GimpModule   *mod,
+                    GimpModule   *module,
                     ModuleDialog *dialog)
 {
   GtkTreeIter  iter;
-  GimpModule  *module;
 
   /* FIXME: Use gtk_list_store_foreach_remove when it becomes available */
 
@@ -383,14 +364,16 @@
 
   do
     {
+      GimpModule  *this;
+
       gtk_tree_model_get (GTK_TREE_MODEL (dialog->list), &iter,
-                          MODULE_COLUMN, &module,
+                          COLUMN_MODULE, &this,
                           -1);
 
-      if (module)
-        g_object_unref (module);
+      if (this)
+        g_object_unref (this);
 
-      if (module == mod)
+      if (this == module)
         {
           gtk_list_store_remove (dialog->list, &iter);
           return;
@@ -408,7 +391,8 @@
                     ModuleDialog *dialog)
 {
   GTypeModule *g_type_module;
-  const gchar *text[NUM_INFO_LINES];
+  const gchar *text[NUM_INFO_LINES] = { NULL, };
+  gchar       *location             = NULL;
   gint         i;
 
   g_type_module = G_TYPE_MODULE (module);
@@ -420,76 +404,44 @@
   if (! module)
     {
       for (i = 0; i < NUM_INFO_LINES; i++)
-        gtk_label_set_text (GTK_LABEL (dialog->label[i]), "");
-      gtk_label_set_text (GTK_LABEL (dialog->button_label), _("<No modules>"));
-      gtk_widget_set_sensitive (GTK_WIDGET (dialog->button), FALSE);
+        gtk_label_set_text (GTK_LABEL (dialog->label[i]), NULL);
+
+      gtk_label_set_text (GTK_LABEL (dialog->error_label), NULL);
+      gtk_widget_hide (dialog->error_box);
+
       return;
     }
 
+  if (module->on_disk)
+    location = g_filename_display_name (module->filename);
+
   if (module->info)
     {
-      text[0] = module->info->purpose;
-      text[1] = module->info->author;
-      text[2] = module->info->version;
+      text[0] = module->info->author;
+      text[1] = module->info->version;
+      text[2] = module->info->date;
       text[3] = module->info->copyright;
-      text[4] = module->info->date;
-      text[5] = module->on_disk ? _("On disk") : _("Only in memory");
+      text[4] = module->on_disk ? location : _("Only in memory");
     }
   else
     {
-      text[0] = "--";
-      text[1] = "--";
-      text[2] = "--";
-      text[3] = "--";
-      text[4] = "--";
-      text[5] = module->on_disk ? _("On disk") : _("No longer available");
+      text[4] = module->on_disk ? location : _("No longer available");
     }
 
-  text[6] = gimp_module_state_name (module->state);
+  for (i = 0; i < NUM_INFO_LINES; i++)
+    gtk_label_set_text (GTK_LABEL (dialog->label[i]),
+                        text[i] ? text[i] : "--");
 
   if (module->state == GIMP_MODULE_STATE_ERROR && module->last_module_error)
-    text[7] = module->last_module_error;
-  else
-    text[7] = "--";
-
-  if (g_type_module->type_infos || g_type_module->interface_infos)
     {
-      gchar *str;
-
-      str = g_strdup_printf ("%d Types, %d Interfaces",
-                             g_slist_length (g_type_module->type_infos),
-                             g_slist_length (g_type_module->interface_infos));
-      gtk_label_set_text (GTK_LABEL (dialog->label[NUM_INFO_LINES - 1]), str);
-      g_free (str);
+      gtk_label_set_text (GTK_LABEL (dialog->error_label),
+                          module->last_module_error);
+      gtk_widget_show (dialog->error_box);
     }
   else
     {
-      gtk_label_set_text (GTK_LABEL (dialog->label[NUM_INFO_LINES - 1]),
-                          "---");
-    }
-
-  for (i = 0; i < NUM_INFO_LINES - 1; i++)
-    gtk_label_set_text (GTK_LABEL (dialog->label[i]), gettext (text[i]));
-
-  /* work out what the button should do (if anything) */
-  switch (module->state)
-    {
-    case GIMP_MODULE_STATE_ERROR:
-    case GIMP_MODULE_STATE_LOAD_FAILED:
-    case GIMP_MODULE_STATE_NOT_LOADED:
-      if (module->info)
-        gtk_label_set_text (GTK_LABEL (dialog->button_label), _("Load"));
-      else
-        gtk_label_set_text (GTK_LABEL (dialog->button_label), _("Query"));
-
-      gtk_widget_set_sensitive (GTK_WIDGET (dialog->button),
-                                module->on_disk);
-      break;
-
-    case GIMP_MODULE_STATE_LOADED:
-      gtk_label_set_text (GTK_LABEL (dialog->button_label), _("Unload"));
-      gtk_widget_set_sensitive (GTK_WIDGET (dialog->button), FALSE);
-      break;
+      gtk_label_set_text (GTK_LABEL (dialog->error_label), NULL);
+      gtk_widget_hide (dialog->error_box);
     }
 }
 
@@ -502,15 +454,11 @@
 
   static const gchar * const text[] =
   {
-    N_("Purpose:"),
     N_("Author:"),
     N_("Version:"),
-    N_("Copyright:"),
     N_("Date:"),
-    N_("Location:"),
-    N_("State:"),
-    N_("Last error:"),
-    N_("Available types:")
+    N_("Copyright:"),
+    N_("Location:")
   };
 
   for (i = 0; i < G_N_ELEMENTS (text); i++)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]