launchbar adding tooltip of Exe
authorGiuseppe Penone <giuspen@gmail.com>
Sat, 1 Sep 2012 15:51:11 +0000 (17:51 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Mon, 26 Nov 2012 21:11:05 +0000 (23:11 +0200)
data/ui/launchbar.glade
src/plugins/launchbar.c

index 1b12775..2ba6450 100644 (file)
             <property name="can_focus">False</property>
             <property name="spacing">12</property>
             <child>
-              <object class="GtkScrolledWindow" id="scroll1">
-                <property name="width_request">230</property>
+              <object class="GtkVBox" id="vbox_defined">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">automatic</property>
-                <property name="vscrollbar_policy">automatic</property>
-                <property name="shadow_type">etched-in</property>
+                <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkTreeView" id="defined_view">
+                  <object class="GtkScrolledWindow" id="scroll1">
+                    <property name="width_request">230</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="model">defined_store</property>
-                    <property name="search_column">1</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">etched-in</property>
                     <child>
-                      <object class="GtkTreeViewColumn" id="defined_col">
-                        <property name="title">Applications</property>
-                        <property name="expand">True</property>
+                      <object class="GtkTreeView" id="defined_view">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="model">defined_store</property>
+                        <property name="headers_clickable">False</property>
+                        <property name="search_column">1</property>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="defined_col">
+                            <property name="title">Applications</property>
+                            <property name="expand">True</property>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label_def_app_exec">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
               <packing>
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox2">
+              <object class="GtkVBox" id="vbox_menu">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
index 7717e55..b92ddb1 100644 (file)
@@ -93,7 +93,7 @@ typedef struct {
     GSList * buttons;                  /* Launchbar buttons */
     GtkWidget * config_dlg;            /* Configuration dialog */
     LaunchButton * bootstrap_button;   /* Bootstrapping button for empty launchbar */
-    GtkWidget     *p_button_add, *p_button_remove, *p_label_menu_app_exec;
+    GtkWidget     *p_button_add, *p_button_remove, *p_label_menu_app_exec, *p_label_def_app_exec;
 } LaunchbarPlugin;
 
 void panel_config_save(Panel * panel);  /* defined in configurator.c */
@@ -147,6 +147,35 @@ static gboolean on_defined_view_button_press_event(GtkWidget *p_widget, GdkEvent
     return FALSE;
 }
 
+static void on_defined_view_cursor_changed(GtkTreeView *p_treeview, gpointer p_data)
+{
+    gboolean  label_set = FALSE;
+    LaunchbarPlugin *lb = (LaunchbarPlugin *)p_data;
+    GtkTreeIter  tree_iter_sel;
+    GtkTreeModel* p_treemodel = gtk_tree_view_get_model(p_treeview);
+    GtkTreeSelection *p_treeselection = gtk_tree_view_get_selection(p_treeview);
+    if(gtk_tree_selection_get_selected(p_treeselection,
+                                       (GtkTreeModel **)(&p_treemodel),
+                                       &tree_iter_sel))
+    {
+        LaunchButton * p_btn;
+        gtk_tree_model_get(p_treemodel, &tree_iter_sel, COL_BTN, &p_btn, -1);
+        if( (p_btn != NULL) && (p_btn->action != NULL) )
+        {
+            GString *p_gstring = g_string_new("");
+            g_string_printf(p_gstring, "<i>Exec =</i>  %s", p_btn->action);
+            gtk_label_set_markup(GTK_LABEL(lb->p_label_def_app_exec), p_gstring->str);
+            g_string_free(p_gstring, TRUE/*free also gstring->str*/);
+            gtk_widget_set_visible(lb->p_label_def_app_exec, TRUE);
+            label_set = TRUE;
+        }
+    }
+    if(!label_set)
+    {
+        gtk_widget_set_visible(lb->p_label_def_app_exec, FALSE);
+    }
+}
+
 static void on_menu_view_cursor_changed(GtkTreeView *p_treeview, gpointer p_data)
 {
     gboolean  label_set = FALSE;
@@ -905,6 +934,7 @@ static void launchbar_configure(Plugin * p, GtkWindow * parent)
 
         defined_view = (GtkWidget*)gtk_builder_get_object(builder, "defined_view");
         menu_view = (GtkWidget*)gtk_builder_get_object(builder, "menu_view");
+        lb->p_label_def_app_exec = (GtkWidget*)gtk_builder_get_object(builder, "label_def_app_exec");
         lb->p_label_menu_app_exec = (GtkWidget*)gtk_builder_get_object(builder, "label_menu_app_exec");
 
         /* Connect signals. */
@@ -923,6 +953,7 @@ static void launchbar_configure(Plugin * p, GtkWindow * parent)
         g_signal_connect(btn, "clicked", G_CALLBACK(launchbar_configure_move_down_button), p);
 
         g_signal_connect(defined_view, "button-press-event", G_CALLBACK(on_defined_view_button_press_event), lb);
+        g_signal_connect(defined_view, "cursor-changed", G_CALLBACK(on_defined_view_cursor_changed), lb);
         g_signal_connect(menu_view, "button-press-event", G_CALLBACK(on_menu_view_button_press_event), lb);
         g_signal_connect(menu_view, "cursor-changed", G_CALLBACK(on_menu_view_cursor_changed), lb);
 
@@ -937,6 +968,7 @@ static void launchbar_configure(Plugin * p, GtkWindow * parent)
         launchbar_configure_initialize_list(p, dlg, GTK_TREE_VIEW(menu_view), TRUE);
 
         gtk_widget_set_visible(lb->p_label_menu_app_exec, FALSE);
+        gtk_widget_set_visible(lb->p_label_def_app_exec, FALSE);
 
         g_object_unref(builder);
         return;