[Xfce4-commits] [apps/xfce4-terminal] 01/01: Support setting drop-down status bar icon with --icon option

noreply at xfce.org noreply at xfce.org
Mon Nov 7 10:19:08 CET 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit fe44a126da32ce893b1c9ab42f0ec77558c7a81b
Author: Igor <f2404 at yandex.ru>
Date:   Mon Nov 7 11:18:10 2016 +0200

    Support setting drop-down status bar icon with --icon option
    
    Implements https://bugzilla.xfce.org/show_bug.cgi?id=12937
---
 terminal/terminal-app.c             |  4 +++-
 terminal/terminal-window-dropdown.c | 24 +++++++++++++++++++++---
 terminal/terminal-window-dropdown.h |  1 +
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/terminal/terminal-app.c b/terminal/terminal-app.c
index a8b433d..e66a84f 100644
--- a/terminal/terminal-app.c
+++ b/terminal/terminal-app.c
@@ -383,13 +383,14 @@ terminal_app_create_window (TerminalApp       *app,
 static GtkWidget*
 terminal_app_create_drop_down (TerminalApp        *app,
                                const gchar        *role,
+                               const gchar        *icon,
                                gboolean            fullscreen,
                                TerminalVisibility  menubar,
                                TerminalVisibility  toolbar)
 {
   GtkWidget *window;
 
-  window = terminal_window_dropdown_new (role, fullscreen, menubar, toolbar);
+  window = terminal_window_dropdown_new (role, icon, fullscreen, menubar, toolbar);
 
   terminal_app_take_window (app, GTK_WINDOW (window));
 
@@ -712,6 +713,7 @@ terminal_app_open_window (TerminalApp        *app,
           /* create new drop-down window */
           window = terminal_app_create_drop_down (app,
                                                   attr->role,
+                                                  attr->icon,
                                                   attr->fullscreen,
                                                   attr->menubar,
                                                   attr->toolbar);
diff --git a/terminal/terminal-window-dropdown.c b/terminal/terminal-window-dropdown.c
index 3088789..ce2bc60 100644
--- a/terminal/terminal-window-dropdown.c
+++ b/terminal/terminal-window-dropdown.c
@@ -309,6 +309,7 @@ terminal_window_dropdown_set_property (GObject      *object,
   TerminalWindow         *window = TERMINAL_WINDOW (object);
   gdouble                 opacity;
   GdkScreen              *screen;
+  const gchar            *icon_name;
 
   switch (prop_id)
     {
@@ -337,9 +338,13 @@ terminal_window_dropdown_set_property (GObject      *object,
     case PROP_DROPDOWN_STATUS_ICON:
       if (g_value_get_boolean (value))
         {
-          if (dropdown->status_icon == NULL)
+          /* icon_name will be NULL initially after creation; will update it later */
+          icon_name = gtk_window_get_icon_name (GTK_WINDOW (object));
+          if (dropdown->status_icon == NULL && icon_name != NULL)
             {
-              dropdown->status_icon = gtk_status_icon_new_from_icon_name ("utilities-terminal");
+              dropdown->status_icon = g_path_is_absolute (icon_name)
+                ? gtk_status_icon_new_from_file (icon_name)
+                : gtk_status_icon_new_from_icon_name (icon_name);
               gtk_status_icon_set_title (dropdown->status_icon, _("Drop-down Terminal"));
               gtk_status_icon_set_tooltip_text (dropdown->status_icon, _("Toggle Drop-down Terminal"));
               g_signal_connect (G_OBJECT (dropdown->status_icon), "button-press-event",
@@ -906,6 +911,7 @@ terminal_window_dropdown_get_timestamp (GtkWidget   *widget,
 
 GtkWidget *
 terminal_window_dropdown_new (const gchar        *role,
+                              const gchar        *icon,
                               gboolean            fullscreen,
                               TerminalVisibility  menubar,
                               TerminalVisibility  toolbar)
@@ -913,19 +919,31 @@ terminal_window_dropdown_new (const gchar        *role,
   TerminalWindow *window;
   gboolean        show_menubar;
   gboolean        show_toolbar;
+  gboolean        show_icon;
   GtkAction      *action;
+  GValue          value = G_VALUE_INIT;
 
   if (G_LIKELY (role == NULL))
     role = PACKAGE_NAME "-dropdown";
 
-  window = g_object_new (TERMINAL_TYPE_WINDOW_DROPDOWN, "role", role, NULL);
+  window = g_object_new (TERMINAL_TYPE_WINDOW_DROPDOWN,
+                         "role", role,
+                         "icon-name", icon != NULL ? icon : "utilities-terminal",
+                         NULL);
 
   /* read default preferences */
   g_object_get (terminal_window_get_preferences (window),
                 "misc-menubar-default", &show_menubar,
                 "misc-toolbar-default", &show_toolbar,
+                "dropdown-status-icon", &show_icon,
                 NULL);
 
+  /* update status bar icon */
+  g_value_init (&value, G_TYPE_BOOLEAN);
+  g_value_set_boolean (&value, show_icon);
+  terminal_window_dropdown_set_property (G_OBJECT (window),
+                                         PROP_DROPDOWN_STATUS_ICON, &value, NULL);
+
   /* setup full screen */
   if (fullscreen && gtk_action_is_sensitive (window->action_fullscreen))
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (window->action_fullscreen), TRUE);
diff --git a/terminal/terminal-window-dropdown.h b/terminal/terminal-window-dropdown.h
index 171772e..1616a9c 100644
--- a/terminal/terminal-window-dropdown.h
+++ b/terminal/terminal-window-dropdown.h
@@ -36,6 +36,7 @@ typedef struct _TerminalWindowDropdown      TerminalWindowDropdown;
 GType           terminal_window_dropdown_get_type             (void) G_GNUC_CONST;
 
 GtkWidget      *terminal_window_dropdown_new                  (const gchar            *role,
+                                                               const gchar            *icon,
                                                                gboolean                fullscreen,
                                                                TerminalVisibility      menubar,
                                                                TerminalVisibility      toolbar);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list