[gnome-settings-daemon/randr-osd: 6/15] Function to create buttons for each stock configuration type
- From: Federico Mena Quintero <federico src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/randr-osd: 6/15] Function to create buttons for each stock configuration type
- Date: Tue, 19 Jan 2010 23:35:17 +0000 (UTC)
commit 1ef4114f8a71309a2e67af22b5d0fcc77217861f
Author: Federico Mena Quintero <federico novell com>
Date: Wed Jan 13 15:13:38 2010 -0600
Function to create buttons for each stock configuration type
Signed-off-by: Federico Mena Quintero <federico novell com>
plugins/xrandr/Makefile.am | 10 ++--
plugins/xrandr/gsd-xrandr-manager.c | 88 +++++++++++++++++++++++++++--------
2 files changed, 75 insertions(+), 23 deletions(-)
---
diff --git a/plugins/xrandr/Makefile.am b/plugins/xrandr/Makefile.am
index c66d09a..c74cbbf 100644
--- a/plugins/xrandr/Makefile.am
+++ b/plugins/xrandr/Makefile.am
@@ -71,10 +71,12 @@ libxrandr_la_SOURCES = \
gsd-xrandr-manager.h \
gsd-xrandr-manager.c
-libxrandr_la_CPPFLAGS = \
- -I$(top_srcdir)/gnome-settings-daemon \
- -DBINDIR=\"$(bindir)\" \
- -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
+libxrandr_la_CPPFLAGS = \
+ -I$(top_srcdir)/gnome-settings-daemon \
+ -I$(top_srcdir)/plugins/common \
+ -DBINDIR=\"$(bindir)\" \
+ -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
+ -DGNOME_SETTINGS_DATADIR=\""$(datadir)/gnome-settings-daemon"\" \
$(AM_CPPFLAGS)
libxrandr_la_CFLAGS = \
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 4f28bb3..d979c60 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -999,32 +999,28 @@ error_message (GsdXrandrManager *mgr, const char *primary_text, GError *error_to
}
static const char *
-get_icon_name_for_stock_config (StockConfigType type)
+get_label_for_stock_config (StockConfigType type)
{
switch (type) {
case STOCK_CONFIG_CURRENT:
- return "gsd-xrandr-current";
+ return _("Current");
case STOCK_CONFIG_LAPTOP:
- return "gsd-xrandr-laptop";
+ return _("_Laptop only");
case STOCK_CONFIG_CLONE_LAPTOP:
- return "gsd-xrandr-clone-laptop";
-
case STOCK_CONFIG_CLONE_MONITORS:
- return "gsd-xrandr-clone-monitors";
+ return _("_Mirror screens");
case STOCK_CONFIG_EXTENDED_RIGHT:
- return "gsd-xrandr-extended-right";
-
case STOCK_CONFIG_EXTENDED_ONTOP:
- return "gsd-xrandr-extended-ontop";
+ return _("_Extended");
case STOCK_CONFIG_EXTERNAL:
- return "gsd-xrandr-external";
+ return _("E_xternal only");
case STOCK_CONFIG_CUSTOM:
- return "gsd-xrandr-custom";
+ return _("_Custom setup...");
default:
g_assert_not_reached ();
@@ -1032,34 +1028,88 @@ get_icon_name_for_stock_config (StockConfigType type)
}
}
-static const char *
-get_label_for_stock_config (StockConfigType type)
+static char *
+get_filename_for_stock_config_icon (StockConfigType type)
{
+ const char *base;
+
switch (type) {
case STOCK_CONFIG_CURRENT:
- return _("Current");
+ base = "gsd-xrandr-current.png";
+ break;
case STOCK_CONFIG_LAPTOP:
- return _("_Laptop only");
+ base = "gsd-xrandr-laptop.png";
+ break;
case STOCK_CONFIG_CLONE_LAPTOP:
+ base = "gsd-xrandr-clone-laptop.png";
+ break;
+
case STOCK_CONFIG_CLONE_MONITORS:
- return _("_Mirror screens");
+ base = "gsd-xrandr-clone-monitors.png";
+ break;
case STOCK_CONFIG_EXTENDED_RIGHT:
+ base = "gsd-xrandr-extended-right.png";
+ break;
+
case STOCK_CONFIG_EXTENDED_ONTOP:
- return _("_Extended");
+ base = "gsd-xrandr-extended-ontop.png";
+ break;
case STOCK_CONFIG_EXTERNAL:
- return _("E_xternal only");
+ base = "gsd-xrandr-external.png";
+ break;
case STOCK_CONFIG_CUSTOM:
- return _("_Custom setup...");
+ base = "gsd-xrandr-custom.png";
+ break;
default:
g_assert_not_reached ();
return NULL;
}
+
+ return g_build_filename (GNOME_SETTINGS_DATADIR, "xrandr", base, NULL);
+}
+
+static GtkWidget *
+make_button_for_stock_config (GsdXrandrManager *manager, StockConfigType type)
+{
+ GtkWidget *button;
+ GtkWidget *box;
+ GtkWidget *label;
+ GdkPixbuf *pixbuf;
+ char *icon_filename;
+
+ button = gtk_button_new ();
+ g_object_set_data (G_OBJECT (button), "stock-config-type", GINT_TO_POINTER (type));
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (stock_config_button_clicked_cb), manager);
+
+ box = gtk_vbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 12);
+ gtk_container_add (GTK_CONTAINER (button), box);
+
+ icon_filename = get_filename_for_stock_config_icon (type);
+ pixbuf = gdk_pixbuf_new_from_file (icon_filename, NULL); /* NULL-GError */
+ if (pixbuf) {
+ GtkWidget *image;
+
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ g_object_unref (pixbuf);
+
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
+ }
+
+ label = gtk_label_new_with_mnemonic (get_label_for_stock_config (type));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
+ gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (button);
+
+ return button;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]