2010-05-20 17:50:56 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Intel, Inc
|
2012-08-20 19:49:07 +02:00
|
|
|
* Copyright (C) 2012 Red Hat, Inc.
|
2010-05-20 17:50:56 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2010-10-20 15:59:16 +02:00
|
|
|
* Authors: Thomas Wood <thomas.wood@intel.com>
|
|
|
|
* Rodrigo Moya <rodrigo@gnome.org>
|
2012-08-20 19:49:07 +02:00
|
|
|
* Ondrej Holy <oholy@redhat.com>
|
2010-05-20 17:50:56 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cc-mouse-panel.h"
|
2013-01-04 15:23:01 +01:00
|
|
|
#include "cc-mouse-resources.h"
|
|
|
|
|
2010-10-20 15:59:16 +02:00
|
|
|
#include "gnome-mouse-properties.h"
|
2012-08-20 19:49:07 +02:00
|
|
|
#include "gnome-mouse-test.h"
|
2010-05-20 17:50:56 +01:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2012-08-20 19:49:07 +02:00
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
2012-08-21 14:29:22 -04:00
|
|
|
CC_PANEL_REGISTER (CcMousePanel, cc_mouse_panel)
|
2010-05-20 17:50:56 +01:00
|
|
|
|
|
|
|
#define MOUSE_PANEL_PRIVATE(o) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_MOUSE_PANEL, CcMousePanelPrivate))
|
|
|
|
|
|
|
|
struct _CcMousePanelPrivate
|
|
|
|
{
|
|
|
|
GtkBuilder *builder;
|
2013-06-25 12:00:19 +01:00
|
|
|
GtkWidget *test_dialog;
|
2012-08-20 19:49:07 +02:00
|
|
|
GtkWidget *prefs_widget;
|
|
|
|
GtkWidget *test_widget;
|
|
|
|
GtkWidget *shell_header;
|
2010-05-20 17:50:56 +01:00
|
|
|
};
|
|
|
|
|
2012-08-20 19:49:07 +02:00
|
|
|
enum {
|
|
|
|
CC_MOUSE_PAGE_PREFS,
|
|
|
|
CC_MOUSE_PAGE_TEST
|
|
|
|
};
|
2010-05-20 17:50:56 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
cc_mouse_panel_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
CcMousePanelPrivate *priv = CC_MOUSE_PANEL (object)->priv;
|
|
|
|
|
2012-08-20 19:49:07 +02:00
|
|
|
g_clear_object (&priv->shell_header);
|
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
if (priv->test_dialog)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (priv->test_dialog);
|
|
|
|
priv->test_dialog = NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-20 17:50:56 +01:00
|
|
|
G_OBJECT_CLASS (cc_mouse_panel_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2012-05-18 17:04:32 +02:00
|
|
|
static const char *
|
|
|
|
cc_mouse_panel_get_help_uri (CcPanel *panel)
|
|
|
|
{
|
|
|
|
return "help:gnome-help/mouse";
|
|
|
|
}
|
|
|
|
|
2012-08-20 19:49:07 +02:00
|
|
|
static void
|
2013-06-25 12:00:19 +01:00
|
|
|
shell_test_button_clicked (GtkButton *button, CcMousePanel *panel)
|
2012-08-20 19:49:07 +02:00
|
|
|
{
|
2013-06-25 12:00:19 +01:00
|
|
|
CcMousePanelPrivate *priv = panel->priv;
|
2012-08-20 19:49:07 +02:00
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
/* 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);
|
2012-08-20 19:49:07 +02:00
|
|
|
}
|
|
|
|
|
2012-11-07 12:29:46 -05:00
|
|
|
static void
|
|
|
|
cc_mouse_panel_constructed (GObject *object)
|
2012-08-20 19:49:07 +02:00
|
|
|
{
|
2012-11-07 12:29:46 -05:00
|
|
|
CcMousePanel *self = CC_MOUSE_PANEL (object);
|
2013-06-25 12:00:19 +01:00
|
|
|
CcMousePanelPrivate *priv = self->priv;
|
|
|
|
GtkWidget *box, *button, *container, *toplevel;
|
|
|
|
CcShell *shell;
|
2012-08-20 19:49:07 +02:00
|
|
|
|
2012-11-07 12:29:46 -05:00
|
|
|
G_OBJECT_CLASS (cc_mouse_panel_parent_class)->constructed (object);
|
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
/* Add test area button to shell header. */
|
|
|
|
shell = cc_panel_get_shell (CC_PANEL (self));
|
2012-08-20 19:49:07 +02:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
button = gtk_button_new_with_mnemonic (_("Test Your _Settings"));
|
2012-08-20 19:49:07 +02:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_set_visible (button, TRUE);
|
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
cc_shell_embed_widget_in_header (shell, box);
|
2012-08-20 19:49:07 +02:00
|
|
|
gtk_widget_set_visible (box, TRUE);
|
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
priv->shell_header = g_object_ref (box);
|
2012-08-20 19:49:07 +02:00
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
g_signal_connect (GTK_BUTTON (button), "clicked",
|
|
|
|
G_CALLBACK (shell_test_button_clicked),
|
2012-11-07 12:29:46 -05:00
|
|
|
self);
|
2013-06-25 12:00:19 +01:00
|
|
|
|
|
|
|
toplevel = cc_shell_get_toplevel (shell);
|
|
|
|
priv->test_dialog = gtk_dialog_new_with_buttons (_("Test Your Settings"),
|
|
|
|
GTK_WINDOW (toplevel),
|
|
|
|
GTK_DIALOG_MODAL,
|
|
|
|
_("_Done"), GTK_RESPONSE_ACCEPT, NULL);
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (priv->test_dialog), FALSE);
|
|
|
|
|
|
|
|
container = gtk_dialog_get_content_area (GTK_DIALOG (priv->test_dialog));
|
|
|
|
gtk_container_add (GTK_CONTAINER (container), priv->test_widget);
|
2012-08-20 19:49:07 +02:00
|
|
|
}
|
|
|
|
|
2010-05-20 17:50:56 +01:00
|
|
|
static void
|
|
|
|
cc_mouse_panel_init (CcMousePanel *self)
|
|
|
|
{
|
|
|
|
CcMousePanelPrivate *priv;
|
|
|
|
|
|
|
|
priv = self->priv = MOUSE_PANEL_PRIVATE (self);
|
2013-01-04 15:23:01 +01:00
|
|
|
g_resources_register (cc_mouse_get_resource ());
|
2010-05-20 17:50:56 +01:00
|
|
|
|
2013-03-28 10:50:58 +01:00
|
|
|
priv->prefs_widget = cc_mouse_properties_new ();
|
2013-03-15 11:57:28 +01:00
|
|
|
priv->test_widget = cc_mouse_test_new ();
|
2012-08-20 19:49:07 +02:00
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
gtk_widget_set_margin_left (priv->prefs_widget, 6);
|
|
|
|
gtk_widget_set_margin_right (priv->prefs_widget, 6);
|
|
|
|
gtk_widget_set_margin_top (priv->prefs_widget, 6);
|
|
|
|
gtk_widget_set_margin_bottom (priv->prefs_widget, 6);
|
2010-05-20 17:50:56 +01:00
|
|
|
|
2013-06-25 12:00:19 +01:00
|
|
|
gtk_container_add (GTK_CONTAINER (self), priv->prefs_widget);
|
2013-03-28 10:50:58 +01:00
|
|
|
gtk_widget_show (priv->prefs_widget);
|
2013-03-15 11:57:28 +01:00
|
|
|
gtk_widget_show (priv->test_widget);
|
2012-11-07 12:29:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_mouse_panel_class_init (CcMousePanelClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (CcMousePanelPrivate));
|
|
|
|
|
|
|
|
panel_class->get_help_uri = cc_mouse_panel_get_help_uri;
|
2010-05-20 17:50:56 +01:00
|
|
|
|
2012-11-07 12:29:46 -05:00
|
|
|
object_class->dispose = cc_mouse_panel_dispose;
|
|
|
|
object_class->constructed = cc_mouse_panel_constructed;
|
2010-05-20 17:50:56 +01:00
|
|
|
}
|