[nautilus-actions] fma-config-tool: add Gtk conditionals to run under Ubuntu 12 LTS



commit 316056062c7b757b51bedd9d40b5dcd710b3822c
Author: Pierre Wieser <pwieser trychlos org>
Date:   Fri Feb 17 18:11:31 2017 +0100

    fma-config-tool: add Gtk conditionals to run under Ubuntu 12 LTS

 src/ui/egg-tree-multi-dnd.c |    7 +++++--
 src/ui/fma-application.c    |   29 +++++++++++++++++++++++++++++
 src/ui/fma-application.h    |    2 ++
 src/ui/fma-main-window.c    |    6 ++++++
 src/ui/fma-menu-view.c      |    5 +++++
 src/ui/fma-menu.c           |   12 ++++++++++++
 6 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/src/ui/egg-tree-multi-dnd.c b/src/ui/egg-tree-multi-dnd.c
index 6bc1bc9..b02ddef 100644
--- a/src/ui/egg-tree-multi-dnd.c
+++ b/src/ui/egg-tree-multi-dnd.c
@@ -387,10 +387,13 @@ on_motion_event( GtkWidget *widget, GdkEventMotion *event, EggTreeMultiDragSourc
                        GtkTargetList *target_list = v_get_target_list( drag_source );
                        GdkDragAction actions = v_get_drag_actions( drag_source );
 
-                       /*context = gtk_drag_begin(
-                                       widget, target_list, actions, priv_data->pressed_button, ( GdkEvent * 
) event );*/
+#if GTK_CHECK_VERSION( 3, 10, 0 )
                        context = gtk_drag_begin_with_coordinates(
                                        widget, target_list, actions, priv_data->pressed_button, ( GdkEvent * 
) event, priv_data->x, priv_data->y );
+#else
+                       context = gtk_drag_begin(
+                                       widget, target_list, actions, priv_data->pressed_button, ( GdkEvent * 
) event );
+#endif
 
                        set_treeview_data( widget, path_list );
 
diff --git a/src/ui/fma-application.c b/src/ui/fma-application.c
index 68d2daf..a8d9ec3 100644
--- a/src/ui/fma-application.c
+++ b/src/ui/fma-application.c
@@ -55,6 +55,7 @@ struct _FMAApplicationPrivate {
        int             code;
 
        FMAUpdater      *updater;
+       FMAMainWindow   *main_window;
 };
 
 static const gchar *st_application_name        = N_( "FileManager-Actions Configuration Tool" );
@@ -445,6 +446,7 @@ static void
 application_activate( GApplication *application )
 {
        static const gchar *thisfn = "fma_application_activate";
+       FMAApplicationPrivate *priv;
        GList *windows_list;
        FMAMainWindow *main_window;
 
@@ -452,6 +454,7 @@ application_activate( GApplication *application )
 
        g_return_if_fail( application && FMA_IS_APPLICATION( application ));
 
+       priv = FMA_APPLICATION( application )->private;
        windows_list = gtk_application_get_windows( GTK_APPLICATION( application ));
 
        /* if the application is unique, have only one main window */
@@ -469,6 +472,9 @@ application_activate( GApplication *application )
        }
 
        g_return_if_fail( main_window && FMA_IS_MAIN_WINDOW( main_window ));
+
+       priv->main_window = main_window;
+
        gtk_window_present( GTK_WINDOW( main_window ));
 }
 
@@ -549,3 +555,26 @@ fma_application_get_updater( const FMAApplication *application )
 
        return( updater );
 }
