[recipes/gtk-ifdefs] wip: ifdeffery



commit cc2277cce3dfe0ba6a48b3e8f50bfae36299066f
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Feb 24 15:35:48 2017 -0500

    wip: ifdeffery
    
    Just enough ifdefs and commented out things to make a window
    appear with gtk 3.18 and the X backend. Its not pretty, though.

 configure.ac               |    4 ++--
 src/gr-about-dialog.c      |   11 ++++++++++-
 src/gr-app.c               |    4 ++++
 src/gr-chef-dialog.c       |    9 +++++++++
 src/gr-cooking-view.c      |    4 ++++
 src/gr-edit-page.c         |   36 ++++++++++++++++++++++++++++++++++++
 src/gr-edit-page.ui        |   14 ++++++++++++++
 src/gr-image-page.c        |   14 +++++++++++++-
 src/gr-image-viewer.c      |    4 ++++
 src/gr-mail.c              |    6 +++++-
 src/gr-query-editor.c      |    4 ++++
 src/gr-query-editor.ui     |    2 ++
 src/gr-recipe-small-tile.c |    2 +-
 src/gr-recipes-page.ui     |    2 ++
 src/gr-shopping-page.c     |    2 +-
 src/gr-utils.c             |   37 ++++++++++++++++++++++++++++++++++++-
 src/gr-utils.h             |    3 +++
 src/gr-window.c            |    4 ++++
 18 files changed, 154 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bdb5b98..3c4fccb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,8 +136,8 @@ fi
 dnl ***********************************************************************
 dnl Check for required packages
 dnl ***********************************************************************
-PKG_CHECK_MODULES(RECIPES, [gio-2.0 >= 2.42
-                            gtk+-3.0 >= 3.20
+PKG_CHECK_MODULES(RECIPES, [gio-2.0
+                            gtk+-3.0
                             $AUTOAR_DEP
                             $GSPELL_DEP
                             $CANBERRA_DEP])
diff --git a/src/gr-about-dialog.c b/src/gr-about-dialog.c
index 3a4ee0c..32f36fc 100644
--- a/src/gr-about-dialog.c
+++ b/src/gr-about-dialog.c
@@ -83,7 +83,11 @@ builder_info (GtkButton *button,
         const char *uri = "http://wiki.gnome.org/Apps/Builder";;
         g_autoptr(GError) error = NULL;
 
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_show_uri_on_window (GTK_WINDOW (about), uri, GDK_CURRENT_TIME, &error);
+#else
+        gtk_show_uri (gtk_widget_get_screen (about), uri, GDK_CURRENT_TIME, &error);
+#endif
         if (error)
                 g_warning ("Unable to show '%s': %s", uri, error->message);
 }
@@ -521,8 +525,13 @@ follow_if_link (GrAboutDialog *about,
                 GtkTextTag *tag = tagp->data;
 
                 uri = g_object_get_data (G_OBJECT (tag), "uri");
-                if (uri)
+                if (uri) {
+#if GTK_CHECK_VERSION(3,22,0)
                         gtk_show_uri_on_window (GTK_WINDOW (about), uri, GDK_CURRENT_TIME, NULL);
+#else
+                        gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (about)), uri, GDK_CURRENT_TIME, 
NULL);
+#endif
+                }
         }
 
         g_slist_free (tags);
diff --git a/src/gr-app.c b/src/gr-app.c
index 9711d5a..db4b45a 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -302,7 +302,11 @@ gr_app_new (void)
 {
         return g_object_new (GR_TYPE_APP,
                              "application-id", "org.gnome.Recipes",
+#if GLIB_CHECK_VERSION(2,48,0)
                              "flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_CAN_OVERRIDE_APP_ID,
+#else
+                             "flags", G_APPLICATION_HANDLES_OPEN,
+#endif
                              NULL);
 }
 
diff --git a/src/gr-chef-dialog.c b/src/gr-chef-dialog.c
index dec39a7..be6ec1c 100644
--- a/src/gr-chef-dialog.c
+++ b/src/gr-chef-dialog.c
@@ -115,6 +115,7 @@ field_changed (GrChefDialog *self)
         gtk_widget_set_sensitive (self->save_button, TRUE);
 }
 
+#if 0
 static void
 file_chooser_response (GtkNativeDialog *self,
                        gint             response_id,
@@ -138,10 +139,12 @@ file_chooser_response (GtkNativeDialog *self,
                 field_changed (prefs);
         }
 }
