Add support for monitors "All" to span panel over all monitors.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 11 Nov 2014 18:19:03 +0000 (20:19 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 11 Nov 2014 18:19:03 +0000 (20:19 +0200)
ChangeLog
data/ui/panel-pref.glade
plugins/launchtaskbar.c
src/configurator.c
src/misc.c
src/panel.c
src/plugin.h
src/private.h

index 07f662e..8e2d323 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
 * Added CONF_TYPE_EXTERNAL support for lxpanel_generic_config_dlg().
 * Implemented property "aspect-width" for PanelIconGrid to allow using
     non-square tray sockets.
+* Added support for monitors "All" to span panel over all monitors (i.e.
+    to allow pre-0.6.0 behavior).
 
 0.7.2
 -------------------------------------------------------------------------
index 5b856ec..e59dcce 100644 (file)
@@ -3,7 +3,6 @@
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkAdjustment" id="adjustment1">
-    <property name="lower">0</property>
     <property name="upper">10</property>
     <property name="value">2</property>
     <property name="step_increment">1</property>
     <property name="value">10</property>
     <property name="step_increment">1</property>
   </object>
-  <object class="GtkAdjustment" id="adjustment7">
-    <property name="lower">1</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">1</property>
-  </object>
   <object class="GtkListStore" id="liststore1">
     <columns>
       <!-- column-name item -->
       </row>
     </data>
   </object>
+  <object class="GtkListStore" id="liststore4">
+    <columns>
+      <!-- column-name mon -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">All</col>
+      </row>
+      <row>
+        <col id="0">1</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="panel_pref">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="yalign">0.10000000149011612</property>
-                                        <property name="xscale">0.80000001192092896</property>
+                                        <property name="xscale">0.85</property>
                                         <property name="yscale">0</property>
                                         <property name="left_padding">12</property>
                                         <property name="right_padding">12</property>
                                         <child>
-                                          <object class="GtkSpinButton" id="monitor">
+                                          <object class="GtkComboBox" id="monitor">
                                             <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="invisible_char">•</property>
-                                            <property name="width_chars">6</property>
-                                            <property name="invisible_char_set">True</property>
-                                            <property name="primary_icon_activatable">False</property>
-                                            <property name="secondary_icon_activatable">False</property>
-                                            <property name="primary_icon_sensitive">True</property>
-                                            <property name="secondary_icon_sensitive">True</property>
-                                            <property name="adjustment">adjustment7</property>
-                                            <property name="climb_rate">1</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="model">liststore4</property>
                                           </object>
                                         </child>
                                       </object>
                                 <child>
                                   <object class="GtkComboBox" id="fm_combobox">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
+                                    <property name="can_focus">False</property>
                                   </object>
                                   <packing>
                                     <property name="expand">True</property>
index e2a5406..552ef62 100644 (file)
@@ -1319,6 +1319,8 @@ static void on_menu_view_row_activated(GtkTreeView *tree_view, GtkTreePath *path
     _launchbar_configure_add(tree_view, ltbp);
 }
 
+/* FIXME: add support for global hotkeys for launchers */
+
 /* Callback when the configuration dialog is to be shown. */
 static GtkWidget *launchtaskbar_configure(LXPanel *panel, GtkWidget *p)
 {
@@ -1616,7 +1618,8 @@ static gboolean task_is_visible(LaunchTaskBarPlugin * tb, Task * tk)
         return FALSE;
 
     /* Not on same monitor */
-    if (tb->same_monitor_only && panel_get_monitor(tb->panel) != tk->monitor)
+    if (tb->same_monitor_only && panel_get_monitor(tb->panel) != tk->monitor
+        && panel_get_monitor(tb->panel) >= 0)
         return FALSE;
 
     /* Desktop placement. */
index 64050d5..d9e3ef6 100644 (file)
@@ -122,11 +122,12 @@ gboolean panel_edge_available(Panel* p, int edge, gint monitor)
 {
     GSList* l;
     for (l = all_panels; l != NULL; l = l->next)
-        {
+    {
         LXPanel* pl = (LXPanel*) l->data;
-        if ((pl->priv != p) && (pl->priv->edge == edge) && (pl->priv->monitor == monitor))
+        if ((pl->priv != p) && (pl->priv->edge == edge) &&
+            (pl->priv->monitor < 0 || monitor < 0 || pl->priv->monitor == monitor))
             return FALSE;
-        }
+    }
     return TRUE;
 }
 
@@ -138,6 +139,7 @@ static void set_edge(LXPanel* panel, int edge)
     update_panel_geometry(panel);
     _panel_set_panel_configuration_changed(panel);
     UPDATE_GLOBAL_STRING(p, "edge", num2str(edge_pair, edge, "none"));
+    //FIXME: update monitors and strut sensitivities
 }
 
 static void edge_bottom_toggle(GtkToggleButton *widget, LXPanel *p)
@@ -164,6 +166,7 @@ static void edge_right_toggle(GtkToggleButton *widget, LXPanel *p)
         set_edge(p, EDGE_RIGHT);
 }
 
