Exemplo n.º 1
0
static gboolean
hearing_sound_preferences_clicked (GtkButton  *button,
                                   CcUaPanel  *panel)
{
  CcShell *shell;

  shell = cc_panel_get_shell (CC_PANEL (panel));
  if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)
    cc_shell_set_active_panel_from_id (shell, "sound-nua", NULL, NULL);
  else
    cc_shell_set_active_panel_from_id (shell, "sound", NULL, NULL);

  return TRUE;
}
Exemplo n.º 2
0
/* mouse/pointing & clicking section */
static gboolean
pointing_mouse_preferences_clicked_cb (GtkButton  *button,
                                       CcUaPanel  *panel)
{
  CcShell *shell;

  shell = cc_panel_get_shell (CC_PANEL (panel));
  cc_shell_set_active_panel_from_id (shell, "mouse", NULL, NULL);

  return TRUE;
}
Exemplo n.º 3
0
/* typing/keyboard section */
static gboolean
typing_keyboard_preferences_clicked (GtkButton  *button,
                                     CcUaPanel  *panel)
{
  CcShell *shell;

  shell = cc_panel_get_shell (CC_PANEL (panel));
  cc_shell_set_active_panel_from_id (shell, "keyboard", NULL, NULL);

  return TRUE;
}
static void
panel_changed (GtkWidget        *settings_widget,
	       const char       *panel,
	       CcBluetoothPanel *self)
{
	CcShell *shell;
	GError *error = NULL;

	shell = cc_panel_get_shell (CC_PANEL (self));
	if (cc_shell_set_active_panel_from_id (shell, panel, NULL, &error) == FALSE) {
		g_warning ("Failed to activate '%s' panel: %s", panel, error->message);
		g_error_free (error);
	}
}
static gboolean
layout_link_clicked (GtkLinkButton *button,
                     CcPanel       *panel)
{
  CcShell *shell;
  GError *error = NULL;

  shell = cc_panel_get_shell (panel);
  if (cc_shell_set_active_panel_from_id (shell, "region", NULL, &error) == FALSE)
    {
      g_warning ("Failed to activate Region panel: %s", error->message);
      g_error_free (error);
    }
  return TRUE;
}
Exemplo n.º 6
0
void
cc_wacom_panel_switch_to_panel (CcWacomPanel *self,
				const char   *panel)
{
	CcShell *shell;
	GError *error = NULL;

	g_return_if_fail (self);

	shell = cc_panel_get_shell (CC_PANEL (self));
	if (cc_shell_set_active_panel_from_id (shell, panel, NULL, &error) == FALSE)
	{
		g_warning ("Failed to activate '%s' panel: %s", panel, error->message);
		g_error_free (error);
	}
}
static void
item_activated_cb (CcShellCategoryView *view,
                   gchar               *name,
                   gchar               *id,
                   gchar               *desktop_file,
                   GnomeControlCenter  *shell)
{
  GError *err = NULL;

  if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, NULL, &err))
    {
      /* TODO: show message to user */
      if (err)
        {
          g_warning ("Could not active panel \"%s\": %s", id, err->message);
          g_error_free (err);
        }
    }
}
static void
launch_panel_activated (GSimpleAction *action,
                        GVariant      *parameter,
                        gpointer       user_data)
{
  CcApplication *self = CC_APPLICATION (user_data);
  GError *error = NULL;
  gchar *panel_id;
  GVariant *parameters;

  g_variant_get (parameter, "(&s@av)", &panel_id, &parameters);
  g_debug ("gnome-control-center: 'launch-panel' activated for panel '%s' with %"G_GSIZE_FORMAT" arguments",
      panel_id, g_variant_n_children (parameters));
  if (!cc_shell_set_active_panel_from_id (CC_SHELL (self->priv->window), panel_id, parameters, &error))
    {
      g_warning ("Failed to activate the '%s' panel: %s", panel_id, error->message);
      g_error_free (error);
    }
  g_variant_unref (parameters);
}
static void
on_search_selection_changed (GtkTreeSelection   *selection,
                             GnomeControlCenter *shell)
{
  GtkTreeModel *model;
  GtkTreeIter   iter;
  char         *id = NULL;

  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
    return;

  gtk_tree_model_get (model, &iter,
                      COL_ID, &id,
                      -1);

  if (id)
    cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, NULL, NULL);

  gtk_tree_selection_unselect_all (selection);

  g_free (id);
}
static int
cc_application_command_line (GApplication *application,
                             GApplicationCommandLine *command_line)
{
  CcApplication *self = CC_APPLICATION (application);
  int argc;
  char **argv;
  int retval = 0;
  GOptionContext *context;
  GError *error = NULL;
  GVariantBuilder *flags_builder;

  verbose = FALSE;
  show_overview = FALSE;
  show_help = FALSE;
  start_panels = NULL;

  flags_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);

  argv = g_application_command_line_get_arguments (command_line, &argc);

  context = g_option_context_new (N_("- Settings"));
  g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE);
  g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  cc_panel_loader_add_option_groups (context, flags_builder);
  g_option_context_set_help_enabled (context, FALSE);

  if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
    {
      g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
               error->message, argv[0]);
      g_error_free (error);
      g_option_context_free (context);
      return 1;
    }

  if (show_help || show_help_all || show_help_gtk)
    {
      gchar *help;
      GOptionGroup *group;

      if (show_help || show_help_all)
        group = NULL;
      else
        group = gtk_get_option_group (FALSE);

      help = g_option_context_get_help (context, FALSE, group);
      g_print ("%s", help);
      g_free (help);
      g_option_context_free (context);
      return 0;
    }

  if (list_panels)
    {
      GList *panels, *l;

      panels = cc_panel_loader_get_panels ();

      g_print ("%s\n", _("Available panels:"));
      for (l = panels; l != NULL; l = l->next)
        g_print ("\t%s\n", (char *) l->data);

      g_list_free (panels);

      return 0;
    }

