[anjuta] git: Use a toggle button to show and hide the command bar



commit 89cd0c9177276fc27ad2c45b9d94444c8080c43e
Author: James Liggett <jrliggett cox net>
Date:   Fri Mar 22 15:25:19 2013 -0700

    git: Use a toggle button to show and hide the command bar
    
    The show/hide state is stored using a GSettings key, so it is persistent across
    Anjuta sessions.

 plugins/git/Makefile.am                            |   10 +++-
 plugins/git/anjuta-git.ui                          |   73 ++++++++++++++++++++
 .../org.gnome.anjuta.plugins.git.gschema.xml.in    |    7 ++
 plugins/git/plugin.c                               |   49 ++++++++++++--
 plugins/git/plugin.h                               |    2 +
 5 files changed, 135 insertions(+), 6 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 4a60168..f821d38 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -233,9 +233,17 @@ libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 libanjuta_git_la_LIBADD = \
        $(LIBANJUTA_LIBS)
 
+gsettings_in_file = org.gnome.anjuta.plugins.git.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
 EXTRA_DIST = \
        $(git_glade_DATA) \
        $(git_plugin_DATA) \
-       $(plugin_in_files)
+       $(plugin_in_files) \
+    $(gsettings_in_file)
+
+CLEANFILES = $(gsettings_SCHEMAS)
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index c755b76..d8817ae 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -1562,6 +1562,79 @@
       </packing>
     </child>
   </object>
+  <object class="GtkBox" id="grip_box">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkImage" id="image1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="stock">git-plugin</property>
+        <property name="icon-size">1</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label51">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="xalign">0</property>
+        <property name="label" translatable="yes">Git</property>
+      </object>
+      <packing>
+        <property name="expand">True</property>
+        <property name="fill">True</property>
+        <property name="padding">2</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkToggleButton" id="git_tasks_button">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">True</property>
+        <child>
+          <object class="GtkBox" id="box2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label52">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Tasks</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkArrow" id="arrow1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="arrow_type">down</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+  </object>
   <object class="GtkListStore" id="log_branch_combo_model">
     <columns>
       <!-- column-name active -->
diff --git a/plugins/git/org.gnome.anjuta.plugins.git.gschema.xml.in 
b/plugins/git/org.gnome.anjuta.plugins.git.gschema.xml.in
new file mode 100644
index 0000000..c55883f
--- /dev/null
+++ b/plugins/git/org.gnome.anjuta.plugins.git.gschema.xml.in
@@ -0,0 +1,7 @@
+<schemalist>
+    <schema id="org.gnome.anjuta.plugins.git" path="/org/gnome/anjuta/plugins/git/">
+        <key name="show-command-bar" type="b">
+            <default>true</default>        
+        </key>    
+    </schema>
+</schemalist>
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 9d8023f..8f9cd04 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -57,6 +57,8 @@
 #include "git-patch-series-pane.h"
 #include "git-apply-mailbox-pane.h"
 
+#define SETTINGS_SCHEMA "org.gnome.anjuta.plugins.git"
+
 AnjutaCommandBarEntry branch_entries[] =
 {
        {
@@ -648,16 +650,29 @@ git_register_stock_icons (AnjutaPlugin *plugin)
                END_REGISTER_ICON
 }
 
+static void
+on_git_tasks_button_toggled (GtkToggleButton *button, GtkWidget *dock)
+{
+       gtk_widget_set_visible (dock, gtk_toggle_button_get_active (button));
+}
+
 static gboolean
 git_activate_plugin (AnjutaPlugin *plugin)
 {
        Git *git_plugin;
+       GtkBuilder *builder;
+       gchar *objects[] = {"grip_box",
+                                               NULL};
+       GtkWidget *git_tasks_button;
        
        DEBUG_PRINT ("%s", "Git: Activating Git plugin …");
        
        git_plugin = ANJUTA_PLUGIN_GIT (plugin);
 
        git_register_stock_icons (plugin);
+
+       builder = gtk_builder_new ();
+       gtk_builder_add_objects_from_file (builder, BUILDER_FILE, objects, NULL);
        
        /* Command bar and dock */
        git_plugin->command_bar = anjuta_command_bar_new ();
@@ -671,11 +686,24 @@ git_activate_plugin (AnjutaPlugin *plugin)
        anjuta_dock_set_command_bar (ANJUTA_DOCK (git_plugin->dock), 
                                     ANJUTA_COMMAND_BAR (git_plugin->command_bar));
 
-       gtk_widget_show_all (git_plugin->box);
-       anjuta_shell_add_widget (plugin->shell, git_plugin->box, "GitDock", 
-                                _("Git"), "git-plugin", ANJUTA_SHELL_PLACEMENT_CENTER,
-                                NULL);
+       gtk_widget_show (git_plugin->box);
+       gtk_widget_show (git_plugin->dock);
+       anjuta_shell_add_widget_custom (plugin->shell, git_plugin->box, "GitDock", 
+                                               _("Git"), "git-plugin", 
+                                       GTK_WIDGET (gtk_builder_get_object (builder, "grip_box")), 
+                                       ANJUTA_SHELL_PLACEMENT_CENTER,
+                                               NULL);
+       git_tasks_button = GTK_WIDGET (gtk_builder_get_object (builder, 
+                                                              "git_tasks_button"));
+
+       g_signal_connect (G_OBJECT (git_tasks_button), "toggled",
+                         G_CALLBACK (on_git_tasks_button_toggled),
+                         git_plugin->command_bar);
 
+       g_settings_bind (git_plugin->settings, "show-command-bar", 
+                        git_tasks_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+       
        /* Create the branch list commands. There are two commands because some 
         * views need to be able to tell the difference between local and 
         * remote branches */
@@ -840,7 +868,16 @@ git_finalize (GObject *obj)
 static void
 git_dispose (GObject *obj)
 {
-       /* Disposition codes */
+       Git *git_plugin;
+
+       git_plugin = ANJUTA_PLUGIN_GIT (obj);
+
+       if (git_plugin->settings)
+       {
+               g_clear_object (&git_plugin->settings);
+               git_plugin->settings = NULL;
+       }
+       
        G_OBJECT_CLASS (parent_class)->dispose (obj);
 }
 
@@ -850,6 +887,8 @@ git_instance_init (GObject *obj)
        Git *plugin = ANJUTA_PLUGIN_GIT (obj);
 
        plugin->command_queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_AUTOMATIC);
+       plugin->settings = g_settings_new (SETTINGS_SCHEMA);
+
 }
 
 static void
diff --git a/plugins/git/plugin.h b/plugins/git/plugin.h
index 3a2cffe..647d99c 100644
--- a/plugins/git/plugin.h
+++ b/plugins/git/plugin.h
@@ -67,6 +67,8 @@ struct _Git
        GtkWidget *dock;
        GtkWidget *box;
 
+       GSettings *settings;
+
        /* Dock panes */
        AnjutaDockPane *status_pane;
        AnjutaDockPane *log_pane;


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