gpointing-device-settings r223 - in trunk: data modules src test
- From: hiikezoe svn gnome org
- To: svn-commits-list gnome org
- Subject: gpointing-device-settings r223 - in trunk: data modules src test
- Date: Sun, 15 Mar 2009 11:15:02 +0000 (UTC)
Author: hiikezoe
Date: Sun Mar 15 11:15:02 2009
New Revision: 223
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=223&view=rev
Log:
UI change.
Now device name with its icon in the left side the window like evolution preference dialog.
Modified:
trunk/data/mouse.ui.in
trunk/data/touchpad.png
trunk/data/touchpad.ui.in
trunk/modules/gpds-mouse-ui.c
trunk/modules/gpds-touchpad-ui.c
trunk/src/gpds-ui.c
trunk/src/gpds-ui.h
trunk/src/gpointing-device-settings.c
trunk/test/test-ui.c
Modified: trunk/data/mouse.ui.in
==============================================================================
--- trunk/data/mouse.ui.in (original)
+++ trunk/data/mouse.ui.in Sun Mar 15 11:15:02 2009
@@ -1,18 +1,5 @@
<?xml version="1.0" standalone="no"?>
<interface>
- <object class="GtkHBox" id ="main-widget-label">
- <property name="visible">True</property>
- <child>
- <object class="GtkImage" id ="main-widget-label-icon">
- <property name="visible">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id ="main-widget-label-text">
- <property name="visible">True</property>
- </object>
- </child>
- </object>
<object class="GtkVBox" id="main-widget">
<property name="visible">True</property>
<child>
Modified: trunk/data/touchpad.png
==============================================================================
Binary files trunk/data/touchpad.png (original) and trunk/data/touchpad.png Sun Mar 15 11:15:02 2009 differ
Modified: trunk/data/touchpad.ui.in
==============================================================================
--- trunk/data/touchpad.ui.in (original)
+++ trunk/data/touchpad.ui.in Sun Mar 15 11:15:02 2009
@@ -65,20 +65,6 @@
<property name="page_size">0</property>
<property name="value">900</property>
</object>
- <object class="GtkHBox" id ="main-widget-label">
- <property name="visible">True</property>
- <child>
- <object class="GtkImage" id ="main-widget-label-icon">
- <property name="visible">True</property>
- <property name="file">@prefix@/share/gpointing-device-settings/icon/touchpad.png</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id ="main-widget-label-text">
- <property name="visible">True</property>
- </object>
- </child>
- </object>
<object class="GtkVBox" id="main-widget">
<property name="visible">True</property>
<property name="homogeneous">False</property>
Modified: trunk/modules/gpds-mouse-ui.c
==============================================================================
--- trunk/modules/gpds-mouse-ui.c (original)
+++ trunk/modules/gpds-mouse-ui.c Sun Mar 15 11:15:02 2009
@@ -59,7 +59,7 @@
static gboolean is_available (GpdsUI *ui, GError **error);
static gboolean build (GpdsUI *ui, GError **error);
static GtkWidget *get_content_widget (GpdsUI *ui, GError **error);
-static GtkWidget *get_label_widget (GpdsUI *ui, GError **error);
+static GdkPixbuf *get_icon_pixbuf (GpdsUI *ui, GError **error);
G_DEFINE_DYNAMIC_TYPE(GpdsMouseUI, gpds_mouse_ui, GPDS_TYPE_UI)
@@ -74,7 +74,7 @@
ui_class->is_available = is_available;
ui_class->build = build;
ui_class->get_content_widget = get_content_widget;
- ui_class->get_label_widget = get_label_widget;
+ ui_class->get_icon_pixbuf = get_icon_pixbuf;
}
static void
@@ -632,33 +632,12 @@
return GTK_WIDGET(widget);
}
-static GtkWidget *
-get_label_widget (GpdsUI *ui, GError **error)
+static GdkPixbuf *
+get_icon_pixbuf (GpdsUI *ui, GError **error)
{
- GtkBuilder *builder;
- GObject *widget, *label, *image;
-
- builder = gpds_ui_get_builder(ui);
-
- widget = gtk_builder_get_object(builder, "main-widget-label");
- if (!widget) {
- g_set_error(error,
- GPDS_UI_ERROR,
- GPDS_UI_ERROR_NO_WIDGET,
- _("There is no widget(%s)."),
- "main-widget-label");
- return NULL;
- }
-
- label = gtk_builder_get_object(builder, "main-widget-label-text");
- if (label)
- gtk_label_set_text(GTK_LABEL(label), gpds_ui_get_device_name(ui));
-
- image = gtk_builder_get_object(builder, "main-widget-label-icon");
- if (image && strstr(gpds_ui_get_device_name(ui), "TrackPoint"))
- gtk_image_set_from_file(GTK_IMAGE(image), GPDS_ICONDIR "/trackpoint.png");
-
- return GTK_WIDGET(widget);
+ if (strstr(gpds_ui_get_device_name(ui), "TrackPoint"))
+ return gdk_pixbuf_new_from_file(GPDS_ICONDIR "/trackpoint.png", error);
+ return NULL;
}
/*
Modified: trunk/modules/gpds-touchpad-ui.c
==============================================================================
--- trunk/modules/gpds-touchpad-ui.c (original)
+++ trunk/modules/gpds-touchpad-ui.c Sun Mar 15 11:15:02 2009
@@ -58,7 +58,7 @@
static gboolean is_available (GpdsUI *ui, GError **error);
static gboolean build (GpdsUI *ui, GError **error);
static GtkWidget *get_content_widget (GpdsUI *ui, GError **error);
-static GtkWidget *get_label_widget (GpdsUI *ui, GError **error);
+static GdkPixbuf *get_icon_pixbuf (GpdsUI *ui, GError **error);
G_DEFINE_DYNAMIC_TYPE(GpdsTouchpadUI, gpds_touchpad_ui, GPDS_TYPE_UI)
@@ -73,7 +73,7 @@
ui_class->is_available = is_available;
ui_class->build = build;
ui_class->get_content_widget = get_content_widget;
- ui_class->get_label_widget = get_label_widget;
+ ui_class->get_icon_pixbuf = get_icon_pixbuf;
}
static void
@@ -879,28 +879,11 @@
return GTK_WIDGET(widget);
}
-static GtkWidget *
-get_label_widget (GpdsUI *ui, GError **error)
+static GdkPixbuf *
+get_icon_pixbuf (GpdsUI *ui, GError **error)
{
- GtkBuilder *builder;
- GObject *widget, *label;
-
- builder = gpds_ui_get_builder(ui);
-
- widget = gtk_builder_get_object(builder, "main-widget-label");
- if (!widget) {
- g_set_error(error,
- GPDS_UI_ERROR,
- GPDS_UI_ERROR_NO_WIDGET,
- _("There is no widget(%s)."),
- "main-widget-label");
- return NULL;
- }
- label = gtk_builder_get_object(builder, "main-widget-label-text");
- if (label)
- gtk_label_set_text(GTK_LABEL(label), gpds_ui_get_device_name(ui));
-
- return GTK_WIDGET(widget);
+ return gdk_pixbuf_new_from_file(GPDS_ICONDIR "/touchpad.png",
+ error);
}
/*
Modified: trunk/src/gpds-ui.c
==============================================================================
--- trunk/src/gpds-ui.c (original)
+++ trunk/src/gpds-ui.c Sun Mar 15 11:15:02 2009
@@ -242,18 +242,17 @@
return (klass->get_content_widget) ? klass->get_content_widget(ui, error) : FALSE;
}
-GtkWidget *
-gpds_ui_get_label_widget (GpdsUI *ui, GError **error)
+GdkPixbuf *
+gpds_ui_get_icon_pixbuf (GpdsUI *ui, GError **error)
{
GpdsUIClass *klass;
g_return_val_if_fail(GPDS_IS_UI(ui), FALSE);
klass = GPDS_UI_GET_CLASS(ui);
- return (klass->get_label_widget) ? klass->get_label_widget(ui, error) : FALSE;
+ return (klass->get_icon_pixbuf) ? klass->get_icon_pixbuf(ui, error) : FALSE;
}
-
GtkBuilder *
gpds_ui_get_builder (GpdsUI *ui)
{
Modified: trunk/src/gpds-ui.h
==============================================================================
--- trunk/src/gpds-ui.h (original)
+++ trunk/src/gpds-ui.h Sun Mar 15 11:15:02 2009
@@ -55,7 +55,7 @@
gboolean (*is_available) (GpdsUI *ui, GError **error);
gboolean (*build) (GpdsUI *ui, GError **error);
GtkWidget *(*get_content_widget) (GpdsUI *ui, GError **error);
- GtkWidget *(*get_label_widget) (GpdsUI *ui, GError **error);
+ GdkPixbuf *(*get_icon_pixbuf) (GpdsUI *ui, GError **error);
};
gboolean gpds_uis_load (void);
@@ -70,7 +70,7 @@
gboolean gpds_ui_is_available (GpdsUI *ui, GError **error);
gboolean gpds_ui_build (GpdsUI *ui, GError **error);
GtkWidget *gpds_ui_get_content_widget (GpdsUI *ui, GError **error);
-GtkWidget *gpds_ui_get_label_widget (GpdsUI *ui, GError **error);
+GdkPixbuf *gpds_ui_get_icon_pixbuf (GpdsUI *ui, GError **error);
GtkBuilder *gpds_ui_get_builder (GpdsUI *ui);
const gchar *gpds_ui_get_device_name (GpdsUI *ui);
void gpds_ui_set_gconf_bool (GpdsUI *ui,
Modified: trunk/src/gpointing-device-settings.c
==============================================================================
--- trunk/src/gpointing-device-settings.c (original)
+++ trunk/src/gpointing-device-settings.c Sun Mar 15 11:15:02 2009
@@ -27,6 +27,12 @@
#include "gpds-module.h"
#include "gpds-ui.h"
+enum {
+ DEVICE_NAME_COLUMN,
+ ICON_COLUMN,
+ N_COLUMNS
+};
+
static GList *uis = NULL;
static gboolean
@@ -52,73 +58,124 @@
gtk_main_quit();
}
+static GpdsUI *
+create_ui (GpdsXInputPointerInfo *info)
+{
+ GpdsUI *ui;
+ gchar *type_name;
+ const gchar *device_name;
+ GError *error = NULL;
+
+ device_name = gpds_xinput_pointer_info_get_name(info);
+ if (!strcmp(device_name, "Macintosh mouse button emulation"))
+ return NULL;
+
+ type_name = g_ascii_strdown(gpds_xinput_pointer_info_get_type_name(info), -1);
+ ui = gpds_ui_new(type_name,
+ "device-name", device_name,
+ NULL);
+ g_free(type_name);
+
+ if (!gpds_ui_is_available(ui, &error)) {
+ if (error) {
+ g_message("%s", error->message);
+ g_clear_error(&error);
+ }
+ g_object_unref(ui);
+ return NULL;
+ }
+
+ return ui;
+}
+
+static void
+append_ui (GtkIconView *icon_view, GtkNotebook *notebook,
+ GpdsUI *ui)
+{
+ GtkWidget *widget = NULL;
+ GError *error = NULL;
+ GtkTreeIter iter;
+ GdkPixbuf *pixbuf;
+ GtkListStore *list_store;
+
+ gpds_ui_build(ui, &error);
+ if (error) {
+ g_warning("%s", error->message);
+ g_clear_error(&error);
+ }
+ widget = gpds_ui_get_content_widget(ui, &error);
+ if (error) {
+ g_warning("%s", error->message);
+ g_clear_error(&error);
+ }
+
+ if (!widget)
+ widget = gtk_label_new(error->message);
+
+ list_store = GTK_LIST_STORE(gtk_icon_view_get_model(icon_view));
+ gtk_list_store_append(list_store, &iter);
+ pixbuf = gpds_ui_get_icon_pixbuf(ui, &error);
+ if (error) {
+ g_warning("%s", error->message);
+ g_clear_error(&error);
+ }
+
+ gtk_list_store_set(list_store, &iter,
+ DEVICE_NAME_COLUMN, gpds_ui_get_device_name(ui),
+ ICON_COLUMN, pixbuf,
+ -1);
+ gtk_notebook_append_page(notebook, widget, NULL);
+}
+
static void
-append_uis (GtkNotebook *notebook)
+append_uis (GtkIconView *icon_view, GtkNotebook *notebook)
{
GList *node, *pointer_infos;;
pointer_infos = gpds_xinput_utils_collect_pointer_infos();
for (node = pointer_infos; node; node = g_list_next(node)) {
- GpdsUI *ui;
GpdsXInputPointerInfo *info = node->data;
- gchar *type_name;
- GtkWidget *widget = NULL;
- GtkWidget *label = NULL;
- GError *error = NULL;
-
- if (!strcmp(gpds_xinput_pointer_info_get_name(info),
- "Macintosh mouse button emulation")) {
- continue;
- }
-
- type_name = g_ascii_strdown(gpds_xinput_pointer_info_get_type_name(info), -1);
- ui = gpds_ui_new(type_name,
- "device-name", gpds_xinput_pointer_info_get_name(info),
- NULL);
- g_free(type_name);
- uis = g_list_prepend(uis, ui);
-
- if (!gpds_ui_is_available(ui, &error)) {
- if (error) {
- g_message("%s", error->message);
- g_clear_error(&error);
- }
- continue;
- }
+ GpdsUI *ui;
- gpds_ui_build(ui, &error);
- if (error) {
- g_warning("%s", error->message);
- g_clear_error(&error);
- }
- widget = gpds_ui_get_content_widget(ui, &error);
- if (error) {
- g_warning("%s", error->message);
- g_clear_error(&error);
- }
- label = gpds_ui_get_label_widget(ui, &error);
- if (error) {
- g_warning("%s", error->message);
- g_clear_error(&error);
+ ui = create_ui(info);
+ if (ui) {
+ uis = g_list_prepend(uis, ui);
+ append_ui(icon_view, notebook, ui);
}
-
- if (!widget)
- widget = gtk_label_new(error->message);
-
- gtk_notebook_append_page(notebook,
- widget, label);
-
}
g_list_foreach(pointer_infos, (GFunc)gpds_xinput_pointer_info_free, NULL);
g_list_free(pointer_infos);
}
+static void
+cb_selection_changed (GtkIconView *icon_view, gpointer data)
+{
+ GtkTreePath *path = NULL;
+ GtkCellRenderer *cell = NULL;
+ GtkTreeModel *model;
+ GtkNotebook *notebook = GTK_NOTEBOOK(data);
+ gint *indices;
+
+ gtk_icon_view_get_cursor(icon_view, &path, &cell);
+
+ if (!path)
+ return;
+ model = gtk_icon_view_get_model(icon_view);
+ indices = gtk_tree_path_get_indices(path);
+ gtk_notebook_set_current_page(notebook, indices[0]);
+
+ gtk_tree_path_free(path);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *dialog, *notebook, *content_area;
+ GtkWidget *hbox;
+ GtkIconView *icon_view;
+ GtkListStore *list_store;
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
@@ -136,11 +193,25 @@
g_signal_connect(dialog, "response",
G_CALLBACK(cb_response), NULL);
+ hbox = gtk_hbox_new(FALSE, 8);
notebook = gtk_notebook_new();
+ gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
+
+ list_store = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF);
+ icon_view = GTK_ICON_VIEW(gtk_icon_view_new_with_model(GTK_TREE_MODEL(list_store)));
+ gtk_icon_view_set_pixbuf_column(icon_view, ICON_COLUMN);
+ gtk_icon_view_set_text_column(icon_view, DEVICE_NAME_COLUMN);
+ gtk_icon_view_set_selection_mode(icon_view, GTK_SELECTION_MULTIPLE);
+ g_signal_connect(icon_view, "selection-changed",
+ G_CALLBACK(cb_selection_changed), notebook);
+ g_object_unref(list_store);
+
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(icon_view), FALSE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox), notebook, TRUE, TRUE, 0);
content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_container_add(GTK_CONTAINER(content_area),
- notebook);
- append_uis(GTK_NOTEBOOK(notebook));
+ hbox);
+ append_uis(icon_view, GTK_NOTEBOOK(notebook));
gtk_widget_show_all(dialog);
gtk_main();
Modified: trunk/test/test-ui.c
==============================================================================
--- trunk/test/test-ui.c (original)
+++ trunk/test/test-ui.c Sun Mar 15 11:15:02 2009
@@ -8,13 +8,14 @@
void test_is_available (void);
void test_build (void);
void test_get_content_widget (void);
-void test_get_label_widget (void);
+void test_get_icon_pixbuf (void);
static GError *error;
static GpdsUI *ui;
static GList *names;
static GList *expected_names;
static GtkWidget *widget;
+static GdkPixbuf *pixbuf;
#define DEVICE_NAME "Macintosh mouse button emulation"
@@ -38,6 +39,7 @@
error = NULL;
names = NULL;
expected_names = NULL;
+ pixbuf = NULL;
}
void
@@ -48,6 +50,8 @@
g_list_free(names);
g_list_free(expected_names);
+ if (pixbuf)
+ g_object_unref(pixbuf);
if (error)
g_clear_error(&error);
}
@@ -114,13 +118,13 @@
}
void
-test_get_label_widget (void)
+test_get_icon_pixbuf (void)
{
cut_trace(test_build());
- widget = gpds_ui_get_label_widget(ui, &error);
+ pixbuf = gpds_ui_get_icon_pixbuf(ui, &error);
gcut_assert_error(error);
- cut_assert_true(GTK_IS_WIDGET(widget));
+ cut_assert_true(GDK_IS_PIXBUF(pixbuf));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]