[gimp] Add "title" and "status" properties to GimpSisplayShell



commit 660c333b55d11266d191c8f4d2b8fc5c3db15c4b
Author: Michael Natterer <mitch gimp org>
Date:   Wed Sep 23 19:33:36 2009 +0200

    Add "title" and "status" properties to GimpSisplayShell
    
    Set the properties when updating title and status. In GimpImageWindow,
    connect to notifications of the properties to update window title and
    statusbar.

 app/display/gimpdisplayshell-title.c |   23 ++++++++++---------
 app/display/gimpdisplayshell.c       |   35 ++++++++++++++++++++++++++++-
 app/display/gimpdisplayshell.h       |    3 ++
 app/display/gimpimagewindow.c        |   40 ++++++++++++++++++++++++++++++++-
 4 files changed, 87 insertions(+), 14 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c
index e904a4f..9068613 100644
--- a/app/display/gimpdisplayshell-title.c
+++ b/app/display/gimpdisplayshell-title.c
@@ -92,6 +92,7 @@ gimp_display_shell_update_title_idle (gpointer data)
     {
       GimpDisplayConfig *config = shell->display->config;
       gchar              title[MAX_TITLE_BUF];
+      gchar              status[MAX_TITLE_BUF];
       gint               len;
 
       /* format the title */
@@ -103,23 +104,23 @@ gimp_display_shell_update_title_idle (gpointer data)
 
       g_strlcpy (title + len, GIMP_ACRONYM, sizeof (title) - len);
 
-      gtk_window_set_title (GTK_WINDOW (shell), title);
-
       /* format the statusbar */
-      gimp_display_shell_format_title (shell, title, sizeof (title),
+      gimp_display_shell_format_title (shell, status, sizeof (status),
                                        config->image_status_format);
 
-      /* FIXME image window */
-      gimp_statusbar_replace (GIMP_STATUSBAR (GIMP_IMAGE_WINDOW (shell)->statusbar), "title",
-                              NULL, "%s", title);
+      g_object_set (shell,
+                    /* FIXME: "title" later */
+                    "gimp-title",  title,
+                    "status", status,
+                    NULL);
     }
   else
     {
-      gtk_window_set_title (GTK_WINDOW (shell), GIMP_NAME);
-
-      /* FIXME image window */
-      gimp_statusbar_replace (GIMP_STATUSBAR (GIMP_IMAGE_WINDOW (shell)->statusbar), "title",
-                              NULL, " ");
+      g_object_set (shell,
+                    /* FIXME: "title" later */
+                    "gimp-title",  GIMP_NAME,
+                    "status", " ",
+                    NULL);
     }
 
   return FALSE;
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 7b21541..923b2a5 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -84,7 +84,9 @@
 enum
 {
   PROP_0,
-  PROP_UNIT
+  PROP_UNIT,
+  PROP_TITLE,
+  PROP_STATUS
 };
 
 enum
@@ -214,6 +216,17 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
                                                          GIMP_UNIT_PIXEL,
                                                          GIMP_PARAM_READWRITE));
 
+  g_object_class_install_property (object_class, PROP_TITLE,
+                                   /* FIXME: "title" later */
+                                   g_param_spec_string ("gimp-title", NULL, NULL,
+                                                        NULL,
+                                                        GIMP_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class, PROP_STATUS,
+                                   g_param_spec_string ("status", NULL, NULL,
+                                                        NULL,
+                                                        GIMP_PARAM_READWRITE));
+
   gtk_rc_parse_string (display_rc_style);
 }
 
@@ -400,6 +413,12 @@ gimp_display_shell_finalize (GObject *object)
   if (shell->no_image_options)
     g_object_unref (shell->no_image_options);
 
