diff options
author | Stephen Browne <stephen@src.gnome.org> | 2002-05-29 11:54:12 +0000 |
---|---|---|
committer | Stephen Browne <stephen@src.gnome.org> | 2002-05-29 11:54:12 +0000 |
commit | 31ba0b1f95a2ea10d1fd7d143da1883d94a9ff44 (patch) | |
tree | 123105fc73353d338e38514b7d0f0a52ecc1dee5 /src/tools | |
parent | 68eb780c758ce1ed07f12d825ade0e8e67e46e3f (diff) | |
download | metacity-31ba0b1f95a2ea10d1fd7d143da1883d94a9ff44.tar.gz metacity-31ba0b1f95a2ea10d1fd7d143da1883d94a9ff44.tar.bz2 |
New config dialog for focus mode and autoraise
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/Makefile.am | 28 | ||||
-rw-r--r-- | src/tools/metacity-properties.c | 131 | ||||
-rw-r--r-- | src/tools/metacity-properties.desktop.in | 8 | ||||
-rw-r--r-- | src/tools/metacity-properties.glade | 202 | ||||
-rw-r--r-- | src/tools/metacity-properties.png | bin | 0 -> 1565 bytes |
5 files changed, 366 insertions, 3 deletions
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am index 6514484..25ed4de 100644 --- a/src/tools/Makefile.am +++ b/src/tools/Makefile.am @@ -1,8 +1,13 @@ +@INTLTOOL_DESKTOP_RULE@ icondir=$(pkgdatadir)/icons icon_DATA=metacity-window-demo.png -INCLUDES=@METACITY_WINDOW_DEMO_CFLAGS@ @METACITY_MESSAGE_CFLAGS@ -DMETACITY_ICON_DIR=\"$(pkgdatadir)/icons\" +INCLUDES=@METACITY_WINDOW_DEMO_CFLAGS@ @METACITY_MESSAGE_CFLAGS@ \ + @METACITY_PROPS_CFLAGS@ -DMETACITY_ICON_DIR=\"$(pkgdatadir)/icons\" \ + -DMETACITY_PROPS_GLADEDIR=\"$(pkgdatadir)/glade\" \ + -DMETACITY_PROPS_ICON_DIR=\"$(datadir)/pixmaps\" \ + -DMETACITY_LOCALEDIR=\"$(datadir)/locale\" metacity_message_SOURCES= \ metacity-message.c @@ -10,9 +15,26 @@ metacity_message_SOURCES= \ metacity_window_demo_SOURCES= \ metacity-window-demo.c -bin_PROGRAMS=metacity-message metacity-window-demo +metacity_properties_SOURCES= \ + metacity-properties.c + +metacity_properties_LDFLAGS = -export-dynamic + +uidir=$(pkgdatadir)/glade +ui_DATA=metacity-properties.glade + +propicondir=$(datadir)/pixmaps +propicon_DATA=metacity-properties.png + +desktopdir=$(datadir)/control-center-2.0/capplets +Desktop_in_files=metacity-properties.desktop.in +desktop_DATA=$(Desktop_in_files:.desktop.in=.desktop) + +bin_PROGRAMS=metacity-message metacity-window-demo metacity-properties metacity_message_LDADD= @METACITY_MESSAGE_LIBS@ metacity_window_demo_LDADD= @METACITY_WINDOW_DEMO_LIBS@ +metacity_properties_LDADD= @METACITY_PROPS_LIBS@ + +EXTRA_DIST=$(icon_DATA) $(ui_DATA) $(propicon_DATA) -EXTRA_DIST=$(icon_DATA)
\ No newline at end of file diff --git a/src/tools/metacity-properties.c b/src/tools/metacity-properties.c new file mode 100644 index 0000000..6ee8a28 --- /dev/null +++ b/src/tools/metacity-properties.c @@ -0,0 +1,131 @@ +#include <config.h> +#include <glade/glade.h> +#include <gtk/gtk.h> +#include <libintl.h> +#include <string.h> +#include <gconf/gconf-client.h> + +void update_config (GtkWidget *widget, gpointer user_data); + +static GConfClient *gconf_client; +static GtkWidget *click_radio; +static GtkWidget *point_radio; +static GtkWidget *autoraise_check; + +#define KEY_DIR "/apps/metacity/general" +#define KEY_FOCUS_MODE "/apps/metacity/general/focus_mode" +#define KEY_AUTO_RAISE "/apps/metacity/general/auto_raise" + +static void +update_ui (void) +{ + char *focus_mode; + + focus_mode = gconf_client_get_string (gconf_client, + KEY_FOCUS_MODE, + NULL); + + if (focus_mode == NULL) focus_mode = g_strdup("click"); + + if (strcmp (focus_mode, "click") == 0) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (click_radio), + TRUE); + gtk_widget_set_sensitive(autoraise_check, FALSE); + } + else + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (point_radio), + TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoraise_check), + gconf_client_get_bool (gconf_client, + KEY_AUTO_RAISE, + NULL)); + gtk_widget_set_sensitive(autoraise_check, TRUE); + } + + g_free (focus_mode); +} + +static void +key_change_cb (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + update_ui (); +} + +void +update_config (GtkWidget *widget, gpointer user_data) +{ + const char *focus_mode = NULL; + + if (GTK_TOGGLE_BUTTON (click_radio)->active == TRUE) + { + focus_mode = "click"; + } + else + { + focus_mode = "sloppy"; + } + + gconf_client_set_string (gconf_client, + KEY_FOCUS_MODE, + focus_mode, + NULL); + + gconf_client_set_bool (gconf_client, KEY_AUTO_RAISE, + GTK_TOGGLE_BUTTON (autoraise_check)->active, NULL); +} + +int +main (int argc, char **argv) +{ + GladeXML *xml; + GdkPixbuf *pixbuf; + GtkWidget *window, *icon; + + bindtextdomain (GETTEXT_PACKAGE, METACITY_LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + gtk_init (&argc, &argv); + + xml = glade_xml_new (METACITY_PROPS_GLADEDIR + "/metacity-properties.glade", NULL, NULL); + + click_radio = glade_xml_get_widget (xml, "Clickfocus"); + point_radio = glade_xml_get_widget (xml, "Pointfocus"); + autoraise_check = glade_xml_get_widget (xml, "Autoraise"); + window = glade_xml_get_widget (xml, "Mainwindow"); + icon = glade_xml_get_widget (xml, "Icon"); + + pixbuf = gdk_pixbuf_new_from_file (METACITY_PROPS_ICON_DIR + "/metacity-properties.png", NULL); + + gtk_window_set_icon (GTK_WINDOW (window), pixbuf); + gtk_image_set_from_pixbuf (GTK_IMAGE(icon) , pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + + gconf_client = gconf_client_get_default (); + gconf_client_add_dir (gconf_client, + KEY_DIR, + GCONF_CLIENT_PRELOAD_NONE, + NULL); + gconf_client_notify_add (gconf_client, + KEY_FOCUS_MODE, + key_change_cb, + NULL, NULL, NULL); + gconf_client_notify_add (gconf_client, + KEY_AUTO_RAISE, + key_change_cb, + NULL, NULL, NULL); + + update_ui (); + + glade_xml_signal_autoconnect(xml); + + gtk_main(); + + return 0; +} + diff --git a/src/tools/metacity-properties.desktop.in b/src/tools/metacity-properties.desktop.in new file mode 100644 index 0000000..f0084a3 --- /dev/null +++ b/src/tools/metacity-properties.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Window Focus +Comment=Change how focus is moved from one window to another +Exec=metacity-properties +Icon=metacity-properties.png +Terminal=0 +Type=Application +Categories=Application;Settings; diff --git a/src/tools/metacity-properties.glade b/src/tools/metacity-properties.glade new file mode 100644 index 0000000..af39603 --- /dev/null +++ b/src/tools/metacity-properties.glade @@ -0,0 +1,202 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkDialog" id="Mainwindow"> + <property name="visible">True</property> + <property name="title" translatable="yes">Window Properties</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="has_separator">True</property> + <signal name="close" handler="gtk_main_quit" last_modification_time="Tue, 28 May 2002 18:10:39 GMT"/> + <signal name="response" handler="gtk_main_quit" last_modification_time="Tue, 28 May 2002 18:12:39 GMT"/> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="border_width">2</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="border_width">5</property> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">10</property> + + <child> + <widget class="GtkButton" id="helpbutton"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-help</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">-11</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="closebutton1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-close</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">-7</property> + <signal name="clicked" handler="gtk_main_quit" last_modification_time="Tue, 28 May 2002 18:19:12 GMT"/> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="border_width">8</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">8</property> + + <child> + <widget class="GtkImage" id="Icon"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">8</property> + <property name="column_spacing">8</property> + + <child> + <widget class="GtkRadioButton" id="Clickfocus"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Click to give focus</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="update_config" last_modification_time="Tue, 28 May 2002 20:59:55 GMT"/> + <signal name="clicked" handler="update_config" last_modification_time="Tue, 28 May 2002 21:19:56 GMT"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="Pointfocus"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Point to give focus</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <property name="group">Clickfocus</property> + <signal name="toggled" handler="update_config" last_modification_time="Tue, 28 May 2002 21:00:02 GMT"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">Window behavior:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="Autoraise"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Raise window on focus</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="update_config" last_modification_time="Tue, 28 May 2002 21:00:14 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/src/tools/metacity-properties.png b/src/tools/metacity-properties.png Binary files differnew file mode 100644 index 0000000..8b5d9c3 --- /dev/null +++ b/src/tools/metacity-properties.png |