launchtaskbar: use combobox instead of radio buttons
authorHenry Gebhardt <hsggebhardt@gmail.com>
Tue, 25 Mar 2014 03:32:23 +0000 (23:32 -0400)
committerHenry Gebhardt <hsggebhardt@gmail.com>
Tue, 25 Mar 2014 03:35:03 +0000 (23:35 -0400)
data/ui/launchtaskbar.glade
src/plugins/launchtaskbar.c

index d71c521..3f31c42 100644 (file)
                 <property name="can_focus">False</property>
                 <property name="left_padding">12</property>
                 <child>
-                  <object class="GtkVBox" id="vbox3">
+                  <object class="GtkComboBox" id="combobox_mode">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="homogeneous">True</property>
+                    <property name="model">liststore_mode</property>
                     <child>
-                      <object class="GtkRadioButton" id="radiobutton_launch">
-                        <property name="label" translatable="yes">Only Application Launch Bar</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">radiobutton_launchtask</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="radiobutton_task">
-                        <property name="label" translatable="yes">Only Task Bar (Window List)</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">radiobutton_launchtask</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="radiobutton_launchtask">
-                        <property name="label" translatable="yes">Integrated Application Launch Bar and Task Bar</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
+                      <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
                     </child>
                   </object>
                 </child>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
       <action-widget response="-7">close</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkListStore" id="liststore_mode">
+    <columns>
+      <!-- column-name modename -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Only Application Launch Bar</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Only Task Bar (Window List)</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Integrated Application Launch Bar and Task Bar</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkTreeStore" id="menu_store">
     <columns>
       <!-- column-name icon -->
index edac109..dbe2b0c 100644 (file)
@@ -70,7 +70,7 @@ enum {
 };
 
 typedef enum {
-    LAUNCHBAR = 1,
+    LAUNCHBAR = 0,  /* GtkComboBox is 0-indexed. */
     TASKBAR,
     LAUNCHTASKBAR
 } LtbMode;
@@ -1123,82 +1123,59 @@ static void  plugin_set_expand_status(LaunchTaskBarPlugin *ltbp, gboolean expand
     gtk_box_set_child_packing(GTK_BOX(box), ltbp->plugin, expand_new, fill, padding, pack_type);
 }
 
-static void  on_radiobutton_launch_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
+static void set_config_visibility(LaunchTaskBarPlugin *ltbp)
 {
-    if(!gtk_toggle_button_get_active(p_togglebutton)) return;
-    LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data;
-
     switch (ltbp->mode) {
-    case LAUNCHBAR:
-        return;
-    case TASKBAR:
-        launchtaskbar_constructor_launch(ltbp, TRUE/*build_bootstrap*/);
-        break;
+    default:
     case LAUNCHTASKBAR:
-        break;
-    }
-    gtk_widget_set_visible(ltbp->p_evbox_taskbar, FALSE);
-    ltbp->mode = LAUNCHBAR;
-    config_group_set_int(ltbp->settings, "LaunchTaskBarMode", LAUNCHBAR);
-
-    gtk_widget_set_visible(ltbp->p_notebook_page_launch, TRUE);
-    gtk_widget_set_visible(ltbp->p_notebook_page_task, FALSE);
-    gtk_notebook_set_show_tabs(ltbp->p_notebook, FALSE);
-
-    plugin_set_expand_status(ltbp, FALSE);
-    gtk_widget_set_name(ltbp->plugin, "launchbar");
-}
-
-static void  on_radiobutton_task_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
-{
-    if(!gtk_toggle_button_get_active(p_togglebutton)) return;
-    LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data;
-
-    switch (ltbp->mode) {
-    case LAUNCHBAR:
-        launchtaskbar_constructor_task(ltbp);
+        gtk_widget_set_visible(ltbp->p_notebook_page_launch, TRUE);
+        gtk_widget_set_visible(ltbp->p_notebook_page_task, TRUE);
+        gtk_notebook_set_show_tabs(ltbp->p_notebook, TRUE);
         break;
     case TASKBAR:
-        return;
-    case LAUNCHTASKBAR:
+        gtk_widget_set_visible(ltbp->p_notebook_page_launch, FALSE);
+        gtk_widget_set_visible(ltbp->p_notebook_page_task, TRUE);
+        gtk_notebook_set_show_tabs(ltbp->p_notebook, FALSE);
         break;
+    case LAUNCHBAR:
+        gtk_widget_set_visible(ltbp->p_notebook_page_launch, TRUE);
+        gtk_widget_set_visible(ltbp->p_notebook_page_task, FALSE);
+        gtk_notebook_set_show_tabs(ltbp->p_notebook, FALSE);
     }
-    gtk_widget_set_visible(ltbp->p_evbox_launchbar, FALSE);
-    ltbp->mode = TASKBAR;
-    config_group_set_int(ltbp->settings, "LaunchTaskBarMode", TASKBAR);
-
-    gtk_widget_set_visible(ltbp->p_notebook_page_launch, FALSE);
-    gtk_widget_set_visible(ltbp->p_notebook_page_task, TRUE);
-    gtk_notebook_set_show_tabs(ltbp->p_notebook, FALSE);
-
-    plugin_set_expand_status(ltbp, TRUE);
-    gtk_widget_set_name(ltbp->plugin, "taskbar");
 }
 