+
+/**
+ * fma_application_get_main_window:
+ * @application: this FMAApplication object.
+ *
+ * Returns: the main window.
+ */
+GtkWindow *
+fma_application_get_main_window( FMAApplication *application )
+{
+       FMAApplicationPrivate *priv;
+
+       g_return_val_if_fail( application && FMA_IS_APPLICATION( application ), NULL );
+
+       priv = application->private;
+
+       if( !priv->dispose_has_run ){
+
+               return( GTK_WINDOW( priv->main_window ));
+       }
+
+       return( NULL );
+}
diff --git a/src/ui/fma-application.h b/src/ui/fma-application.h
index 88e231a..ae176bc 100644
--- a/src/ui/fma-application.h
+++ b/src/ui/fma-application.h
@@ -105,6 +105,8 @@ gchar          *fma_application_get_application_name( const FMAApplication *appl
 
 FMAUpdater     *fma_application_get_updater         ( const FMAApplication *application );
 
+GtkWindow      *fma_application_get_main_window     ( FMAApplication *application );
+
 G_END_DECLS
 
 #endif /* __UI_FMA_APPLICATION_H__ */
diff --git a/src/ui/fma-main-window.c b/src/ui/fma-main-window.c
index ffeaa11..45370ad 100644
--- a/src/ui/fma-main-window.c
+++ b/src/ui/fma-main-window.c
@@ -710,7 +710,13 @@ setup_main_ui( FMAMainWindow *main_window )
        /* no error condition here:
         * If there is an error opening the file or parsing the description
         * then the program will be aborted. */
+#if GTK_CHECK_VERSION( 3, 10, 0 )
        builder = gtk_builder_new_from_file( st_xmlui_filename );
+#else
+       builder = gtk_builder_new();
+       guint ret = gtk_builder_add_from_file( builder, st_xmlui_filename, NULL );
+       g_return_if_fail( ret > 0 );
+#endif
        top_window = gtk_builder_get_object( builder, st_toplevel_name );
        g_return_if_fail( top_window && GTK_IS_WINDOW( top_window ));
 
diff --git a/src/ui/fma-menu-view.c b/src/ui/fma-menu-view.c
index 0a5ef3f..3064d02 100644
--- a/src/ui/fma-menu-view.c
+++ b/src/ui/fma-menu-view.c
@@ -132,7 +132,12 @@ setup_toolbars_submenu( FMAMainWindow *window )
 {
        GtkBuilder *builder;
 
+#if GTK_CHECK_VERSION( 3, 10, 0 )
        builder = gtk_builder_new_from_file( st_toolbar_ui );
+#else
+       builder = gtk_builder_new();
+       gtk_builder_add_from_file( builder, st_toolbar_ui, NULL );
+#endif
 
        setup_toolbar( window, builder, TOOLBAR_FILE_ID );
        setup_toolbar( window, builder, TOOLBAR_EDIT_ID );
diff --git a/src/ui/fma-menu.c b/src/ui/fma-menu.c
index 7831930..6edc2f4 100644
--- a/src/ui/fma-menu.c
+++ b/src/ui/fma-menu.c
@@ -259,7 +259,11 @@ on_app_about( GSimpleAction *action, GVariant *parameter, gpointer user_data )
 
        g_return_if_fail( user_data && FMA_IS_APPLICATION( user_data ));
 
+#if GTK_CHECK_VERSION( 3, 6, 0 )
        window = gtk_application_get_active_window( GTK_APPLICATION( user_data ));
+#else
+       window = fma_application_get_main_window( FMA_APPLICATION( user_data ));
+#endif
        g_return_if_fail( window && FMA_IS_MAIN_WINDOW( window ));
 
        fma_about_display( window );
@@ -288,7 +292,11 @@ on_app_preferences( GSimpleAction *action, GVariant *parameter, gpointer user_da
 
        g_return_if_fail( user_data && FMA_IS_APPLICATION( user_data ));
 
+#if GTK_CHECK_VERSION( 3, 6, 0 )
        window = gtk_application_get_active_window( GTK_APPLICATION( user_data ));
+#else
+       window = fma_application_get_main_window( FMA_APPLICATION( user_data ));
+#endif
        g_return_if_fail( window && FMA_IS_MAIN_WINDOW( window ));
 
        fma_preferences_editor_run( FMA_MAIN_WINDOW( window ));
@@ -301,7 +309,11 @@ on_app_quit( GSimpleAction *action, GVariant *parameter, gpointer user_data )
 
        g_return_if_fail( user_data && FMA_IS_APPLICATION( user_data ));
 
+#if GTK_CHECK_VERSION( 3, 6, 0 )
        window = gtk_application_get_active_window( GTK_APPLICATION( user_data ));
+#else
+       window = fma_application_get_main_window( FMA_APPLICATION( user_data ));
+#endif
        g_return_if_fail( window && FMA_IS_MAIN_WINDOW( window ));
 
        fma_main_window_quit( FMA_MAIN_WINDOW( window ));


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