gimp r25475 - in trunk: . app/display app/widgets themes/Default themes/Small



Author: neo
Date: Sun Apr 13 18:01:19 2008
New Revision: 25475
URL: http://svn.gnome.org/viewvc/gimp?rev=25475&view=rev

Log:
2008-04-13  Sven Neumann  <sven gimp org>

	* app/widgets/gimpunitcombobox.c: added "label-scale" style 
property.

	* app/display/gimpscalecombobox.[ch]: ditto. Also removed the
	support for extra action items.

	* app/display/gimpstatusbar.c: changed accordingly.

	* themes/Default/gtkrc
	* themes/Small/gtkrc: use a smaller font for the combo-box 
labels
	in the statusbar.



Modified:
   trunk/ChangeLog
   trunk/app/display/gimpscalecombobox.c
   trunk/app/display/gimpscalecombobox.h
   trunk/app/display/gimpstatusbar.c
   trunk/app/widgets/gimpunitcombobox.c
   trunk/themes/Default/gtkrc
   trunk/themes/Small/gtkrc

Modified: trunk/app/display/gimpscalecombobox.c
==============================================================================
--- trunk/app/display/gimpscalecombobox.c	(original)
+++ trunk/app/display/gimpscalecombobox.c	Sun Apr 13 18:01:19 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpscalecombobox.c
- * Copyright (C) 2004  Sven Neumann <sven gimp org>
+ * Copyright (C) 2004, 2008  Sven Neumann <sven gimp org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -37,24 +37,22 @@
 {
   SCALE,
   LABEL,
-  LABEL_ALIGN,
   PERSISTENT,
-  SEPARATOR,
-  ACTION,
   NUM_COLUMNS
 };
 
 
-static void      gimp_scale_combo_box_finalize   (GObject           *object);
-static void      gimp_scale_combo_box_changed    (GimpScaleComboBox *combo_box);
+static void   gimp_scale_combo_box_finalize   (GObject           *object);
 
-static void      gimp_scale_combo_box_scale_iter_set (GtkListStore  *store,
-                                                      GtkTreeIter   *iter,
-                                                      gdouble        scale,
-                                                      gboolean       persistent);
-static gboolean  gimp_scale_combo_box_row_separator  (GtkTreeModel  *model,
-                                                      GtkTreeIter   *iter,
-                                                      gpointer       data);
+static void   gimp_scale_combo_box_style_set  (GtkWidget         *widget,
+                                               GtkStyle          *prev_style);
+
+static void   gimp_scale_combo_box_changed    (GimpScaleComboBox *combo_box);
+
+static void   gimp_scale_combo_box_scale_iter_set (GtkListStore  *store,
+                                                   GtkTreeIter   *iter,
+                                                   gdouble        scale,
+                                                   gboolean       persistent);
 
 
 G_DEFINE_TYPE (GimpScaleComboBox, gimp_scale_combo_box, GTK_TYPE_COMBO_BOX)
@@ -65,42 +63,50 @@
 static void
 gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   object_class->finalize = gimp_scale_combo_box_finalize;
+
+  widget_class->style_set = gimp_scale_combo_box_style_set;
+
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_double ("label-scale",
+                                                                NULL, NULL,
+                                                                0.0,
+                                                                G_MAXDOUBLE,
+                                                                1.0,
+                                                                GIMP_PARAM_READABLE));
 }
 
 static void
 gimp_scale_combo_box_init (GimpScaleComboBox *combo_box)
 {
   GtkListStore    *store;
+  GtkCellLayout   *layout;
   GtkCellRenderer *cell;
   GtkTreeIter      iter;
   gint             i;
 
-  combo_box->actions_added = FALSE;
-  combo_box->last_path     = NULL;
+  combo_box->last_path = NULL;
 
   store = gtk_list_store_new (NUM_COLUMNS,
                               G_TYPE_DOUBLE,    /* SCALE       */
                               G_TYPE_STRING,    /* LABEL       */
-                              G_TYPE_DOUBLE,    /* LABEL_ALIGN */
-                              G_TYPE_BOOLEAN,   /* PERSISTENT  */
-                              G_TYPE_BOOLEAN,   /* SEPARATOR   */
-                              GTK_TYPE_ACTION); /* ACTION      */
+                              G_TYPE_BOOLEAN);  /* PERSISTENT  */
 
   gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
   g_object_unref (store);
 
