mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-05 19:15:32 +00:00
application: Propagate verbosity to main instance
If another instance of calls was already running, invoking calls with `-v` flag would set the verbosity for the newly created process and then exit if it was not the primary instance.
This commit is contained in:
parent
a5eb750350
commit
f7e632dcb4
3 changed files with 36 additions and 0 deletions
|
@ -398,12 +398,21 @@ static int
|
|||
calls_application_handle_local_options (GApplication *application,
|
||||
GVariantDict *options)
|
||||
{
|
||||
guint verbosity = calls_log_get_verbosity ();
|
||||
|
||||
if (g_variant_dict_contains (options, "version")) {
|
||||
g_print ("%s %s\n", APP_DATA_NAME, *VCS_TAG ? VCS_TAG : PACKAGE_VERSION);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Propagate verbosity changes to the main instance */
|
||||
if (verbosity > 0) {
|
||||
g_variant_dict_insert_value (options, "verbosity", g_variant_new_uint32 (verbosity));
|
||||
g_print ("Increasing verbosity to %u\n", verbosity);
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -466,6 +475,7 @@ calls_application_command_line (GApplication *application,
|
|||
g_autoptr (GVariant) providers = NULL;
|
||||
g_auto (GStrv) arguments = NULL;
|
||||
gint argc;
|
||||
guint verbosity;
|
||||
|
||||
options = g_application_command_line_get_options_dict (command_line);
|
||||
|
||||
|
@ -488,6 +498,17 @@ calls_application_command_line (GApplication *application,
|
|||
g_action_group_activate_action (G_ACTION_GROUP (application),
|
||||
"dial", g_variant_new_string (arg));
|
||||
|
||||
/* TODO make this a comma separated string of "CATEGORY:level" pairs */
|
||||
if (g_variant_dict_lookup (options, "verbosity", "u", &verbosity)) {
|
||||
gint delta = calls_log_set_verbosity (verbosity);
|
||||
guint level = calls_log_get_verbosity ();
|
||||
if (delta != 0)
|
||||
g_print ("%s verbosity by %d to %u\n",
|
||||
delta > 0 ? "Increased" : "Decreased",
|
||||
delta,
|
||||
level);
|
||||
}
|
||||
|
||||
arguments = g_application_command_line_get_arguments (command_line, &argc);
|
||||
|
||||
/* Keep only the first URI, if there are many */
|
||||
|
|
|
@ -278,3 +278,17 @@ calls_log_get_verbosity (void)
|
|||
{
|
||||
return verbosity;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
calls_log_set_verbosity (guint new_verbosity)
|
||||
{
|
||||
int diff = verbosity - new_verbosity;
|
||||
|
||||
if (new_verbosity == verbosity)
|
||||
return 0;
|
||||
|
||||
verbosity = new_verbosity;
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
|
|
@ -39,3 +39,4 @@
|
|||
void calls_log_init (void);
|
||||
void calls_log_increase_verbosity (void);
|
||||
guint calls_log_get_verbosity (void);
|
||||
int calls_log_set_verbosity (guint new_verbosity);
|
||||
|
|
Loading…
Reference in a new issue