static void cc_search_panel_constructed (GObject *object) { CcSearchPanel *self = CC_SEARCH_PANEL (object); GtkWidget *box, *widget, *search_box; G_OBJECT_CLASS (cc_search_panel_parent_class)->constructed (object); /* add the disable all switch */ search_box = WID ("search_vbox"); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); widget = gtk_switch_new (); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 4); g_settings_bind (self->priv->search_settings, "disable-external", widget, "active", G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN); g_object_bind_property (widget, "active", search_box, "sensitive", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); gtk_widget_show_all (box); cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)), box); }
static void remove_account_cb (GoaAccount *account, GAsyncResult *res, gpointer user_data) { GoaPanel *panel = GOA_PANEL (user_data); GError *error; error = NULL; if (!goa_account_call_remove_finish (account, res, &error)) { GtkWidget *dialog; dialog = gtk_message_dialog_new (GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)))), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error removing account")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); g_error_free (error); } g_object_unref (panel); }
static void shell_test_button_clicked (GtkButton *button, CcMousePanel *panel) { CcMousePanelPrivate *priv = panel->priv; CcShell *shell; shell = cc_panel_get_shell (CC_PANEL (panel)); /* When running on a small screen, make the test dialog * the same height of the toplevel. */ if (cc_shell_is_small_screen (shell)) { gint height; gtk_window_get_size (GTK_WINDOW (cc_shell_get_toplevel (shell)), NULL, &height); gtk_widget_set_size_request (priv->test_dialog, -1, height); } else { gtk_widget_set_size_request (priv->test_widget, -1, TEST_WIDGET_DEFAULT_HEIGHT); } /* GTK_RESPONSE_NONE is returned if the dialog is being destroyed, so only * hide the dialog if it is not being destroyed */ if (gtk_dialog_run (GTK_DIALOG (priv->test_dialog)) != GTK_RESPONSE_NONE) gtk_widget_hide (priv->test_dialog); }
void cc_network_panel_connect_to_3g_network (CcNetworkPanel *panel, NMClient *client, NMRemoteSettings *settings, NMDevice *device) { GtkWidget *toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel))); if (toplevel == NULL) { toplevel = GTK_WIDGET (panel); } MobileDialogClosure *closure; NMAMobileWizard *wizard; NMDeviceModemCapabilities caps; gboolean visible = FALSE; g_debug ("connect to 3g"); if (!NM_IS_DEVICE_MODEM (device)) { g_warning ("Network panel loaded with connect-3g but the selected device" " is not a modem"); return; } closure = g_slice_new (MobileDialogClosure); closure->client = g_object_ref (client); closure->settings = g_object_ref (settings); closure->device = g_object_ref (device); caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) { wizard = nma_mobile_wizard_new (GTK_WINDOW (toplevel), NULL, NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS, FALSE, gsm_mobile_wizard_done, closure); if (wizard == NULL) { g_warning ("failed to construct GSM wizard"); return; } } else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) { wizard = nma_mobile_wizard_new (GTK_WINDOW (toplevel), NULL, NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO, FALSE, cdma_mobile_wizard_done, closure); if (wizard == NULL) { g_warning ("failed to construct CDMA wizard"); return; } } else { g_warning ("Network panel loaded with connect-3g but the selected device" " does not support GSM or CDMA"); mobile_dialog_closure_free (closure); return; } g_object_get (G_OBJECT (toplevel), "visible", &visible, NULL); if (visible) { g_debug ("Scheduling showing the Mobile wizard"); g_idle_add ((GSourceFunc) show_wizard_idle_cb, wizard); } else { g_debug ("Will show wizard a bit later, toplevel is not visible"); g_signal_connect (G_OBJECT (toplevel), "notify::visible", G_CALLBACK (toplevel_shown), wizard); } }
static void on_info_bar_response (GtkInfoBar *info_bar, gint response_id, gpointer user_data) { GoaPanel *panel = GOA_PANEL (user_data); GtkTreeIter iter; if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (panel->accounts_treeview)), NULL, &iter)) { GoaProvider *provider; const gchar *provider_type; GoaAccount *account; GoaObject *object; GtkWindow *parent; GError *error; gtk_tree_model_get (GTK_TREE_MODEL (panel->accounts_model), &iter, GOA_PANEL_ACCOUNTS_MODEL_COLUMN_OBJECT, &object, -1); account = goa_object_peek_account (object); provider_type = goa_account_get_provider_type (account); provider = goa_provider_get_for_provider_type (provider_type); parent = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)))); error = NULL; if (!goa_provider_refresh_account (provider, panel->client, object, parent, &error)) { if (!(error->domain == GOA_ERROR && error->code == GOA_ERROR_DIALOG_DISMISSED)) { GtkWidget *dialog; dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error logging into the account")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } g_error_free (error); } g_object_unref (provider); g_object_unref (object); } }
static void cc_sharing_panel_constructed (GObject *object) { CcSharingPanelPrivate *priv = CC_SHARING_PANEL (object)->priv; G_OBJECT_CLASS (cc_sharing_panel_parent_class)->constructed (object); /* add the master switch */ cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (object)), gtk_widget_get_parent (priv->master_switch)); }
/* 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; }
/* 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; }
static void cc_bluetooth_panel_constructed (GObject *object) { CcBluetoothPanel *self = CC_BLUETOOTH_PANEL (object); G_OBJECT_CLASS (cc_bluetooth_panel_parent_class)->constructed (object); /* add kill switch widgets */ self->priv->kill_switch_header = g_object_ref (WID ("box_power")); cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)), self->priv->kill_switch_header); gtk_widget_show_all (self->priv->kill_switch_header); }
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 void run_dialog (CcDateTimePanel *self, const gchar *dialog_name) { CcDateTimePanelPrivate *priv = self->priv; GtkWidget *dialog, *parent; dialog = W (dialog_name); parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self))); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); gtk_dialog_run (GTK_DIALOG (dialog)); }
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; }
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; }
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 on_toolbar_remove_button_clicked (GtkToolButton *button, gpointer user_data) { GoaPanel *panel = GOA_PANEL (user_data); GtkTreeIter iter; if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (panel->accounts_treeview)), NULL, &iter)) { GoaObject *object; GtkWidget *dialog; gint response; gtk_tree_model_get (GTK_TREE_MODEL (panel->accounts_model), &iter, GOA_PANEL_ACCOUNTS_MODEL_COLUMN_OBJECT, &object, -1); dialog = gtk_message_dialog_new (GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)))), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, _("Are you sure you want to remove the account?")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("This will not remove the account on the server.")); gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Remove"), GTK_RESPONSE_OK); gtk_widget_show_all (dialog); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_OK) { goa_account_call_remove (goa_object_peek_account (object), NULL, /* GCancellable */ (GAsyncReadyCallback) remove_account_cb, g_object_ref (panel)); } g_object_unref (object); } }
static void cc_mouse_panel_constructed (GObject *object) { CcMousePanel *self = CC_MOUSE_PANEL (object); CcMousePanelPrivate *priv = self->priv; GtkWidget *button, *container, *toplevel, *label; CcShell *shell; G_OBJECT_CLASS (cc_mouse_panel_parent_class)->constructed (object); /* Add test area button to shell header. */ shell = cc_panel_get_shell (CC_PANEL (self)); label = gtk_label_new_with_mnemonic (_("Test Your _Settings")); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_widget_show (label); button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), label); gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button"); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_widget_set_visible (button, TRUE); cc_shell_embed_widget_in_header (shell, button); g_signal_connect (GTK_BUTTON (button), "clicked", G_CALLBACK (shell_test_button_clicked), self); toplevel = cc_shell_get_toplevel (shell); priv->test_dialog = g_object_new (GTK_TYPE_DIALOG, "title", _("Test Your Settings"), "transient-for", GTK_WINDOW (toplevel), "modal", TRUE, "use_header-bar", TRUE, "resizable", FALSE, NULL); container = gtk_dialog_get_content_area (GTK_DIALOG (priv->test_dialog)); gtk_container_add (GTK_CONTAINER (container), priv->test_widget); }
static void cc_sharing_panel_run_dialog (CcSharingPanel *self, const gchar *dialog_name) { CcSharingPanelPrivate *priv = self->priv; GtkWidget *dialog, *parent; dialog = WID (dialog_name); /* ensure labels with the hostname are updated if the hostname has changed */ cc_sharing_panel_setup_label_with_hostname (self, WID ("screen-sharing-label")); cc_sharing_panel_setup_label_with_hostname (self, WID ("remote-login-label")); cc_sharing_panel_setup_label_with_hostname (self, WID ("personal-file-sharing-label")); parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self))); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); gtk_dialog_run (GTK_DIALOG (dialog)); }
/* Add test area toggle to shell header. */ static gboolean add_shell_test_button_cb (gpointer user_data) { CcMousePanel *panel = CC_MOUSE_PANEL (user_data); GtkWidget *box, *button; box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); button = gtk_toggle_button_new_with_mnemonic (_("_Test Your Settings")); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); gtk_widget_set_visible (button, TRUE); cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (panel)), box); gtk_widget_set_visible (box, TRUE); panel->priv->shell_header = g_object_ref (box); g_signal_connect (GTK_BUTTON (button), "toggled", G_CALLBACK (shell_test_button_toggle_event), panel); return FALSE; }
static void add_account (GoaPanel *panel) { GtkWindow *parent; GtkWidget *dialog; gint response; GList *providers; GList *l; GoaObject *object; GError *error; providers = NULL; parent = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)))); dialog = goa_panel_add_account_dialog_new (panel->client); gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); providers = goa_provider_get_all (); for (l = providers; l != NULL; l = l->next) { GoaProvider *provider; provider = GOA_PROVIDER (l->data); goa_panel_add_account_dialog_add_provider (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), provider); } gtk_widget_show_all (dialog); response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response != GTK_RESPONSE_OK) { gtk_widget_destroy (dialog); goto out; } error = NULL; object = goa_panel_add_account_dialog_get_account (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), &error); gtk_widget_destroy (dialog); /* We might have an object even when error is set. * eg., if we failed to store the credentials in the keyring. */ if (object != NULL) { GtkTreeIter iter; /* navigate to newly created object */ if (goa_panel_accounts_model_get_iter_for_object (panel->accounts_model, object, &iter)) { gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (panel->accounts_treeview)), &iter); } g_object_unref (object); } if (error != NULL) { if (!(error->domain == GOA_ERROR && error->code == GOA_ERROR_DIALOG_DISMISSED)) { dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error creating account")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } g_error_free (error); } out: g_list_foreach (providers, (GFunc) g_object_unref, NULL); g_list_free (providers); }