-  gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo_box),
-                                        gimp_scale_combo_box_row_separator,
-                                        NULL, NULL);
-
-  cell = gtk_cell_renderer_text_new ();
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
-  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
-                                  "text",   LABEL,
-                                  "xalign", LABEL_ALIGN,
+  layout = GTK_CELL_LAYOUT (combo_box);
+
+  cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
+                       "xalign", 1.0,
+                       NULL);
+
+  gtk_cell_layout_pack_start (layout, cell, TRUE);
+  gtk_cell_layout_set_attributes (layout, cell,
+                                  "text", LABEL,
                                   NULL);
 
   for (i = 8; i > 0; i /= 2)
@@ -143,6 +149,33 @@
 }
 
 static void
+gimp_scale_combo_box_style_set (GtkWidget *widget,
+                                GtkStyle  *prev_style)
+{
+  GtkCellLayout   *layout;
+  GtkCellRenderer *cell;
+  gdouble          scale;
+
+  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+
+  gtk_widget_style_get (widget, "label-scale", &scale, NULL);
+
+  /*  hackedehack ...  */
+  layout = GTK_CELL_LAYOUT (gtk_bin_get_child (GTK_BIN (widget)));
+  gtk_cell_layout_clear (layout);
+
+  cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
+                       "xalign", 1.0,
+                       "scale",  scale,
+                       NULL);
+
+  gtk_cell_layout_pack_start (layout, cell, TRUE);
+  gtk_cell_layout_set_attributes (layout, cell,
+                                  "text", LABEL,
+                                  NULL);
+}
+
+static void
 gimp_scale_combo_box_changed (GimpScaleComboBox *combo_box)
 {
   GtkTreeIter iter;
@@ -150,27 +183,12 @@
   if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
     {
       GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
-      GtkAction    *action;
       gdouble       scale;
 
       gtk_tree_model_get (model, &iter,
                           SCALE,  &scale,
-                          ACTION, &action,
                           -1);
-      if (action)
-        {
-          g_signal_stop_emission_by_name (combo_box, "changed");
-
-          gtk_action_activate (action);
-          g_object_unref (action);
-
-          if (combo_box->last_path &&
-              gtk_tree_model_get_iter (model, &iter, combo_box->last_path))
-            {
-              gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
-            }
-        }
-      else if (scale > 0.0)
+      if (scale > 0.0)
         {
           if (combo_box->last_path)
             gtk_tree_path_free (combo_box->last_path);
@@ -180,20 +198,6 @@
     }
 }
 
-static gboolean
-gimp_scale_combo_box_row_separator (GtkTreeModel *model,
-                                    GtkTreeIter  *iter,
-                                    gpointer      data)
-{
-  gboolean separator;
-
-  gtk_tree_model_get (model, iter,
-                      SEPARATOR, &separator,
-                      -1);
-
-  return separator;
-}
-
 static void
 gimp_scale_combo_box_scale_iter_set (GtkListStore *store,
                                      GtkTreeIter  *iter,
@@ -202,13 +206,12 @@
 {
   gchar label[32];
 
-  g_snprintf (label, sizeof (label), "%d%%", (int) ROUND (100.0 * scale));
+  g_snprintf (label, sizeof (label), "%d%%", (gint) ROUND (100.0 * scale));
 
   gtk_list_store_set (store, iter,
-                      SCALE,       scale,
-                      LABEL,       label,
-                      LABEL_ALIGN, 1.0,
-                      PERSISTENT,  persistent,
+                      SCALE,      scale,
+                      LABEL,      label,
+                      PERSISTENT, persistent,
                       -1);
 }
 
@@ -285,41 +288,6 @@
 }
 
 void
-gimp_scale_combo_box_add_action (GimpScaleComboBox *combo_box,
-                                 GtkAction         *action,
-                                 const gchar       *label)
-{
-  GtkTreeModel *model;
-  GtkListStore *store;
-  GtkTreeIter   iter;
-
-  g_return_if_fail (GIMP_IS_SCALE_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_ACTION (action));
-
-  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
-  store = GTK_LIST_STORE (model);
-
-  if (! combo_box->actions_added)
-    {
-      gtk_list_store_append (store, &iter);
-      gtk_list_store_set (store, &iter,
-                          PERSISTENT, TRUE,
-                          SEPARATOR,  TRUE,
-                          -1);
-
-      combo_box->actions_added = TRUE;
-    }
-
-  gtk_list_store_append (store, &iter);
-  gtk_list_store_set (store, &iter,
-                      LABEL,       label,
-                      LABEL_ALIGN, 0.0,
-                      PERSISTENT,  TRUE,
-                      ACTION,      action,
-                      -1);
-}
-
-void
 gimp_scale_combo_box_set_scale (GimpScaleComboBox *combo_box,
                                 gdouble            scale)
 {

Modified: trunk/app/display/gimpscalecombobox.h
==============================================================================
--- trunk/app/display/gimpscalecombobox.h	(original)
+++ trunk/app/display/gimpscalecombobox.h	Sun Apr 13 18:01:19 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpscalecombobox.h
- * Copyright (C) 2004  Sven Neumann <sven gimp org>
+ * Copyright (C) 2004, 2008  Sven Neumann <sven gimp org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -44,7 +44,6 @@
 {
   GtkComboBox       parent_instance;
 
-  gboolean          actions_added;
   GtkTreePath      *last_path;
   GList            *mru;
 };
@@ -53,9 +52,6 @@
 GType       gimp_scale_combo_box_get_type   (void) G_GNUC_CONST;
 
 GtkWidget * gimp_scale_combo_box_new        (void);
-void        gimp_scale_combo_box_add_action (GimpScaleComboBox *combo_box,
-                                             GtkAction         *action,
-                                             const gchar       *label);
 void        gimp_scale_combo_box_set_scale  (GimpScaleComboBox *combo_box,
                                              gdouble            scale);
 gdouble     gimp_scale_combo_box_get_scale  (GimpScaleComboBox *combo_box);

Modified: trunk/app/display/gimpstatusbar.c
==============================================================================
--- trunk/app/display/gimpstatusbar.c	(original)
+++ trunk/app/display/gimpstatusbar.c	Sun Apr 13 18:01:19 2008
@@ -33,7 +33,6 @@
 #include "core/gimpunit.h"
 #include "core/gimpprogress.h"
 
-#include "widgets/gimpuimanager.h"
 #include "widgets/gimpunitstore.h"
 #include "widgets/gimpunitcombobox.h"
 #include "widgets/gimpwidgets-utils.h"
@@ -132,9 +131,9 @@
   GObjectClass   *object_class     = G_OBJECT_CLASS (klass);
   GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
 
-  object_class->finalize     = gimp_statusbar_finalize;
+  object_class->finalize    = gimp_statusbar_finalize;
 
-  gtk_object_class->destroy  = gimp_statusbar_destroy;
+  gtk_object_class->destroy = gimp_statusbar_destroy;
 }
 
 static void
@@ -181,6 +180,11 @@
   gtk_widget_show (hbox);
 
   statusbar->cursor_label = gtk_label_new ("8888, 8888");
+#if 0
+  gimp_label_set_attributes (GTK_LABEL (statusbar->cursor_label),
+                             PANGO_ATTR_SCALE,  PANGO_SCALE_SMALL,
+                             -1);
+#endif
   gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5);
   gtk_box_pack_start (GTK_BOX (hbox), statusbar->cursor_label, FALSE, FALSE, 0);
   gtk_widget_show (statusbar->cursor_label);