+  if (shell->title)
+    g_free (shell->title);
+
+  if (shell->status)
+    g_free (shell->status);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -416,6 +435,14 @@ gimp_display_shell_set_property (GObject      *object,
     case PROP_UNIT:
       gimp_display_shell_set_unit (shell, g_value_get_int (value));
       break;
+    case PROP_TITLE:
+      g_free (shell->title);
+      shell->title = g_value_dup_string (value);
+      break;
+    case PROP_STATUS:
+      g_free (shell->status);
+      shell->status = g_value_dup_string (value);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -436,6 +463,12 @@ gimp_display_shell_get_property (GObject    *object,
     case PROP_UNIT:
       g_value_set_int (value, shell->unit);
       break;
+    case PROP_TITLE:
+      g_value_set_string (value, shell->title);
+      break;
+    case PROP_STATUS:
+      g_value_set_string (value, shell->status);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 147d6cf..610f767 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -148,6 +148,9 @@ struct _GimpDisplayShell
 
   guint              title_idle_id;    /*  title update idle ID               */
 
+  gchar             *title;            /*  current title                      */
+  gchar             *status;           /*  current default statusbar content  */
+
   gint               icon_size;        /*  size of the icon pixmap            */
   guint              icon_idle_id;     /*  ID of the idle-function            */
 
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 7b0f469..503bb7e 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -75,8 +75,14 @@ static void      gimp_image_window_show_tooltip (GimpUIManager       *manager,
 static void      gimp_image_window_hide_tooltip (GimpUIManager       *manager,
                                                  GimpImageWindow     *window);
 
-static void      gimp_image_window_shell_scaled (GimpDisplayShell    *shell,
-                                                 GimpImageWindow     *window);
+static void      gimp_image_window_shell_scaled        (GimpDisplayShell    *shell,
+                                                        GimpImageWindow     *window);
+static void      gimp_image_window_shell_title_notify  (GimpDisplayShell    *shell,
+                                                        const GParamSpec    *pspec,
+                                                        GimpImageWindow     *window);
+static void      gimp_image_window_shell_status_notify (GimpDisplayShell    *shell,
+                                                        const GParamSpec    *pspec,
+                                                        GimpImageWindow     *window);
 
 
 G_DEFINE_TYPE (GimpImageWindow, gimp_image_window, GIMP_TYPE_WINDOW)
@@ -372,6 +378,12 @@ gimp_image_window_set_active_display (GimpImageWindow *window,
       g_signal_handlers_disconnect_by_func (active_shell,
                                             gimp_image_window_shell_scaled,
                                             window);
+      g_signal_handlers_disconnect_by_func (active_shell,
+                                            gimp_image_window_shell_title_notify,
+                                            window);
+      g_signal_handlers_disconnect_by_func (active_shell,
+                                            gimp_image_window_shell_status_notify,
+                                            window);
     }
 
   window->active_display = display;
@@ -382,6 +394,13 @@ gimp_image_window_set_active_display (GimpImageWindow *window,
   g_signal_connect (active_shell, "scaled",
                     G_CALLBACK (gimp_image_window_shell_scaled),
                     window);
+  /* FIXME: "title" later */
+  g_signal_connect (active_shell, "notify::gimp-title",
+                    G_CALLBACK (gimp_image_window_shell_title_notify),
+                    window);
+  g_signal_connect (active_shell, "notify::status",
+                    G_CALLBACK (gimp_image_window_shell_status_notify),
+                    window);
 
   gimp_ui_manager_update (window->menubar_manager,
                           window->active_display);
@@ -445,3 +464,20 @@ gimp_image_window_shell_scaled (GimpDisplayShell *shell,
   gimp_ui_manager_update (window->menubar_manager,
                           shell->display);
 }
+
+static void
+gimp_image_window_shell_title_notify (GimpDisplayShell *shell,
+                                      const GParamSpec *pspec,
+                                      GimpImageWindow  *window)
+{
+  gtk_window_set_title (GTK_WINDOW (window), shell->title);
+}
+
+static void
+gimp_image_window_shell_status_notify (GimpDisplayShell *shell,
+                                       const GParamSpec *pspec,
+                                       GimpImageWindow  *window)
+{
+  gimp_statusbar_replace (GIMP_STATUSBAR (window->statusbar), "title",
+                          NULL, "%s", shell->status);
+}



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