+/* only for old UI file, safe fallback */
 static void set_monitor(GtkSpinButton *widget, LXPanel *panel)
 {
     Panel *p = panel->priv;
@@ -174,6 +177,35 @@ static void set_monitor(GtkSpinButton *widget, LXPanel *panel)
     UPDATE_GLOBAL_INT(p, "monitor", p->monitor);
 }
 
+static void update_mon_sensitivity(GtkCellLayout *layout, GtkCellRenderer *cell,
+                                   GtkTreeModel *model, GtkTreeIter *iter,
+                                   gpointer user_data)
+{
+    LXPanel *panel = user_data;
+    Panel *p = panel->priv;
+    GtkTreePath *path;
+    gint *indices;
+
+    /* set it sensitive if edge is available */
+    path = gtk_tree_model_get_path(model, iter);
+    indices = gtk_tree_path_get_indices(path);
+    g_object_set(cell, "sensitive", (panel_edge_available(p, p->edge,
+                                                          indices[0] - 1)), NULL);
+    gtk_tree_path_free(path);
+}
+
+static void set_monitor_cb(GtkComboBox *cb, LXPanel *panel)
+{
+    Panel *p = panel->priv;
+
+    /* change monitor */
+    p->monitor = gtk_combo_box_get_active(cb) - 1;
+    update_panel_geometry(panel);
+    _panel_set_panel_configuration_changed(panel);
+    UPDATE_GLOBAL_INT(p, "monitor", p->monitor);
+    //FIXME: update edge and strut sensitivities
+}
+
 static void set_alignment(LXPanel* panel, int align)
 {
     Panel *p = panel->priv;
@@ -986,14 +1018,39 @@ void panel_configure( LXPanel* panel, int sel_page )
 
     /* monitor */
     monitors = 1;
-    screen = gdk_screen_get_default();
+    screen = gtk_widget_get_screen(GTK_WIDGET(panel));
     if(screen) monitors = gdk_screen_get_n_monitors(screen);
     g_assert(monitors >= 1);
     w = (GtkWidget*)gtk_builder_get_object( builder, "monitor" );
-    gtk_spin_button_set_range(GTK_SPIN_BUTTON(w), 1, monitors);
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), p->monitor + 1);
-    gtk_widget_set_sensitive(w, monitors > 1);
-    g_signal_connect(w, "value-changed", G_CALLBACK(set_monitor), panel);
+    if (GTK_IS_SPIN_BUTTON(w))
+    {
+        gtk_spin_button_set_range(GTK_SPIN_BUTTON(w), 1, monitors);
+        gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), p->monitor + 1);
+        gtk_widget_set_sensitive(w, monitors > 1);
+        g_signal_connect(w, "value-changed", G_CALLBACK(set_monitor), panel);
+    }
+    else if (GTK_IS_COMBO_BOX(w))
+    {
+        GtkCellRenderer *cell;
+        gint i;
+        char itext[4];
+
+        /* create a new cell renderer and bind cell data function to it */
+        cell = gtk_cell_renderer_text_new();
+        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(w), cell, TRUE);
+        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(w), cell, "text", 0);
+        gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(w), cell,
+                                           update_mon_sensitivity, panel, NULL);
+        /* add monitors beyond first one to the model */
+        for (i = 1; i < monitors; i++)
+        {
+            snprintf(itext, sizeof(itext), "%d", i + 1);
+            gtk_combo_box_append_text(GTK_COMBO_BOX(w), itext);
+        }
+        gtk_combo_box_set_active(GTK_COMBO_BOX(w), p->monitor + 1);
+        /* FIXME: set sensitive only if more than 1 monitor available? */
+        g_signal_connect(w, "changed", G_CALLBACK(set_monitor_cb), panel);
+    }
 
     /* alignment */
     p->alignment_left_label = w = (GtkWidget*)gtk_builder_get_object( builder, "alignment_left" );