@@ -576,7 +580,6 @@
 gimp_statusbar_new (GimpDisplayShell *shell)
 {
   GimpStatusbar *statusbar;
-  GtkAction     *action;
 
   g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
 
@@ -584,16 +587,6 @@
 
   statusbar->shell = shell;
 
-  action = gimp_ui_manager_find_action (shell->menubar_manager,
-                                        "view", "view-zoom-other");
-
-  if (action)
-    {
-      GimpScaleComboBox *combo = GIMP_SCALE_COMBO_BOX (statusbar->scale_combo);
-
-      gimp_scale_combo_box_add_action (combo, action, _("Other..."));
-    }
-
   g_signal_connect_object (shell, "scaled",
                            G_CALLBACK (gimp_statusbar_shell_scaled),
                            statusbar, 0);

Modified: trunk/app/widgets/gimpunitcombobox.c
==============================================================================
--- trunk/app/widgets/gimpunitcombobox.c	(original)
+++ trunk/app/widgets/gimpunitcombobox.c	Sun Apr 13 18:01:19 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpunitcombobox.c
- * Copyright (C) 2004  Sven Neumann <sven gimp org>
+ * Copyright (C) 2004, 2008  Sven Neumann <sven gimp org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,6 +29,10 @@
 #include "gimpunitstore.h"
 
 
+static void  gimp_unit_combo_box_style_set (GtkWidget *widget,
+                                            GtkStyle  *prev_style);
+
+
 G_DEFINE_TYPE (GimpUnitComboBox, gimp_unit_combo_box, GTK_TYPE_COMBO_BOX)
 
 #define parent_class gimp_unit_combo_box_parent_class
@@ -37,6 +41,17 @@
 static void
 gimp_unit_combo_box_class_init (GimpUnitComboBoxClass *klass)
 {
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  widget_class->style_set = gimp_unit_combo_box_style_set;
+
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_double ("label-scale",
+                                                                NULL, NULL,
+                                                                0.0,
+                                                                G_MAXDOUBLE,
+                                                                1.0,
+                                                                GIMP_PARAM_READABLE));
 }
 
 static void
