From 289d1e90c51b0ab6c4568833cfd61cd572c6f3ac Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 26 Jan 2012 17:49:56 +0000 Subject: [PATCH] wacom: Implement switching to Display settings --- panels/wacom/cc-wacom-page.c | 17 ++++++++++++++++- panels/wacom/cc-wacom-page.h | 4 +++- panels/wacom/cc-wacom-panel.c | 15 +++++++++++---- panels/wacom/cc-wacom-panel.h | 3 +++ panels/wacom/test-wacom.c | 8 +++++++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c index 9c10c0c37..0afeb3aba 100644 --- a/panels/wacom/cc-wacom-page.c +++ b/panels/wacom/cc-wacom-page.c @@ -42,6 +42,7 @@ G_DEFINE_TYPE (CcWacomPage, cc_wacom_page, GTK_TYPE_BOX) struct _CcWacomPagePrivate { + CcWacomPanel *panel; GsdWacomDevice *stylus, *eraser; GtkBuilder *builder; GtkWidget *nav; @@ -261,6 +262,14 @@ combobox_text_cellrenderer (GtkComboBox *combo, int name_column) "text", BUTTONNAME_COLUMN, NULL); } +static gboolean +display_clicked_cb (GtkButton *button, + CcWacomPage *page) +{ + cc_wacom_panel_switch_to_panel (page->priv->panel, "display"); + return TRUE; +} + /* Boilerplate code goes below */ static void @@ -370,6 +379,9 @@ cc_wacom_page_init (CcWacomPage *self) g_signal_connect (G_OBJECT (sw), "notify::active", G_CALLBACK (left_handed_toggled_cb), self); + g_signal_connect (G_OBJECT (WID ("display-link")), "activate-link", + G_CALLBACK (display_clicked_cb), self); + priv->nav = cc_wacom_nav_button_new (); gtk_grid_attach (GTK_GRID (box), priv->nav, 0, 0, 1, 1); } @@ -431,7 +443,8 @@ add_styli (CcWacomPage *page) } GtkWidget * -cc_wacom_page_new (GsdWacomDevice *stylus, +cc_wacom_page_new (CcWacomPanel *panel, + GsdWacomDevice *stylus, GsdWacomDevice *eraser) { CcWacomPage *page; @@ -446,6 +459,7 @@ cc_wacom_page_new (GsdWacomDevice *stylus, page = g_object_new (CC_TYPE_WACOM_PAGE, NULL); priv = page->priv; + priv->panel = panel; priv->stylus = stylus; priv->eraser = eraser; @@ -469,6 +483,7 @@ cc_wacom_page_new (GsdWacomDevice *stylus, gtk_widget_show (WID ("button-calibrate")); gtk_widget_hide (WID ("combo-tabletmode")); gtk_widget_hide (WID ("label-trackingmode")); + gtk_widget_show (WID ("display-link")); } /* Tablet icon */ diff --git a/panels/wacom/cc-wacom-page.h b/panels/wacom/cc-wacom-page.h index b374b5260..8e05822cc 100644 --- a/panels/wacom/cc-wacom-page.h +++ b/panels/wacom/cc-wacom-page.h @@ -24,6 +24,7 @@ #define _CC_WACOM_PAGE_H #include +#include "cc-wacom-panel.h" #include "gsd-wacom-device.h" G_BEGIN_DECLS @@ -68,7 +69,8 @@ struct _CcWacomPageClass GType cc_wacom_page_get_type (void) G_GNUC_CONST; -GtkWidget * cc_wacom_page_new (GsdWacomDevice *stylus, +GtkWidget * cc_wacom_page_new (CcWacomPanel *panel, + GsdWacomDevice *stylus, GsdWacomDevice *eraser); void cc_wacom_page_set_navigation (CcWacomPage *page, diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c index 70c61fe88..4dfd390e6 100644 --- a/panels/wacom/cc-wacom-panel.c +++ b/panels/wacom/cc-wacom-panel.c @@ -214,7 +214,7 @@ update_current_page (CcWacomPanel *self) if (g_hash_table_lookup (priv->pages, tablet->name) == NULL) { GtkWidget *page; - page = cc_wacom_page_new (tablet->stylus, tablet->eraser); + page = cc_wacom_page_new (self, tablet->stylus, tablet->eraser); cc_wacom_page_set_navigation (CC_WACOM_PAGE (page), GTK_NOTEBOOK (priv->notebook), TRUE); gtk_widget_show (page); gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, NULL); @@ -277,17 +277,24 @@ device_added_cb (GdkDeviceManager *manager, static gboolean link_activated (GtkLinkButton *button, CcWacomPanel *self) +{ + cc_wacom_panel_switch_to_panel (self, "bluetooth"); + return TRUE; +} + +void +cc_wacom_panel_switch_to_panel (CcWacomPanel *self, + const char *panel) { CcShell *shell; GError *error = NULL; shell = cc_panel_get_shell (CC_PANEL (self)); - if (cc_shell_set_active_panel_from_id (shell, "bluetooth", NULL, &error) == FALSE) + if (cc_shell_set_active_panel_from_id (shell, panel, NULL, &error) == FALSE) { - g_warning ("Failed to activate Bluetooth panel: %s", error->message); + g_warning ("Failed to activate '%s' panel: %s", panel, error->message); g_error_free (error); } - return TRUE; } static void diff --git a/panels/wacom/cc-wacom-panel.h b/panels/wacom/cc-wacom-panel.h index 09e0cec6c..54b8faa26 100644 --- a/panels/wacom/cc-wacom-panel.h +++ b/panels/wacom/cc-wacom-panel.h @@ -69,6 +69,9 @@ GType cc_wacom_panel_get_type (void) G_GNUC_CONST; void cc_wacom_panel_register (GIOModule *module); +void cc_wacom_panel_switch_to_panel (CcWacomPanel *self, + const char *panel); + G_END_DECLS #endif /* _CC_WACOM_PANEL_H */ diff --git a/panels/wacom/test-wacom.c b/panels/wacom/test-wacom.c index 4fe284dbc..7dc7f9af6 100644 --- a/panels/wacom/test-wacom.c +++ b/panels/wacom/test-wacom.c @@ -8,6 +8,12 @@ #define FIXED_WIDTH 675 +void +cc_wacom_panel_switch_to_panel (CcWacomPanel *self, const char *panel) +{ + g_message ("Should launch display preferences here"); +} + static void add_page (GList *devices, GtkWidget *notebook) @@ -35,7 +41,7 @@ add_page (GList *devices, } g_list_free (devices); - widget = cc_wacom_page_new (stylus, eraser); + widget = cc_wacom_page_new (NULL, stylus, eraser); cc_wacom_page_set_navigation (CC_WACOM_PAGE (widget), GTK_NOTEBOOK (notebook), FALSE); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, NULL); gtk_widget_show (widget);