index f15961b..3fdf57c 100644 (file)
@@ -843,8 +843,22 @@ void _calculate_position(LXPanel *panel)
         marea.height = np->workarea[np->curdesk*4 + 3];
     } else {
         screen = gtk_widget_get_screen(GTK_WIDGET(panel));
-        g_assert(np->monitor >= 0 && np->monitor < gdk_screen_get_n_monitors(screen));
-        gdk_screen_get_monitor_geometry(screen,np->monitor,&marea);
+        if (np->monitor < 0) /* all monitors */
+        {
+            marea.x = 0;
+            marea.y = 0;
+            marea.width = gdk_screen_get_width(screen);
+            marea.height = gdk_screen_get_height(screen);
+        }
+        else if (np->monitor < gdk_screen_get_n_monitors(screen))
+            gdk_screen_get_monitor_geometry(screen,np->monitor,&marea);
+        else
+        {
+            marea.x = 0;
+            marea.y = 0;
+            marea.width = 0;
+            marea.height = 0;
+        }
     }
 
     if (np->edge == EDGE_TOP || np->edge == EDGE_BOTTOM) {
index c74bfff..030d8ea 100644 (file)
@@ -328,7 +328,7 @@ static void panel_normalize_configuration(Panel* p)
             p->height = PANEL_HEIGHT_MAX;
     }
     if (p->monitor < 0)
-        p->monitor = 0;
+        p->monitor = -1;
     if (p->background)
         p->transparent = 0;
 }
@@ -797,9 +797,10 @@ static void panel_popupmenu_create_panel( GtkMenuItem* item, LXPanel* panel )
     config_setting_t *global;
 
     /* Allocate the edge. */
-    screen = gdk_screen_get_default();
+    screen = gtk_widget_get_screen(GTK_WIDGET(panel));
     g_assert(screen);
     monitors = gdk_screen_get_n_monitors(screen);
+    /* FIXME: try to allocate edge on current monitor first */
     for(m=0; m<monitors; ++m)
     {
         /* try each of the four edges */
index a734080..7a55b1c 100644 (file)
@@ -242,6 +242,7 @@ extern void lxpanel_plugin_show_config_dialog(GtkWidget* plugin);
  * @CONF_TYPE_DIRECTORY_ENTRY: directory path entry, pointer is char **
  * @CONF_TYPE_TRIM: just a text in italic, pointer is ignored
  * @CONF_TYPE_EXTERNAL: (since 0.8) provided by caller, pointer is GtkWidget *
+ * @CONF_TYPE_HOTKEY: (not implemented) change global hotkey, pointer is char **
  *
  * Type of variable passed to lxpanel_generic_config_dlg().
  */
@@ -253,7 +254,8 @@ typedef enum {
     CONF_TYPE_FILE_ENTRY,
     CONF_TYPE_DIRECTORY_ENTRY,
     CONF_TYPE_TRIM,
-    CONF_TYPE_EXTERNAL
+    CONF_TYPE_EXTERNAL,
+    //CONF_TYPE_HOTKEY
 } PluginConfType;
 
 /**
index b0ea442..f3f001c 100644 (file)
@@ -235,6 +235,14 @@ void restart(void);
 void logout(void);
 void gtk_run(void);
 
+/*
+ * creates GtkButton subclass which can change, test and apply global hotkey
+ * emits "changed" signal: void callback(LXHotkeyButton *, char *, gpointer);
+ */
+/*
+GtkWidget *_config_hotkey_button_new(const char *hotkey);
+*/
+
 /* -----------------------------------------------------------------------------
  *   Deprecated declarations. Kept for compatibility with old code plugins.
  *   Should be removed and appropriate code cleaned on some of next releases. */