@@ -50,15 +65,30 @@
   gtk_cell_layout_set_attributes (layout, cell,
                                   "text", GIMP_UNIT_STORE_UNIT_PLURAL,
                                   NULL);
+}
+
+static void
+gimp_unit_combo_box_style_set (GtkWidget *widget,
+                               GtkStyle  *prev_style)
+{
+  GtkCellLayout   *layout;
+  GtkCellRenderer *cell;
+  gdouble          scale;
+
+  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+
+  gtk_widget_style_get (widget, "label-scale", &scale, NULL);
 
   /*  hackedehack ...  */
-  layout = GTK_CELL_LAYOUT (gtk_bin_get_child (GTK_BIN (combo)));
+  layout = GTK_CELL_LAYOUT (gtk_bin_get_child (GTK_BIN (widget)));
   gtk_cell_layout_clear (layout);
 
-  cell = gtk_cell_renderer_text_new ();
+  cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
+                       "scale", scale,
+                       NULL);
   gtk_cell_layout_pack_start (layout, cell, TRUE);
   gtk_cell_layout_set_attributes (layout, cell,
-                                  "text", GIMP_UNIT_STORE_UNIT_ABBREVIATION,
+                                  "text",  GIMP_UNIT_STORE_UNIT_ABBREVIATION,
                                   NULL);
 }
 

Modified: trunk/themes/Default/gtkrc
==============================================================================
--- trunk/themes/Default/gtkrc	(original)
+++ trunk/themes/Default/gtkrc	Sun Apr 13 18:01:19 2008
@@ -94,3 +94,12 @@
 }
 
 widget "*GimpDockable.*" style "gimp-dockable-style"
+
+
+style "gimp-display-style" = "gimp-default-style"
+{
+  GimpUnitComboBox::label-scale  = 0.8333
+  GimpScaleComboBox::label-scale = 0.8333
+}
+
+widget "*GimpDisplayShell.*" style "gimp-display-style"

Modified: trunk/themes/Small/gtkrc
==============================================================================
--- trunk/themes/Small/gtkrc	(original)
+++ trunk/themes/Small/gtkrc	Sun Apr 13 18:01:19 2008
@@ -91,3 +91,12 @@
 }
 
 widget "*GimpDockable.*" style "gimp-dockable-style"
+
+
+style "gimp-display-style" = "gimp-default-style"
+{
+  GimpUnitComboBox::label-scale  = 0.8333
+  GimpScaleComboBox::label-scale = 0.8333
+}
+
+widget "*GimpDisplayShell.*" style "gimp-display-style"



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