+#endif
 
 static void
 image_button_clicked (GrChefDialog *self)
 {
+#if 0
         GtkFileChooserNative *chooser;
         g_autoptr(GtkFileFilter) filter = NULL;
 
@@ -161,6 +164,7 @@ image_button_clicked (GrChefDialog *self)
         g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), self);
 
         gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
+#endif
 }
 
 static void
@@ -348,7 +352,12 @@ chef_selected (GrChefDialog  *dialog,
 
         chef = g_object_get_data (G_OBJECT (row), "chef");
         gr_chef_dialog_set_chef (dialog, chef);
+
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popdown (GTK_POPOVER (dialog->chef_popover));
+#else
+        gtk_widget_hide (dialog->chef_popover);
+#endif
 }
 
 static void
diff --git a/src/gr-cooking-view.c b/src/gr-cooking-view.c
index c4830dd..d9b5461 100644
--- a/src/gr-cooking-view.c
+++ b/src/gr-cooking-view.c
@@ -184,7 +184,11 @@ step_data_new (int         num,
 
                         button = gtk_button_new ();
                         gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+#if GTK_CHECK_VERSION(3,20,0)
                         gtk_widget_set_focus_on_click (button, FALSE);
+#else
+                        gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
+#endif
                         gtk_style_context_add_class (gtk_widget_get_style_context (button), "osd");
                         g_signal_connect_swapped (button, "clicked", G_CALLBACK (go_to_step), d);
 
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index 0ff8386..ecbc206 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -427,7 +427,11 @@ add_ingredient (GtkButton *button, GrEditPage *page)
         hide_ingredients_search_list (page, FALSE);
         hide_units_search_list (page, FALSE);
 
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popup (GTK_POPOVER (page->ingredient_popover));
+#else
+        gtk_widget_show (page->ingredient_popover);
+#endif
 }
 
 static void
@@ -473,7 +477,11 @@ edit_ingredients_row (GtkListBoxRow *row,
         hide_ingredients_search_list (page, FALSE);
         hide_units_search_list (page, FALSE);
 
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popup (GTK_POPOVER (page->ingredient_popover));
+#else
+        gtk_widget_show (page->ingredient_popover);
+#endif
 }
 
 static void
@@ -673,7 +681,11 @@ add_ingredient2 (GtkButton *button, GrEditPage *page)
         GtkWidget *b;
         GtkWidget *row;
 
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popdown (GTK_POPOVER (page->ingredient_popover));
+#else
+        gtk_widget_hide (page->ingredient_popover);
+#endif
 
         b = gtk_popover_get_relative_to (GTK_POPOVER (page->ingredient_popover));
         if (GTK_IS_LIST_BOX_ROW (b)) {
@@ -1052,14 +1064,22 @@ image_activated (GtkFlowBox *flowbox,
         text = g_strdup_printf ("[image:%d]", idx);
         add_tag_to_step (self, text);
 
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popdown (GTK_POPOVER (self->image_popover));
+#else
+        gtk_widget_hide (self->image_popover);
+#endif
         gtk_widget_grab_focus (self->instructions_field);
 }
 
 static void
 add_image_link (GtkButton *button, GrEditPage *page)
 {
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popup (GTK_POPOVER (page->image_popover));
+#else
+        gtk_widget_show (page->image_popover);
+#endif
 }
 
 static int
@@ -1193,14 +1213,22 @@ time_spin_activate (GtkEntry *entry, GrEditPage *self)
 
         add_tag_to_step (self, text);
 
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popdown (GTK_POPOVER (self->timer_popover));
+#else
+        gtk_widget_hide (self->timer_popover);
+#endif
         gtk_widget_grab_focus (self->instructions_field);
 }
 
 static void
 add_timer (GtkButton *button, GrEditPage *page)
 {
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popup (GTK_POPOVER (page->timer_popover));
+#else
+        gtk_widget_show (page->timer_popover);
+#endif
 }
 
 static void
@@ -1221,13 +1249,21 @@ temperature_spin_activate (GtkEntry *entry, GrEditPage *self)
         text = g_strdup_printf ("[temperature:%d%s]", value, unit);
         add_tag_at_insert (self, text);
 
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popdown (GTK_POPOVER (self->temperature_popover));
+#else
+        gtk_widget_hide (self->temperature_popover);
+#endif
         gtk_widget_grab_focus (self->instructions_field);
 }
 static void
 add_temperature (GtkButton *button, GrEditPage *page)
 {
+#if GTK_CHECK_VERSION(3,22,0)
         gtk_popover_popup (GTK_POPOVER (page->temperature_popover));
+#else
+        gtk_widget_show (page->temperature_popover);
+#endif
 }
 
 static void
