From 80d37475904c9e58b8a291bcd6d49867dbf23506 Mon Sep 17 00:00:00 2001 From: lukefromdc Date: Sat, 1 Oct 2016 02:40:11 -0400 Subject: GTK3: port libunique->GtkApplication All GTK3 builds for now, this can go 3-way to permit gtk3/libunique builds if there is any reason for a distro to have issues with using GtkApplication, or for a point/buildfix release --- shell/control-center.c | 73 +++++++++++++++++++++++++++++++++++++++------- shell/matecc.desktop.in.in | 2 +- 2 files changed, 64 insertions(+), 11 deletions(-) (limited to 'shell') diff --git a/shell/control-center.c b/shell/control-center.c index 2f1454b2..d0f8f8cb 100644 --- a/shell/control-center.c +++ b/shell/control-center.c @@ -23,8 +23,9 @@ #include #include #include +#if !GTK_CHECK_VERSION(3,0,0) #include - +#endif #include void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data); @@ -93,7 +94,9 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data) AppShellData* app_data = (AppShellData*) data; MateDesktopItem* item = (MateDesktopItem*) g_object_get_data(G_OBJECT(tile), APP_ACTION_KEY); GSettings *settings; - +#if GTK_CHECK_VERSION(3,0,0) + GApplication *app; +#endif if (event->type == TILE_EVENT_ACTIVATED_DOUBLE_CLICK) { return; @@ -107,7 +110,12 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data) { if (app_data->exit_on_close) { +#if GTK_CHECK_VERSION(3,0,0) + app=g_application_get_default(); + g_application_quit(app); +#else gtk_main_quit(); +#endif } else { @@ -118,6 +126,40 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data) g_object_unref(settings); } +#if GTK_CHECK_VERSION(3,0,0) +static void +activate (GtkApplication *app) +{ + GList *list; + GSList* actions; + gboolean hidden = FALSE; + + list = gtk_application_get_windows (app); + + AppShellData* app_data = appshelldata_new("matecc.menu", GTK_ICON_SIZE_DND, FALSE, TRUE, 0); + + generate_categories(app_data); + + actions = get_actions_list(); + layout_shell(app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions, handle_static_action_clicked); + + if (list) + { + gtk_window_present (GTK_WINDOW (list->data)); + } + else + { + create_main_window(app_data, "MyControlCenter", _("Control Center"), "preferences-desktop", 975, 600, hidden); + gtk_application_add_window (app, GTK_WINDOW(app_data->main_app)); + } +} + +static void +quit (GApplication *app) +{ + g_application_quit(app); +} +#else static UniqueResponse message_received_cb(UniqueApp* app, UniqueCommand command, UniqueMessageData* message, guint time, gpointer user_data) { UniqueResponse res; @@ -148,24 +190,30 @@ static UniqueResponse message_received_cb(UniqueApp* app, UniqueCommand command, return res; } - +#endif int main(int argc, char* argv[]) { gboolean hidden = FALSE; +#if GTK_CHECK_VERSION(3,0,0) + GtkApplication *app; + gint retval; + app = gtk_application_new ("org.mate.mate-control-center.shell", 0); +#else UniqueApp* unique_app; AppShellData* app_data; GSList* actions; +#endif GError* error; GOptionEntry options[] = { {"hide", 0, 0, G_OPTION_ARG_NONE, &hidden, N_("Hide on start (useful to preload the shell)"), NULL}, {NULL} }; - #ifdef ENABLE_NLS - bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); - #endif +#ifdef ENABLE_NLS + bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); +#endif error = NULL; @@ -175,7 +223,12 @@ int main(int argc, char* argv[]) g_error_free(error); return 1; } - +#if GTK_CHECK_VERSION(3,0,0) + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + g_signal_connect (app, "window-removed", G_CALLBACK (quit), NULL); + retval = g_application_run (G_APPLICATION (app), argc, argv); + return retval; +#else unique_app = unique_app_new("org.mate.mate-control-center.shell", NULL); if (unique_app_is_running(unique_app)) @@ -205,8 +258,8 @@ int main(int argc, char* argv[]) g_signal_connect(unique_app, "message-received", G_CALLBACK(message_received_cb), app_data); gtk_main(); - g_object_unref(unique_app); return 0; +#endif } diff --git a/shell/matecc.desktop.in.in b/shell/matecc.desktop.in.in index 50480c63..ca3298e9 100644 --- a/shell/matecc.desktop.in.in +++ b/shell/matecc.desktop.in.in @@ -5,7 +5,7 @@ Icon=preferences-desktop Exec=mate-control-center Terminal=false Type=Application -StartupNotify=true +StartupNotify=false Categories=GTK;Settings; Keywords=MATE;control;center;configuration;tool;destop;preferences; OnlyShowIn=MATE; -- cgit v1.2.1