wacom: Implement switching to Display settings

This commit is contained in:
Bastien Nocera 2012-01-26 17:49:56 +00:00
parent e3565989e0
commit 289d1e90c5
5 changed files with 40 additions and 7 deletions

View file

@ -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 */

View file

@ -24,6 +24,7 @@
#define _CC_WACOM_PAGE_H
#include <gtk/gtk.h>
#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,

View file

@ -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

View file

@ -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 */

View file

@ -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);