diff --git a/src/gr-edit-page.ui b/src/gr-edit-page.ui
index 57409ee..f77c236 100644
--- a/src/gr-edit-page.ui
+++ b/src/gr-edit-page.ui
@@ -806,7 +806,9 @@
     </child>
   </template>
   <object class="GtkPopover" id="ingredient_popover">
+<!--
     <property name="constrain-to">none</property>
+-->
     <signal name="key-press-event" handler="popover_keypress_handler" after="yes"/>
     <child>
       <object class="GtkBox">
@@ -878,8 +880,10 @@
                     <property name="visible">1</property>
                     <property name="shadow-type">in</property>
                     <property name="hscrollbar-policy">never</property>
+<!--
                     <property name="propagate-natural-height">1</property>
                     <property name="max-content-height">220</property>
+-->
                     <property name="height-request">220</property>
                     <child>
                       <object class="GtkListBox" id="ing_list">
@@ -971,8 +975,10 @@
                     <property name="visible">1</property>
                     <property name="shadow-type">in</property>
                     <property name="hscrollbar-policy">never</property>
+<!--
                     <property name="propagate-natural-height">1</property>
                     <property name="max-content-height">220</property>
+-->
                     <property name="height-request">220</property>
                     <child>
                       <object class="GtkListBox" id="unit_list">
@@ -999,7 +1005,9 @@
   </object>
   <object class="GtkPopover" id="image_popover">
     <property name="relative-to">link_image_button</property>
+<!--
     <property name="constrain-to">none</property>
+-->
     <child>
       <object class="GtkFlowBox" id="image_flowbox">
         <property name="visible">1</property>
@@ -1020,7 +1028,9 @@
   </object>
   <object class="GtkPopover" id="timer_popover">
     <property name="relative-to">timer_button</property>
+<!--
     <property name="constrain-to">none</property>
+-->
     <child>
       <object class="GtkBox">
         <property name="visible">1</property>
@@ -1055,7 +1065,9 @@
   </object>
   <object class="GtkPopover" id="temperature_popover">
     <property name="relative-to">temperature_button</property>
+<!--
     <property name="constrain-to">none</property>
+-->
     <child>
       <object class="GtkBox">
         <property name="visible">1</property>
@@ -1102,7 +1114,9 @@
   </object>
   <object class="GtkPopover" id="directions_help_popover">
     <property name="relative-to">directions_help_button</property>
+<!--
     <property name="constrain-to">none</property>
+-->
     <child>
       <object class="GtkGrid">
         <property name="visible">1</property>
diff --git a/src/gr-image-page.c b/src/gr-image-page.c
index 7310b30..d367857 100644
--- a/src/gr-image-page.c
+++ b/src/gr-image-page.c
@@ -88,13 +88,25 @@ set_current_image (GrImagePage *page)
                 g_autoptr(GdkPixbuf) pixbuf = NULL;
                 GdkDisplay *display;
                 GdkWindow *win;
-                GdkMonitor *monitor;
                 GdkRectangle geom;
 
                 display = gtk_widget_get_display (GTK_WIDGET (page));
                 win = gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (page)));
+#if GTK_CHECK_VERSION(3,22,0)
+                {
+                GdkMonitor *monitor;
                 monitor = gdk_display_get_monitor_at_window (display, win);
                 gdk_monitor_get_geometry (monitor, &geom);
+                }
+#else
+                {
+                GdkScreen *screen;
+                int monitor;
+                screen = gdk_display_get_default_screen (display);
+                monitor = gdk_screen_get_monitor_at_window (screen, win);
+                gdk_screen_get_monitor_geometry (screen, monitor, &geom);
+                }
+#endif
 
                 ri = &g_array_index (page->images, GrImage, page->index);
                 pixbuf = load_pixbuf_fit_size (ri->path, 0, geom.width - 80, geom.height - 80, FALSE);
diff --git a/src/gr-image-viewer.c b/src/gr-image-viewer.c
index 2b6f8ac..75613b3 100644
--- a/src/gr-image-viewer.c
+++ b/src/gr-image-viewer.c
@@ -570,6 +570,7 @@ gr_image_viewer_set_images (GrImageViewer *viewer,
         g_object_thaw_notify (G_OBJECT (viewer));
 }
 
+#if 0
 static void
 file_chooser_response (GtkNativeDialog *self,
                        gint             response_id,
@@ -595,10 +596,12 @@ file_chooser_response (GtkNativeDialog *self,
                 show_controls (viewer);
         }
 }
+#endif
 
 static void
 open_filechooser (GrImageViewer *viewer)
 {
+#if 0
         GtkWidget *window;
         GtkFileChooserNative *chooser;
         g_autoptr(GtkFileFilter) filter = NULL;
@@ -635,6 +638,7 @@ open_filechooser (GrImageViewer *viewer)
         g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), viewer);
 
         gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
+#endif
 }
 
 void
diff --git a/src/gr-mail.c b/src/gr-mail.c
index 8769819..49c58bc 100644
--- a/src/gr-mail.c
+++ b/src/gr-mail.c
@@ -68,7 +68,11 @@ send_mail_using_mailto (MailData *data)
                 g_string_append_printf (url, "&attach=%s", path);
         }
 
-        gtk_show_uri_on_window (data->window, url->str, GDK_CURRENT_TIME, NULL);
+#if GTK_CHECK_VERSION(3,22,0)
+        gtk_show_uri_on_window (GTK_WINDOW (data->window), url->str, GDK_CURRENT_TIME, NULL);
+#else
+        gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (data->window)), url->str, GDK_CURRENT_TIME, NULL);
+#endif
 
         mail_data_free (data);
 }
