Few GTK+3 bits into src/configurator.c and src/icon-grid.c.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 29 Nov 2014 19:26:07 +0000 (21:26 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 29 Nov 2014 19:37:36 +0000 (21:37 +0200)
The src/bg.c is omitted from GTK+3 lxpanel.

src/bg.c
src/configurator.c
src/icon-grid.c

index c9f0f0a..3144f9a 100644 (file)
--- a/src/bg.c
+++ b/src/bg.c
 #include <glib-object.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
+#include <gtk/gtk.h>
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 
+#if !GTK_CHECK_VERSION(3, 0, 0)
+/* we don't provide these APIs for GTK+ 3.0 */
+
 #include "bg.h"
 
 //#define DEBUG
 #include "dbg.h"
 
-
 enum {
     CHANGED,
     LAST_SIGNAL
@@ -290,3 +293,4 @@ fb_bg_get_pix_from_file(GtkWidget *widget, const char *filename)
     g_object_unref( pixbuf );
     RET(pixmap);
 }
+#endif /* GTK_CHECK_VERSION */
index ac0bba9..61e8756 100644 (file)
@@ -1096,6 +1096,10 @@ void panel_configure( LXPanel* panel, int sel_page )
     else if (GTK_IS_COMBO_BOX(w))
     {
         GtkCellRenderer *cell;
+#if GTK_CHECK_VERSION(3, 0, 0)
+        GtkListStore *model;
+        GtkTreeIter it;
+#endif
         gint i;
         char itext[4];
 
@@ -1105,11 +1109,19 @@ void panel_configure( LXPanel* panel, int sel_page )
         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);
+#if GTK_CHECK_VERSION(3, 0, 0)
+        model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(w)));
+#endif
         /* add monitors beyond first one to the model */
         for (i = 1; i < monitors; i++)
         {
             snprintf(itext, sizeof(itext), "%d", i + 1);
+#if GTK_CHECK_VERSION(3, 0, 0)
+            gtk_list_store_append(model, &it);
+            gtk_list_store_set(model, &it, 0, itext, -1);
+#else
             gtk_combo_box_append_text(GTK_COMBO_BOX(w), itext);
+#endif
         }
         gtk_combo_box_set_active(GTK_COMBO_BOX(w), p->monitor + 1);
         /* FIXME: set sensitive only if more than 1 monitor available? */
index a6d6d86..bc93839 100644 (file)
@@ -309,6 +309,47 @@ static void panel_icon_grid_size_request(GtkWidget *widget,
         gtk_widget_queue_resize(widget);
 }
 
+#if GTK_CHECK_VERSION(3, 0, 0)
+static void panel_icon_grid_get_preferred_width(GtkWidget *widget,
+                                                gint *minimal_width,
+                                                gint *natural_width)
+{
+    PanelIconGrid *ig = PANEL_ICON_GRID(widget);
+    GtkRequisition requisition;
+
+    if (ig->orientation == GTK_ORIENTATION_VERTICAL)
+    {
+        if (minimal_width)
+            *minimal_width = MIN(ig->target_dimension, ig->child_width);
+        if (natural_width)
+            *natural_width = ig->target_dimension;
+        return;
+    }
+    panel_icon_grid_size_request(widget, &requisition);
+    if (minimal_width)
+        *minimal_width = requisition.width;
+    if (natural_width)
+        *natural_width = requisition.width;
+}
+
+static void panel_icon_grid_get_preferred_height(GtkWidget *widget,
+                                                 gint *minimal_height,
+                                                 gint *natural_height)
+{
+    PanelIconGrid *ig = PANEL_ICON_GRID(widget);
+    GtkRequisition requisition;
+
+    if (ig->orientation == GTK_ORIENTATION_HORIZONTAL)
+        requisition.height = ig->target_dimension;
+    else
+        panel_icon_grid_size_request(widget, &requisition);
+    if (minimal_height)
+        *minimal_height = requisition.height;
+    if (natural_height)
+        *natural_height = requisition.height;
+}
+#endif
+
 /* Add an icon grid element and establish its initial visibility. */
 static void panel_icon_grid_add(GtkContainer *container, GtkWidget *widget)
 {
@@ -561,10 +602,16 @@ static void panel_icon_grid_realize(GtkWidget *widget)
     if (visible_window)
     {
         attributes.visual = gtk_widget_get_visual(widget);
+#if !GTK_CHECK_VERSION(3, 0, 0)
         attributes.colormap = gtk_widget_get_colormap(widget);
+#endif
         attributes.wclass = GDK_INPUT_OUTPUT;
 
+#if GTK_CHECK_VERSION(3, 0, 0)
+        attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+#else
         attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+#endif
 
         window = gdk_window_new(gtk_widget_get_parent_window(widget),
                                 &attributes, attributes_mask);
@@ -685,7 +732,12 @@ static void panel_icon_grid_class_init(PanelIconGridClass *class)
     object_class->set_property = panel_icon_grid_set_property;
     object_class->get_property = panel_icon_grid_get_property;
 
+#if GTK_CHECK_VERSION(3, 0, 0)
+    widget_class->get_preferred_width = panel_icon_grid_get_preferred_width;
+    widget_class->get_preferred_height = panel_icon_grid_get_preferred_height;
+#else
     widget_class->size_request = panel_icon_grid_size_request;
+#endif
     widget_class->size_allocate = panel_icon_grid_size_allocate;
     widget_class->realize = panel_icon_grid_realize;
     widget_class->unrealize = panel_icon_grid_unrealize;