New config dialog for focus mode and autoraise

This commit is contained in:
Stephen Browne 2002-05-29 11:54:12 +00:00
parent 68eb780c75
commit 31ba0b1f95
7 changed files with 380 additions and 3 deletions

View File

@ -1,3 +1,15 @@
2002-05-29 Stephen Browne <stephen.browne@sun.com>
New simple metacity-properties dialog to configure focus mode
and auto raise.
* configure.in: added build support for metacity-properties
* src/tools/Makefile: more build stuff
* src/tools/metacity-properties.c: added these files
* src/tools/metacity-properties.glade:
* src/tools/metacity-properties.desktop.in:
* src/tools/metacity-properties.png:
2002-05-29 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_move_resize_internal): add code to

View File

@ -89,6 +89,7 @@ AM_GLIB_GNU_GETTEXT
PKG_CHECK_MODULES(METACITY, gtk+-2.0 >= 2.0.0 gconf-2.0 >= 1.1.9)
PKG_CHECK_MODULES(METACITY_MESSAGE, gtk+-2.0 >= 2.0.0)
PKG_CHECK_MODULES(METACITY_WINDOW_DEMO, gtk+-2.0 >= 2.0.0)
PKG_CHECK_MODULES(METACITY_PROPS, gtk+-2.0 >= 2.0.0 gconf-2.0 >= 1.1.9 libglade-2.0)
if $PKG_CONFIG --atleast-version 2.1.0 gtk+-2.0; then
AC_DEFINE(HAVE_GTK_MULTIHEAD,,[gtk+ with multihead support found])
@ -112,6 +113,7 @@ fi
METACITY_LIBS="$XINERAMA_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_LIBS"
METACITY_MESSAGE_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_MESSAGE_LIBS"
METACITY_WINDOW_DEMO_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_WINDOW_DEMO_LIBS"
METACITY_PROPS_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_PROPS_LIBS"
found_sm=false
case "$METACITY_LIBS" in

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB