mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
when mapping a window with struts, invalidate the work areas it's on.
2002-02-08 Havoc Pennington <hp@pobox.com> * src/window.c (meta_window_show): when mapping a window with struts, invalidate the work areas it's on. Should fix at least part of the problem with windows maximizing over panels. * src/workspace.c (meta_workspace_invalidate_work_area): also queue move/resize on sticky windows * src/tools/Makefile.am: consolidate reload-theme, restart into a "metacity-message" app and add enable/disable keybindings to the messages it knows about. * src/keybindings.c: (meta_change_keygrab): grab keyboard synchronously (meta_display_process_key_event): if all keybindings are toggled off, ReplayKeyboard, else AsyncKeyboard, except that the debug binding for toggling back on is always processed (meta_set_keybindings_disabled): function to disable/enable all keybindings
This commit is contained in:

committed by
Havoc Pennington

parent
43b67afc41
commit
51d9f9dce6
@ -1,17 +1,13 @@
|
||||
|
||||
INCLUDES=@METACITY_RESTART_CFLAGS@ @METACITY_RELOAD_THEME_CFLAGS@ @METACITY_WINDOW_DEMO_CFLAGS@
|
||||
INCLUDES=@METACITY_WINDOW_DEMO_CFLAGS@ @METACITY_MESSAGE_CFLAGS@
|
||||
|
||||
metacity_restart_SOURCES= \
|
||||
metacity-restart.c
|
||||
|
||||
metacity_reload_theme_SOURCES= \
|
||||
metacity-reload-theme.c
|
||||
metacity_message_SOURCES= \
|
||||
metacity-message.c
|
||||
|
||||
metacity_window_demo_SOURCES= \
|
||||
metacity-window-demo.c
|
||||
|
||||
bin_PROGRAMS=metacity-restart metacity-reload-theme metacity-window-demo
|
||||
bin_PROGRAMS=metacity-message metacity-window-demo
|
||||
|
||||
metacity_restart_LDADD= @METACITY_RESTART_LIBS@
|
||||
metacity_reload_theme_LDADD= @METACITY_RELOAD_THEME_LIBS@
|
||||
metacity_message_LDADD= @METACITY_MESSAGE_LIBS@
|
||||
metacity_window_demo_LDADD= @METACITY_WINDOW_DEMO_LIBS@
|
||||
|
139
src/tools/metacity-message.c
Normal file
139
src/tools/metacity-message.c
Normal file
@ -0,0 +1,139 @@
|
||||
/* Metacity send-magic-messages app */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 Havoc Pennington
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static void
|
||||
send_restart (void)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = gdk_display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (gdk_display,
|
||||
"_METACITY_RESTART_MESSAGE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (gdk_display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (gdk_display);
|
||||
XSync (gdk_display, False);
|
||||
}
|
||||
|
||||
static void
|
||||
send_reload_theme (void)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = gdk_display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (gdk_display,
|
||||
"_METACITY_RELOAD_THEME_MESSAGE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (gdk_display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (gdk_display);
|
||||
XSync (gdk_display, False);
|
||||
}
|
||||
|
||||
static void
|
||||
send_set_keybindings (gboolean enabled)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = gdk_display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (gdk_display,
|
||||
"_METACITY_SET_KEYBINDINGS_MESSAGE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = enabled;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (gdk_display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (gdk_display);
|
||||
XSync (gdk_display, False);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
g_printerr ("Usage: metacity-message (restart|reload-theme|enable-keybindings|disable-keybindings)\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
if (argc < 2)
|
||||
usage ();
|
||||
|
||||
if (strcmp (argv[1], "restart") == 0)
|
||||
send_restart ();
|
||||
else if (strcmp (argv[1], "reload-theme") == 0)
|
||||
send_reload_theme ();
|
||||
else if (strcmp (argv[1], "enable-keybindings") == 0)
|
||||
send_set_keybindings (TRUE);
|
||||
else if (strcmp (argv[1], "disable-keybindings") == 0)
|
||||
send_set_keybindings (FALSE);
|
||||
else
|
||||
usage ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
/* Metacity theme-reloader app */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 Havoc Pennington
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = gdk_display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (gdk_display,
|
||||
"_METACITY_RELOAD_THEME_MESSAGE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (gdk_display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (gdk_display);
|
||||
XSync (gdk_display, False);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
/* Metacity restart app */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = gdk_display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (gdk_display,
|
||||
"_METACITY_RESTART_MESSAGE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (gdk_display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (gdk_display);
|
||||
XSync (gdk_display, False);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -195,7 +195,8 @@ utility_cb (gpointer callback_data,
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_UTILITY");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Utility");
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (callback_data));
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
@ -269,7 +270,8 @@ splashscreen_cb (gpointer callback_data,
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_SPLASHSCREEN");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Splashscreen");
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
|
||||
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
|
||||
@ -318,7 +320,7 @@ make_dock (int type)
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_DOCK");
|
||||
|
||||
|
||||
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||
|
||||
@ -339,21 +341,25 @@ make_dock (int type)
|
||||
gtk_widget_set_size_request (window, DOCK_SIZE, gdk_screen_height ());
|
||||
gtk_window_move (GTK_WINDOW (window), 0, 0);
|
||||
set_gtk_window_struts (window, DOCK_SIZE, 0, 0, 0);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "LeftDock");
|
||||
break;
|
||||
case DOCK_RIGHT:
|
||||
gtk_widget_set_size_request (window, DOCK_SIZE, gdk_screen_height ());
|
||||
gtk_window_move (GTK_WINDOW (window), gdk_screen_width () - DOCK_SIZE, 0);
|
||||
set_gtk_window_struts (window, 0, DOCK_SIZE, 0, 0);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "RightDock");
|
||||
break;
|
||||
case DOCK_TOP:
|
||||
gtk_widget_set_size_request (window, gdk_screen_width (), DOCK_SIZE);
|
||||
gtk_window_move (GTK_WINDOW (window), 0, 0);
|
||||
set_gtk_window_struts (window, 0, 0, DOCK_SIZE, 0);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "TopDock");
|
||||
break;
|
||||
case DOCK_BOTTOM:
|
||||
gtk_widget_set_size_request (window, gdk_screen_width (), DOCK_SIZE);
|
||||
gtk_window_move (GTK_WINDOW (window), 0, gdk_screen_height () - DOCK_SIZE);
|
||||
set_gtk_window_struts (window, 0, 0, 0, DOCK_SIZE);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "BottomDock");
|
||||
break;
|
||||
case DOCK_ALL:
|
||||
break;
|
||||
@ -391,6 +397,7 @@ desktop_cb (gpointer callback_data,
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_DESKTOP");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Desktop");
|
||||
gtk_widget_set_size_request (window,
|
||||
gdk_screen_width (), gdk_screen_height ());
|
||||
gtk_window_move (GTK_WINDOW (window), 0, 0);
|
||||
@ -481,175 +488,176 @@ mark_set_callback (GtkTextBuffer *buffer,
|
||||
update_statusbar (buffer, GTK_STATUSBAR (data));
|
||||
}
|
||||
|
||||
static int window_count = 0;
|
||||
|
||||
static void
|
||||
destroy_cb (GtkWidget *w, gpointer data)
|
||||
{
|
||||
--window_count;
|
||||
if (window_count == 0)
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
do_appwindow (void)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *window;
|
||||
GtkWidget *table;
|
||||
GtkWidget *toolbar;
|
||||
GtkWidget *handlebox;
|
||||
GtkWidget *statusbar;
|
||||
GtkWidget *contents;
|
||||
GtkWidget *sw;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkAccelGroup *accel_group;
|
||||
GtkItemFactory *item_factory;
|
||||
|
||||
/* Create the toplevel window
|
||||
*/
|
||||
|
||||
++window_count;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *table;
|
||||
GtkWidget *toolbar;
|
||||
GtkWidget *handlebox;
|
||||
GtkWidget *statusbar;
|
||||
GtkWidget *contents;
|
||||
GtkWidget *sw;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkAccelGroup *accel_group;
|
||||
GtkItemFactory *item_factory;
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Application Window");
|
||||
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (destroy_cb), NULL);
|
||||
|
||||
/* Create the toplevel window
|
||||
*/
|
||||
table = gtk_table_new (1, 4, FALSE);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Application Window");
|
||||
|
||||
/* NULL window variable when window is closed */
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&window);
|
||||
|
||||
/* Also quit ;-) */
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (gtk_main_quit),
|
||||
NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
|
||||
table = gtk_table_new (1, 4, FALSE);
|
||||
/* Create the menubar
|
||||
*/
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
g_object_unref (accel_group);
|
||||
|
||||
/* Create the menubar
|
||||
*/
|
||||
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
|
||||
|
||||
/* Set up item factory to go away with the window */
|
||||
g_object_ref (item_factory);
|
||||
gtk_object_sink (GTK_OBJECT (item_factory));
|
||||
g_object_set_data_full (G_OBJECT (window),
|
||||
"<main>",
|
||||
item_factory,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
|
||||
/* create menu items */
|
||||
gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
|
||||
menu_items, window);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
gtk_item_factory_get_widget (item_factory, "<main>"),
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Create the toolbar
|
||||
*/
|
||||
toolbar = gtk_toolbar_new ();
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
GTK_STOCK_NEW,
|
||||
"Open another one of these windows",
|
||||
NULL,
|
||||
G_CALLBACK (do_appwindow),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
GTK_STOCK_OPEN,
|
||||
"This is a demo button with an 'open' icon",
|
||||
NULL,
|
||||
G_CALLBACK (toolbar_cb),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
GTK_STOCK_QUIT,
|
||||
"This is a demo button with a 'quit' icon",
|
||||
NULL,
|
||||
G_CALLBACK (toolbar_cb),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
handlebox = gtk_handle_box_new ();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
g_object_unref (accel_group);
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
handlebox,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Create document
|
||||
*/
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
sw,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 2, 3,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
0, 0);
|
||||
|
||||
/* Set up item factory to go away with the window */
|
||||
g_object_ref (item_factory);
|
||||
gtk_object_sink (GTK_OBJECT (item_factory));
|
||||
g_object_set_data_full (G_OBJECT (window),
|
||||
"<main>",
|
||||
item_factory,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
|
||||
/* create menu items */
|
||||
gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
|
||||
menu_items, window);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
gtk_item_factory_get_widget (item_factory, "<main>"),
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Create the toolbar
|
||||
*/
|
||||
toolbar = gtk_toolbar_new ();
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
GTK_STOCK_OPEN,
|
||||
"This is a demo button with an 'open' icon",
|
||||
NULL,
|
||||
G_CALLBACK (toolbar_cb),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
GTK_STOCK_QUIT,
|
||||
"This is a demo button with a 'quit' icon",
|
||||
NULL,
|
||||
G_CALLBACK (toolbar_cb),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
handlebox = gtk_handle_box_new ();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
200, 200);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
handlebox,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Create document
|
||||
*/
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_IN);
|
||||
contents = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
|
||||
PANGO_WRAP_WORD);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
sw,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 2, 3,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
0, 0);
|
||||
gtk_container_add (GTK_CONTAINER (sw),
|
||||
contents);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
200, 200);
|
||||
/* Create statusbar */
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
statusbar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 3, 4,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Show text widget info in the statusbar */
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
|
||||
|
||||
gtk_text_buffer_set_text (buffer,
|
||||
"This demo demonstrates various kinds of windows that "
|
||||
"window managers and window manager themes should handle. "
|
||||
"Be sure to tear off the menu and toolbar, those are also "
|
||||
"a special kind of window.",
|
||||
-1);
|
||||
|
||||
contents = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
|
||||
PANGO_WRAP_WORD);
|
||||
g_signal_connect_object (buffer,
|
||||
"changed",
|
||||
G_CALLBACK (update_statusbar),
|
||||
statusbar,
|
||||
0);
|
||||
|
||||
g_signal_connect_object (buffer,
|
||||
"mark_set", /* cursor moved */
|
||||
G_CALLBACK (mark_set_callback),
|
||||
statusbar,
|
||||
0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw),
|
||||
contents);
|
||||
update_statusbar (buffer, GTK_STATUSBAR (statusbar));
|
||||
|
||||
/* Create statusbar */
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
statusbar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 3, 4,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Show text widget info in the statusbar */
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
|
||||
|
||||
gtk_text_buffer_set_text (buffer,
|
||||
"This demo demonstrates various kinds of windows that "
|
||||
"window managers and window manager themes should handle. "
|
||||
"Be sure to tear off the menu and toolbar, those are also "
|
||||
"a special kind of window.",
|
||||
-1);
|
||||
|
||||
g_signal_connect_object (buffer,
|
||||
"changed",
|
||||
G_CALLBACK (update_statusbar),
|
||||
statusbar,
|
||||
0);
|
||||
|
||||
g_signal_connect_object (buffer,
|
||||
"mark_set", /* cursor moved */
|
||||
G_CALLBACK (mark_set_callback),
|
||||
statusbar,
|
||||
0);
|
||||
|
||||
update_statusbar (buffer, GTK_STATUSBAR (statusbar));
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
{
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
Reference in New Issue
Block a user