diff options
Diffstat (limited to 'src/file-share-properties.c')
-rw-r--r-- | src/file-share-properties.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/file-share-properties.c b/src/file-share-properties.c index 27669f6..b42a1bc 100644 --- a/src/file-share-properties.c +++ b/src/file-share-properties.c @@ -29,7 +29,9 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <gio/gio.h> +#if !GTK_CHECK_VERSION (3, 0, 0) #include <unique/uniqueapp.h> +#endif #include "user_share-private.h" @@ -451,6 +453,10 @@ help_button_clicked (GtkButton *button, GtkWidget *window) } } +#if GTK_CHECK_VERSION (3, 0, 0) +static GtkWidget * +create_window (void) +#else static UniqueResponse message_received_cb (UniqueApp *app, int command, @@ -465,6 +471,7 @@ message_received_cb (UniqueApp *app, int main (int argc, char *argv[]) +#endif { GError *error = NULL; GSettings *settings; @@ -483,6 +490,7 @@ main (int argc, char *argv[]) GtkListStore *store; GtkCellRenderer *cell; GtkTreeIter iter; +#if !GTK_CHECK_VERSION (3, 0, 0) UniqueApp *app; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); @@ -497,6 +505,7 @@ main (int argc, char *argv[]) unique_app_send_message (app, UNIQUE_ACTIVATE, NULL); return 0; } +#endif builder = gtk_builder_new (); gtk_builder_add_from_file (builder, DATADIR"file-share-properties.ui", &error); @@ -509,14 +518,20 @@ main (int argc, char *argv[]) gtk_widget_destroy (dialog); g_error_free (error); +#if GTK_CHECK_VERSION (3, 0, 0) + return NULL; +#else return 1; +#endif } window = GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog")); +#if !GTK_CHECK_VERSION (3, 0, 0) g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (app, "message-received", G_CALLBACK (message_received_cb), window); +#endif settings = g_settings_new (GSETTINGS_SCHEMA); @@ -606,8 +621,13 @@ main (int argc, char *argv[]) "toggled", G_CALLBACK (notify_received_obexpush_check_toggled), NULL); #endif /* HAVE_BLUETOOTH */ +#if GTK_CHECK_VERSION (3, 0, 0) + g_signal_connect_swapped (GTK_WIDGET (gtk_builder_get_object (builder, "close_button")), + "clicked", G_CALLBACK (gtk_widget_destroy), window); +#else g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "close_button")), "clicked", G_CALLBACK (gtk_main_quit), NULL); +#endif g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "help_button")), "clicked", G_CALLBACK (help_button_clicked), gtk_builder_get_object (builder, "user_share_dialog")); @@ -641,9 +661,51 @@ main (int argc, char *argv[]) update_ui (); +#if GTK_CHECK_VERSION (3, 0, 0) + return window; +} + +static void +activate (GtkApplication *app) +{ + GList *list; + GtkWidget *window; + + list = gtk_application_get_windows (app); + + if (list) { + gtk_window_present (GTK_WINDOW (list->data)); + } else { + window = create_window (); + gtk_window_set_application (GTK_WINDOW (window), app); + gtk_widget_show (window); + } +} + +int +main (int argc, char *argv[]) +{ + GtkApplication *app; + gint status; + + bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + app = gtk_application_new ("org.mate.user-share.properties", + G_APPLICATION_FLAGS_NONE); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + + status = g_application_run (G_APPLICATION (app), argc, argv); + + g_object_unref (app); + + return status; +#else gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog"))); gtk_main (); return 0; +#endif } |