diff --git a/src/gr-query-editor.c b/src/gr-query-editor.c
index 359a5cf..caad99e 100644
--- a/src/gr-query-editor.c
+++ b/src/gr-query-editor.c
@@ -1095,7 +1095,11 @@ gr_query_editor_handle_event (GrQueryEditor *editor,
         if (event->type == GDK_KEY_PRESS) {
                 GdkEventKey *e = (GdkEventKey *) event;
                 if ((e->state & GDK_MOD1_MASK) > 0 && e->keyval == GDK_KEY_Down) {
+#if GTK_CHECK_VERSION(3,22,0)
                         gtk_popover_popup (GTK_POPOVER (editor->popover));
+#else
+                        gtk_widget_show (editor->popover);
+#endif
                         return GDK_EVENT_PROPAGATE;
                 }
         }
diff --git a/src/gr-query-editor.ui b/src/gr-query-editor.ui
index 368f75a..c5c3e72 100644
--- a/src/gr-query-editor.ui
+++ b/src/gr-query-editor.ui
@@ -293,8 +293,10 @@
                     <property name="visible">1</property>
                     <property name="shadow-type">in</property>
                     <property name="hscrollbar-policy">never</property>
+<!--
                     <property name="propagate-natural-height">1</property>
                     <property name="max-content-height">300</property>
+-->
                     <child>
                       <object class="GtkListBox" id="ing_list">
                         <property name="visible">1</property>
diff --git a/src/gr-recipe-small-tile.c b/src/gr-recipe-small-tile.c
index 2c78be0..94c8f18 100644
--- a/src/gr-recipe-small-tile.c
+++ b/src/gr-recipe-small-tile.c
@@ -114,7 +114,7 @@ recipe_small_tile_set_recipe (GrRecipeSmallTile *tile,
 static void
 tile_clicked (GrRecipeSmallTile *tile)
 {
-        gtk_popover_popup (GTK_POPOVER (tile->popover));
+        popover_popup (GTK_POPOVER (tile->popover));
 }
 
 static void
diff --git a/src/gr-recipes-page.ui b/src/gr-recipes-page.ui
index bf26613..875c2eb 100644
--- a/src/gr-recipes-page.ui
+++ b/src/gr-recipes-page.ui
@@ -14,7 +14,9 @@
         <property name="visible">1</property>
         <property name="hscrollbar-policy">never</property>
         <property name="vscrollbar-policy">automatic</property>
+<!--
         <property name="propagate-natural-height">1</property>
+-->
         <child>
           <object class="GtkBox">
             <property name="visible">1</property>
diff --git a/src/gr-shopping-page.c b/src/gr-shopping-page.c
index e371ac5..40ce646 100644
--- a/src/gr-shopping-page.c
+++ b/src/gr-shopping-page.c
@@ -384,7 +384,7 @@ removed_row_activated (GtkListBox     *list,
         Ingredient *ing;
 
         popover = gtk_widget_get_ancestor (GTK_WIDGET (row), GTK_TYPE_POPOVER);
-        gtk_popover_popdown (GTK_POPOVER (popover));
+        popover_popdown (GTK_POPOVER (popover));
 
         label = GTK_WIDGET (g_object_get_data (G_OBJECT (row), "ing"));
         name = gtk_label_get_label (GTK_LABEL (label));
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 0b6e0f5..e30f11c 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -502,6 +502,7 @@ all_headers (GtkListBoxRow *row,
         gtk_list_box_row_set_header (row, header);
 }
 
+#if GTK_CHECK_VERSION(3,22,0)
 #ifdef GDK_WINDOWING_WAYLAND
 typedef struct {
         GtkWindow *window;
@@ -524,13 +525,14 @@ wayland_window_handle_exported (GdkWindow  *window,
         g_free (data);
 }
 #endif
+#endif
 
 gboolean
 window_export_handle (GtkWindow            *window,
                       WindowHandleExported  callback,
                       gpointer              user_data)
 {
-
+#if GTK_CHECK_VERSION(3,22,0)
 #ifdef GDK_WINDOWING_X11
         if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) {
                 GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
@@ -565,6 +567,7 @@ window_export_handle (GtkWindow            *window,
                 }
         }
 #endif
+#endif
 
         g_warning ("Couldn't export handle, unsupported windowing system");
 
@@ -574,6 +577,7 @@ window_export_handle (GtkWindow            *window,
 void
 window_unexport_handle (GtkWindow *window)
 {
+#if GTK_CHECK_VERSION(3,22,0)
 #ifdef GDK_WINDOWING_WAYLAND
   if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
     {
@@ -582,6 +586,7 @@ window_unexport_handle (GtkWindow *window)
       gdk_wayland_window_unexport_handle (gdk_window);
     }
 #endif
+#endif
 }
 
 static char *
@@ -708,3 +713,33 @@ remove_image (const char *path)
                 g_print ("Not removing image %s", path);
         }
 }
+
+#if GTK_CHECK_VERSION(3,22,0)
+
+void
+popover_popup (GtkPopover *popover)
+{
+        gtk_popover_popup (popover);
+}
+
+void
+popover_popdown (GtkPopover *popover)
+{
+        gtk_popover_popdown (popover);
+}
+
+#else
+
+void
+popover_popup (GtkPopover *popover)
+{
+        gtk_widget_show (GTK_WIDGET (popover));
+}
+
+void
+popover_popdown (GtkPopover *popover)
+{
+        gtk_widget_hide (GTK_WIDGET (popover));
+}
+
+#endif
diff --git a/src/gr-utils.h b/src/gr-utils.h
index d077726..44cef1e 100644
--- a/src/gr-utils.h
+++ b/src/gr-utils.h
@@ -81,3 +81,6 @@ char *import_image (const char *path);
 char *rotate_image (const char *path,
                     int         angle);
 void  remove_image (const char *path);
+
+void popover_popup   (GtkPopover *popover);
+void popover_popdown (GtkPopover *popover);
diff --git a/src/gr-window.c b/src/gr-window.c
index d8cac3d..a988599 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -768,6 +768,7 @@ do_import (GrWindow *window,
         gr_recipe_importer_import_from (window->importer, file);
 }
 
+#if 0
 static void
 file_chooser_response (GtkNativeDialog *self,
                        int              response_id,
@@ -782,6 +783,7 @@ file_chooser_response (GtkNativeDialog *self,
         gtk_native_dialog_destroy (self);
         window->file_chooser = NULL;
 }
+#endif
 
 static void
 chef_done (GrChefDialog *dialog,
@@ -859,6 +861,7 @@ gr_window_load_recipe (GrWindow *window,
         if (window->file_chooser)
                 return;
 
+#if 0
         window->file_chooser = (GObject *)gtk_file_chooser_native_new (_("Select a recipe file"),
                                                                        GTK_WINDOW (window),
                                                                        GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -869,6 +872,7 @@ gr_window_load_recipe (GrWindow *window,
         g_signal_connect (window->file_chooser, "response", G_CALLBACK (file_chooser_response), window);
 
         gtk_native_dialog_show (GTK_NATIVE_DIALOG (window->file_chooser));
+#endif
 }
 
 void


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