#ifdef HAVE_CHEESE
  cheese_gtk_init (&argc, &argv);
#endif /* HAVE_CHEESE */

  cc_shell_log_set_debug (verbose);

  cc_window_show (self->priv->window);

  if (search_str)
    {
      cc_window_set_search_item (self->priv->window, search_str);
    }
  else if (show_overview)
    {
      cc_window_set_overview_page (self->priv->window);
    }
  else if (start_panels != NULL && start_panels[0] != NULL)
    {
      const char *start_id;
      GError *err = NULL;
      GVariant *parameters;
      GVariantBuilder *builder;
      int i;

      start_id = start_panels[0];

      if (start_panels[1])
        g_debug ("Extra argument: %s", start_panels[1]);
      else
        g_debug ("No extra argument");

      builder = g_variant_builder_new (G_VARIANT_TYPE ("av"));
      g_variant_builder_add (builder, "v", g_variant_builder_end (flags_builder));

      for (i = 1; start_panels[i] != NULL; i++)
        g_variant_builder_add (builder, "v", g_variant_new_string (start_panels[i]));
      parameters = g_variant_builder_end (builder);
      if (!cc_shell_set_active_panel_from_id (CC_SHELL (self->priv->window), start_id, parameters, &err))
        {
          g_warning ("Could not load setting panel \"%s\": %s", start_id,
                     (err) ? err->message : "Unknown error");
          retval = 1;
          if (err)
            {
              g_error_free (err);
              err = NULL;
            }
        }
    }

  if (start_panels != NULL)
    {
      g_strfreev (start_panels);
      start_panels = NULL;
    }

  show_overview = FALSE;

  g_option_context_free (context);
  g_strfreev (argv);

  return retval;
}
Exemplo n.º 11
0
static int
application_command_line_cb (GApplication  *application,
                             GApplicationCommandLine  *command_line,
                             GnomeControlCenter      *shell)
{
  int argc;
  char **argv;
  int retval = 0;
  GOptionContext *context;
  GError *error = NULL;

  verbose = FALSE;
  show_overview = FALSE;
  show_help = FALSE;
  start_panels = NULL;

  argv = g_application_command_line_get_arguments (command_line, &argc);

  context = g_option_context_new (N_("- System Settings"));
  g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE);
  g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  g_option_context_set_help_enabled (context, FALSE);

  if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
    {
      g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
               error->message, argv[0]);
      g_error_free (error);
      g_option_context_free (context);
      return 1;
    }

  if (show_help || show_help_all || show_help_gtk)
    {
      gchar *help;
      GOptionGroup *group;

      if (show_help || show_help_all)
        group = NULL;
      else
        group = gtk_get_option_group (FALSE);

      help = g_option_context_get_help (context, FALSE, group);
      g_print ("%s", help);
      g_free (help);
      g_option_context_free (context);
      return 0;
    }

  g_option_context_free (context);

  cc_shell_log_set_debug (verbose);

  gnome_control_center_show (shell, GTK_APPLICATION (application));

  if (show_overview)
    {
      gnome_control_center_set_overview_page (shell);
    }
  else if (start_panels != NULL && start_panels[0] != NULL)
    {
      const char *start_id;
      GError *err = NULL;

      start_id = start_panels[0];

      if (start_panels[1])
	g_debug ("Extra argument: %s", start_panels[1]);
      else
	g_debug ("No extra argument");

      if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, (const gchar**)start_panels+1, &err))
        {
          g_warning ("Could not load setting panel \"%s\": %s", start_id,
                     (err) ? err->message : "Unknown error");
          retval = 1;
          if (err)
            {
              g_error_free (err);
              err = NULL;
            }
        }
    }

  gnome_control_center_present (shell);
  gdk_notify_startup_complete ();

  g_strfreev (argv);
  if (start_panels != NULL)
    {
      g_strfreev (start_panels);
      start_panels = NULL;
    }
  show_overview = FALSE;

  return retval;
}