-static void  on_radiobutton_launchtask_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
+static void on_combobox_mode_changed(GtkComboBox *p_combobox, gpointer p_data)
 {
-    if(!gtk_toggle_button_get_active(p_togglebutton)) return;
-    LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data;
+    LaunchTaskBarPlugin *ltbp = p_data;
+
+    ltbp->mode = gtk_combo_box_get_active(GTK_COMBO_BOX(p_combobox));
+
+    set_config_visibility(ltbp);
 
     switch (ltbp->mode) {
     case LAUNCHBAR:
+        gtk_widget_set_visible(ltbp->p_evbox_taskbar, FALSE);
+        launchtaskbar_constructor_launch(ltbp, TRUE/*build_bootstrap*/);
+        plugin_set_expand_status(ltbp, FALSE);
+        gtk_widget_set_name(ltbp->plugin, "launchbar");
+        return;
+    case TASKBAR:
+        gtk_widget_set_visible(ltbp->p_evbox_launchbar, FALSE);
         launchtaskbar_constructor_task(ltbp);
+        plugin_set_expand_status(ltbp, TRUE);
+        gtk_widget_set_name(ltbp->plugin, "taskbar");
         break;
-    case TASKBAR:
+    default:
+        ltbp->mode = LAUNCHTASKBAR;
+    case LAUNCHTASKBAR:
         launchtaskbar_constructor_launch(ltbp, TRUE/*build_bootstrap*/);
+        launchtaskbar_constructor_task(ltbp);
+        plugin_set_expand_status(ltbp, TRUE);
+        gtk_widget_set_name(ltbp->plugin, "launchtaskbar");
         break;
-    case LAUNCHTASKBAR:
-        return;
     }
-    ltbp->mode = LAUNCHTASKBAR;
-    config_group_set_int(ltbp->settings, "LaunchTaskBarMode", LAUNCHTASKBAR);
-
-    gtk_widget_set_visible(ltbp->p_notebook_page_launch, TRUE);
-    gtk_widget_set_visible(ltbp->p_notebook_page_task, TRUE);
-    gtk_notebook_set_show_tabs(ltbp->p_notebook, TRUE);
 
-    plugin_set_expand_status(ltbp, TRUE);
-    gtk_widget_set_name(ltbp->plugin, "launchtaskbar");
+    config_group_set_int(ltbp->settings, "LaunchTaskBarMode", ltbp->mode);
 }
 
 static void on_checkbutton_show_tooltips_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
@@ -1406,37 +1383,11 @@ static GtkWidget *launchtaskbar_configure(Panel *panel, GtkWidget *p, GtkWindow
         ltbp->p_notebook = GTK_NOTEBOOK(gtk_builder_get_object(builder, "notebook"));
         ltbp->p_notebook_page_launch = gtk_notebook_get_nth_page(ltbp->p_notebook, 0);
         ltbp->p_notebook_page_task = gtk_notebook_get_nth_page(ltbp->p_notebook, 1);
-        switch (ltbp->mode) {
-        default:
-        case LAUNCHTASKBAR:
-            gtk_widget_set_visible(ltbp->p_notebook_page_launch, TRUE);
-            gtk_widget_set_visible(ltbp->p_notebook_page_task, TRUE);
-            gtk_notebook_set_show_tabs(ltbp->p_notebook, TRUE);
-            object = gtk_builder_get_object(builder, "radiobutton_launchtask");
-            break;
-        case TASKBAR:
-            gtk_widget_set_visible(ltbp->p_notebook_page_launch, FALSE);
-            gtk_widget_set_visible(ltbp->p_notebook_page_task, TRUE);
-            gtk_notebook_set_show_tabs(ltbp->p_notebook, FALSE);
-            object = gtk_builder_get_object(builder, "radiobutton_task");
-            break;
-        case LAUNCHBAR:
-            gtk_widget_set_visible(ltbp->p_notebook_page_launch, TRUE);
-            gtk_widget_set_visible(ltbp->p_notebook_page_task, FALSE);
-            gtk_notebook_set_show_tabs(ltbp->p_notebook, FALSE);
-            object = gtk_builder_get_object(builder, "radiobutton_launch");
-        }
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), TRUE);
-
-        object = gtk_builder_get_object(builder, "radiobutton_launch");
-        g_signal_connect(object, "toggled",
-                         G_CALLBACK(on_radiobutton_launch_toggled), ltbp);
-        object = gtk_builder_get_object(builder, "radiobutton_task");
-        g_signal_connect(object, "toggled",
-                         G_CALLBACK(on_radiobutton_task_toggled), ltbp);
-        object = gtk_builder_get_object(builder, "radiobutton_launchtask");
-        g_signal_connect(object, "toggled",
-                         G_CALLBACK(on_radiobutton_launchtask_toggled), ltbp);
+        set_config_visibility(ltbp);
+       object = gtk_builder_get_object(builder, "combobox_mode");
+        gtk_combo_box_set_active(GTK_COMBO_BOX(object), ltbp->mode);
+       g_signal_connect(object, "changed",
+                       G_CALLBACK(on_combobox_mode_changed), ltbp);
 
 #define SETUP_TOGGLE_BUTTON(button,member) \
         object = gtk_builder_get_object(builder, #button); \