diff options
author | Mike Ruprecht <cmaiku@gmail.com> | 2018-10-02 18:38:22 -0500 |
---|---|---|
committer | Mike Ruprecht <cmaiku@gmail.com> | 2018-10-02 18:38:22 -0500 |
commit | 2205fd081d31cc91079973c1a7e0f27f30ec97ad (patch) | |
tree | 71a700b921fcc6f7622285e57901330490414491 | |
parent | f7cbf9b575a95177bde8e8ca0f0966f62cea1d7d (diff) | |
download | pidgin-2205fd081d31cc91079973c1a7e0f27f30ec97ad.tar.gz |
libpidgin: Use G_APPLICATION_CAN_OVERRIDE_APP_ID to allow multiple instances
This patch adds the G_APPLICATION_CAN_OVERRIDE_APP_ID flag to Pidgin's
GApplication instance. This allows for multiple instances of Pidgin,
using GApplication's unique instance checking, to be run simultaneously
by using an alternate, unique application ID.
Because we currently depend on GLib 2.40 and this flag is since 2.48,
this patch also adds compatibility for compiling with earlier versions
of GLib.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pidgin/libpidgin.c | 27 |
2 files changed, 31 insertions, 1 deletions
@@ -36,6 +36,11 @@ version 3.0.0 (??/??/????): joining a room. (Kha) (#15458) * Fix gevolution plugin to compile with e-d-s >= 3.6, older versions are not supported anymore. (Ed Catmur) (#15353) + * Removed command line argument --multiple in *nix in favor of using + GApplication's uniqueness checking directly. The new way to allow + multiple Pidgin instances is to pass --gapplication-app-id with an + alternate, valid app id. Be careful not to use the same configuration + directory as the primary instance. Finch: * Support the conversation-extended signal for extending the diff --git a/pidgin/libpidgin.c b/pidgin/libpidgin.c index 0167366c72..ea867f64ee 100644 --- a/pidgin/libpidgin.c +++ b/pidgin/libpidgin.c @@ -341,12 +341,25 @@ static gint pidgin_handle_local_options_cb(GApplication *app, GVariantDict *options, gpointer user_data) { +#if !GLIB_CHECK_VERSION(2, 48, 0) + gchar *app_id = NULL; +#endif + if (g_variant_dict_contains(options, "version")) { printf("%s %s (libpurple %s)\n", PIDGIN_NAME, DISPLAY_VERSION, purple_core_get_version()); return 0; } +#if !GLIB_CHECK_VERSION(2, 48, 0) + if (g_variant_dict_lookup(options, "gapplication-app-id", + "s", &app_id)) { + g_variant_dict_remove(options, "gapplication-app-id"); + g_application_set_application_id(app, app_id); + g_free(app_id); + } +#endif + return -1; } @@ -374,6 +387,13 @@ login_opt_arg_func(const gchar *option_name, const gchar *value, } static GOptionEntry option_entries[] = { +#if !GLIB_CHECK_VERSION(2, 48, 0) + /* Support G_APPLICATION_CAN_OVERRIDE_APP_ID functionality + * even though we don't depend on version 2.48 yet + */ + {"gapplication-app-id", '\0', 0, G_OPTION_ARG_STRING, NULL, + N_("Override the application's ID") }, +#endif {"config", 'c', 0, G_OPTION_ARG_FILENAME, &opt_config_dir_arg, N_("use DIR for config files"), N_("DIR")}, @@ -682,7 +702,12 @@ int pidgin_start(int argc, char *argv[]) #endif app = G_APPLICATION(gtk_application_new("im.pidgin.Pidgin", - G_APPLICATION_FLAGS_NONE)); +#if GLIB_CHECK_VERSION(2, 48, 0) + G_APPLICATION_CAN_OVERRIDE_APP_ID +#else + G_APPLICATION_FLAGS_NONE +#endif + )); summary = g_strdup_printf("%s %s", PIDGIN_NAME, DISPLAY_VERSION); g_application_set_option_context_summary(app, summary); |