Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 06:29:20 -04:00
|
|
|
/* Mutter window types/properties demo app */
|
2002-02-07 23:44:56 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 <X11/Xatom.h>
|
2002-04-12 19:00:46 -04:00
|
|
|
#include <unistd.h>
|
2002-02-07 23:44:56 -05:00
|
|
|
|
|
|
|
static GtkWidget* do_appwindow (void);
|
|
|
|
|
2006-01-20 17:03:56 -05:00
|
|
|
static gboolean aspect_on;
|
2003-07-27 22:09:20 -04:00
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
static void
|
|
|
|
set_gdk_window_struts (GdkWindow *window,
|
|
|
|
int left,
|
|
|
|
int right,
|
|
|
|
int top,
|
|
|
|
int bottom)
|
|
|
|
{
|
2003-06-25 23:09:38 -04:00
|
|
|
long vals[12];
|
2002-02-07 23:44:56 -05:00
|
|
|
|
|
|
|
vals[0] = left;
|
|
|
|
vals[1] = right;
|
|
|
|
vals[2] = top;
|
|
|
|
vals[3] = bottom;
|
2003-06-25 23:09:38 -04:00
|
|
|
vals[4] = 000;
|
|
|
|
vals[5] = 400;
|
|
|
|
vals[6] = 200;
|
|
|
|
vals[7] = 600;
|
|
|
|
vals[8] = 76;
|
|
|
|
vals[9] = 676;
|
|
|
|
vals[10] = 200;
|
|
|
|
vals[11] = 800;
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
|
2010-12-02 09:51:36 -05:00
|
|
|
GDK_WINDOW_XID (window),
|
2002-02-07 23:44:56 -05:00
|
|
|
XInternAtom (GDK_WINDOW_XDISPLAY (window),
|
2003-06-25 23:09:38 -04:00
|
|
|
"_NET_WM_STRUT_PARTIAL", False),
|
2002-02-07 23:44:56 -05:00
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
2003-06-25 23:09:38 -04:00
|
|
|
(guchar *)vals, 12);
|
2002-02-07 23:44:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_realize_set_struts (GtkWindow *window,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2010-04-11 14:30:44 -04:00
|
|
|
GtkWidget *widget;
|
2002-02-07 23:44:56 -05:00
|
|
|
int left;
|
|
|
|
int right;
|
|
|
|
int top;
|
|
|
|
int bottom;
|
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
widget = GTK_WIDGET (window);
|
|
|
|
|
|
|
|
g_return_if_fail (gtk_widget_get_realized (widget));
|
2002-02-07 23:44:56 -05:00
|
|
|
|
|
|
|
left = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-left"));
|
|
|
|
right = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-right"));
|
|
|
|
top = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-top"));
|
|
|
|
bottom = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-bottom"));
|
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
set_gdk_window_struts (gtk_widget_get_window (widget),
|
2002-02-07 23:44:56 -05:00
|
|
|
left, right, top, bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_gtk_window_struts (GtkWidget *window,
|
|
|
|
int left,
|
|
|
|
int right,
|
|
|
|
int top,
|
|
|
|
int bottom)
|
|
|
|
{
|
2010-04-11 14:30:44 -04:00
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (window);
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
g_object_set_data (G_OBJECT (window), "meta-strut-left",
|
|
|
|
GINT_TO_POINTER (left));
|
|
|
|
g_object_set_data (G_OBJECT (window), "meta-strut-right",
|
|
|
|
GINT_TO_POINTER (right));
|
|
|
|
g_object_set_data (G_OBJECT (window), "meta-strut-top",
|
|
|
|
GINT_TO_POINTER (top));
|
|
|
|
g_object_set_data (G_OBJECT (window), "meta-strut-bottom",
|
|
|
|
GINT_TO_POINTER (bottom));
|
2010-04-11 14:30:44 -04:00
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
|
|
|
|
on_realize_set_struts,
|
|
|
|
NULL);
|
2010-04-11 14:30:44 -04:00
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
g_signal_connect_after (G_OBJECT (window),
|
|
|
|
"realize",
|
|
|
|
G_CALLBACK (on_realize_set_struts),
|
|
|
|
NULL);
|
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
if (gtk_widget_get_realized (widget))
|
|
|
|
set_gdk_window_struts (gtk_widget_get_window (widget),
|
2002-02-07 23:44:56 -05:00
|
|
|
left, right, top, bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_gdk_window_type (GdkWindow *window,
|
|
|
|
const char *type)
|
|
|
|
{
|
|
|
|
Atom atoms[2] = { None, None };
|
|
|
|
|
|
|
|
atoms[0] = XInternAtom (GDK_WINDOW_XDISPLAY (window),
|
|
|
|
type, False);
|
|
|
|
|
|
|
|
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
|
2010-12-02 09:51:36 -05:00
|
|
|
GDK_WINDOW_XID (window),
|
2002-02-07 23:44:56 -05:00
|
|
|
XInternAtom (GDK_WINDOW_XDISPLAY (window), "_NET_WM_WINDOW_TYPE", False),
|
|
|
|
XA_ATOM, 32, PropModeReplace,
|
|
|
|
(guchar *)atoms,
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_realize_set_type (GtkWindow *window,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2010-04-11 14:30:44 -04:00
|
|
|
GtkWidget *widget;
|
2002-02-07 23:44:56 -05:00
|
|
|
const char *type;
|
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
widget = GTK_WIDGET (window);
|
|
|
|
|
|
|
|
g_return_if_fail (gtk_widget_get_realized (widget));
|
2002-02-07 23:44:56 -05:00
|
|
|
|
|
|
|
type = g_object_get_data (G_OBJECT (window), "meta-window-type");
|
|
|
|
|
|
|
|
g_return_if_fail (type != NULL);
|
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
set_gdk_window_type (gtk_widget_get_window (widget),
|
2002-02-07 23:44:56 -05:00
|
|
|
type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_gtk_window_type (GtkWindow *window,
|
|
|
|
const char *type)
|
|
|
|
{
|
2010-04-11 14:30:44 -04:00
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (window);
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
g_object_set_data (G_OBJECT (window), "meta-window-type", (char*) type);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
|
|
|
|
on_realize_set_type,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect_after (G_OBJECT (window),
|
|
|
|
"realize",
|
|
|
|
G_CALLBACK (on_realize_set_type),
|
|
|
|
NULL);
|
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
if (gtk_widget_get_realized (widget))
|
|
|
|
set_gdk_window_type (gtk_widget_get_window (widget),
|
2002-02-07 23:44:56 -05:00
|
|
|
type);
|
|
|
|
}
|
|
|
|
|
2002-06-21 23:23:02 -04:00
|
|
|
static void
|
|
|
|
set_gdk_window_border_only (GdkWindow *window)
|
|
|
|
{
|
|
|
|
gdk_window_set_decorations (window, GDK_DECOR_BORDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_realize_set_border_only (GtkWindow *window,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2010-04-11 14:30:44 -04:00
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (window);
|
|
|
|
|
|
|
|
g_return_if_fail (gtk_widget_get_realized (widget));
|
2002-06-21 23:23:02 -04:00
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
set_gdk_window_border_only (gtk_widget_get_window (widget));
|
2002-06-21 23:23:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_gtk_window_border_only (GtkWindow *window)
|
|
|
|
{
|
2010-04-11 14:30:44 -04:00
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (window);
|
|
|
|
|
2002-06-21 23:23:02 -04:00
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
|
|
|
|
on_realize_set_border_only,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect_after (G_OBJECT (window),
|
|
|
|
"realize",
|
|
|
|
G_CALLBACK (on_realize_set_border_only),
|
|
|
|
NULL);
|
|
|
|
|
2010-04-11 14:30:44 -04:00
|
|
|
if (gtk_widget_get_realized (widget))
|
|
|
|
set_gdk_window_border_only (gtk_widget_get_window (widget));
|
2002-06-21 23:23:02 -04:00
|
|
|
}
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2002-02-09 18:03:52 -05:00
|
|
|
GList *list;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
GError *err;
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
2002-02-09 18:03:52 -05:00
|
|
|
err = NULL;
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 06:29:20 -04:00
|
|
|
pixbuf = gdk_pixbuf_new_from_file (MUTTER_ICON_DIR"/mutter-window-demo.png",
|
2002-02-09 18:03:52 -05:00
|
|
|
&err);
|
|
|
|
if (pixbuf)
|
|
|
|
{
|
|
|
|
list = g_list_prepend (NULL, pixbuf);
|
|
|
|
|
|
|
|
gtk_window_set_default_icon_list (list);
|
|
|
|
g_list_free (list);
|
|
|
|
g_object_unref (G_OBJECT (pixbuf));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_printerr ("Could not load icon: %s\n", err->message);
|
|
|
|
g_error_free (err);
|
|
|
|
}
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
do_appwindow ();
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-17 12:04:53 -04:00
|
|
|
response_cb (GtkDialog *dialog,
|
|
|
|
int response_id,
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
static void
|
|
|
|
make_dialog (GtkWidget *parent,
|
|
|
|
int depth)
|
2002-02-07 23:44:56 -05:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2002-10-17 12:20:50 -04:00
|
|
|
char *str;
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-10-18 02:05:09 -04:00
|
|
|
dialog = gtk_message_dialog_new (parent ? GTK_WINDOW (parent) : NULL,
|
2002-02-07 23:44:56 -05:00
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
2002-10-18 02:05:09 -04:00
|
|
|
parent ? "Here is a dialog %d" :
|
|
|
|
"Here is a dialog %d with no transient parent",
|
2002-10-17 12:04:53 -04:00
|
|
|
depth);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-10-17 12:20:50 -04:00
|
|
|
str = g_strdup_printf ("%d dialog", depth);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), str);
|
|
|
|
g_free (str);
|
|
|
|
|
2002-10-17 12:04:53 -04:00
|
|
|
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
|
|
|
"Open child dialog",
|
|
|
|
GTK_RESPONSE_ACCEPT);
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
/* Close dialog on user response */
|
|
|
|
g_signal_connect (G_OBJECT (dialog),
|
|
|
|
"response",
|
2002-10-17 12:04:53 -04:00
|
|
|
G_CALLBACK (response_cb),
|
2002-02-07 23:44:56 -05:00
|
|
|
NULL);
|
2002-10-17 12:04:53 -04:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (dialog), "depth",
|
|
|
|
GINT_TO_POINTER (depth));
|
2002-02-07 23:44:56 -05:00
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
2002-10-17 12:04:53 -04:00
|
|
|
static void
|
|
|
|
response_cb (GtkDialog *dialog,
|
|
|
|
int response_id,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
switch (response_id)
|
|
|
|
{
|
|
|
|
case GTK_RESPONSE_ACCEPT:
|
|
|
|
make_dialog (GTK_WIDGET (dialog),
|
|
|
|
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog),
|
|
|
|
"depth")) + 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
dialog_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-10-17 12:04:53 -04:00
|
|
|
{
|
|
|
|
make_dialog (GTK_WIDGET (callback_data), 1);
|
|
|
|
}
|
|
|
|
|
2002-02-08 01:22:24 -05:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
modal_dialog_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-02-08 01:22:24 -05:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (callback_data),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"Here is a MODAL dialog");
|
|
|
|
|
|
|
|
set_gtk_window_type (GTK_WINDOW (dialog), "_NET_WM_WINDOW_TYPE_MODAL_DIALOG");
|
|
|
|
|
|
|
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
2002-09-12 16:46:03 -04:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
no_parent_dialog_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-09-12 16:46:03 -04:00
|
|
|
{
|
2002-10-18 02:05:09 -04:00
|
|
|
make_dialog (NULL, 1);
|
2002-09-12 16:46:03 -04:00
|
|
|
}
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
utility_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-02-07 23:44:56 -05:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_UTILITY");
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Utility");
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (callback_data));
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_mnemonic ("_A button");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_mnemonic ("_B button");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_mnemonic ("_C button");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_mnemonic ("_D button");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
2002-04-30 23:23:46 -04:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
toolbar_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-04-30 23:23:46 -04:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_TOOLBAR");
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Toolbar");
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (callback_data));
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
label = gtk_label_new ("FIXME this needs a resize grip, etc.");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
menu_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-04-30 23:23:46 -04:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_MENU");
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Menu");
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (callback_data));
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
label = gtk_label_new ("FIXME this isn't a menu.");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
2002-05-11 00:44:34 -04:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
override_redirect_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-05-11 00:44:34 -04:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_POPUP);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Override Redirect");
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
label = gtk_label_new ("This is an override\nredirect window\nand should not be managed");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
2002-05-11 01:47:04 -04:00
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
2002-06-21 23:23:02 -04:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
border_only_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-06-21 23:23:02 -04:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
set_gtk_window_border_only (GTK_WINDOW (window));
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Border only");
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (callback_data));
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
label = gtk_label_new ("This window is supposed to have a border but no titlebar.");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
2003-06-25 23:09:38 -04:00
|
|
|
#if 0
|
2002-05-11 01:47:04 -04:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
changing_icon_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-05-11 01:47:04 -04:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Changing Icon");
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
label = gtk_label_new ("This window has an icon that changes over time");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
2002-05-11 00:44:34 -04:00
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
2003-06-25 23:09:38 -04:00
|
|
|
#endif
|
2002-05-11 00:44:34 -04:00
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
static gboolean
|
|
|
|
focus_in_event_cb (GtkWidget *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (data);
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (widget), "Has focus");
|
2003-06-25 23:09:38 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2002-02-07 23:44:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
focus_out_event_cb (GtkWidget *window,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (data);
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (widget), "Not focused");
|
2003-06-25 23:09:38 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2002-02-07 23:44:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget*
|
|
|
|
focus_label (GtkWidget *window)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
label = gtk_label_new ("Not focused");
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (window), "focus_in_event",
|
|
|
|
G_CALLBACK (focus_in_event_cb), label);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (window), "focus_out_event",
|
|
|
|
G_CALLBACK (focus_out_event_cb), label);
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
splashscreen_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-02-07 23:44:56 -05:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_SPLASHSCREEN");
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Splashscreen");
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), focus_label (window), FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
DOCK_TOP = 1,
|
|
|
|
DOCK_BOTTOM = 2,
|
|
|
|
DOCK_LEFT = 3,
|
|
|
|
DOCK_RIGHT = 4,
|
|
|
|
DOCK_ALL = 5
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
make_dock (int type)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *box;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
g_return_if_fail (type != DOCK_ALL);
|
|
|
|
|
|
|
|
box = NULL;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case DOCK_LEFT:
|
|
|
|
case DOCK_RIGHT:
|
|
|
|
box = gtk_vbox_new (FALSE, 0);
|
|
|
|
break;
|
|
|
|
case DOCK_TOP:
|
|
|
|
case DOCK_BOTTOM:
|
|
|
|
box = gtk_hbox_new (FALSE, 0);
|
|
|
|
break;
|
|
|
|
case DOCK_ALL:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_DOCK");
|
2002-02-08 01:01:58 -05:00
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
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);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), focus_label (window), FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label ("Close");
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), window);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), box);
|
|
|
|
|
|
|
|
#define DOCK_SIZE 48
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case DOCK_LEFT:
|
2003-06-25 23:09:38 -04:00
|
|
|
gtk_widget_set_size_request (window, DOCK_SIZE, 400);
|
|
|
|
gtk_window_move (GTK_WINDOW (window), 0, 000);
|
2002-02-07 23:44:56 -05:00
|
|
|
set_gtk_window_struts (window, DOCK_SIZE, 0, 0, 0);
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "LeftDock");
|
2002-02-07 23:44:56 -05:00
|
|
|
break;
|
|
|
|
case DOCK_RIGHT:
|
2003-06-25 23:09:38 -04:00
|
|
|
gtk_widget_set_size_request (window, DOCK_SIZE, 400);
|
|
|
|
gtk_window_move (GTK_WINDOW (window), gdk_screen_width () - DOCK_SIZE, 200);
|
2002-02-07 23:44:56 -05:00
|
|
|
set_gtk_window_struts (window, 0, DOCK_SIZE, 0, 0);
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "RightDock");
|
2002-02-07 23:44:56 -05:00
|
|
|
break;
|
|
|
|
case DOCK_TOP:
|
2003-06-25 23:09:38 -04:00
|
|
|
gtk_widget_set_size_request (window, 600, DOCK_SIZE);
|
|
|
|
gtk_window_move (GTK_WINDOW (window), 76, 0);
|
2002-02-07 23:44:56 -05:00
|
|
|
set_gtk_window_struts (window, 0, 0, DOCK_SIZE, 0);
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "TopDock");
|
2002-02-07 23:44:56 -05:00
|
|
|
break;
|
|
|
|
case DOCK_BOTTOM:
|
2003-06-25 23:09:38 -04:00
|
|
|
gtk_widget_set_size_request (window, 600, DOCK_SIZE);
|
|
|
|
gtk_window_move (GTK_WINDOW (window), 200, gdk_screen_height () - DOCK_SIZE);
|
2002-02-07 23:44:56 -05:00
|
|
|
set_gtk_window_struts (window, 0, 0, 0, DOCK_SIZE);
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "BottomDock");
|
2002-02-07 23:44:56 -05:00
|
|
|
break;
|
|
|
|
case DOCK_ALL:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
dock_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-02-07 23:44:56 -05:00
|
|
|
{
|
2010-06-14 06:47:12 -04:00
|
|
|
guint callback_action;
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
name = gtk_action_get_name (action);
|
|
|
|
|
|
|
|
if (!g_strcmp0 (name, "Top dock"))
|
|
|
|
callback_action = DOCK_TOP;
|
|
|
|
else if (!g_strcmp0 (name, "Bottom dock"))
|
|
|
|
callback_action = DOCK_BOTTOM;
|
|
|
|
else if (!g_strcmp0 (name, "Left dock"))
|
|
|
|
callback_action = DOCK_LEFT;
|
|
|
|
else if (!g_strcmp0 (name, "Right dock"))
|
|
|
|
callback_action = DOCK_RIGHT;
|
|
|
|
else if (!g_strcmp0 (name, "All docks"))
|
|
|
|
callback_action = DOCK_ALL;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
if (callback_action == DOCK_ALL)
|
|
|
|
{
|
|
|
|
make_dock (DOCK_TOP);
|
|
|
|
make_dock (DOCK_BOTTOM);
|
|
|
|
make_dock (DOCK_LEFT);
|
|
|
|
make_dock (DOCK_RIGHT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
make_dock (callback_action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
desktop_cb (GtkAction *action,
|
|
|
|
gpointer callback_data)
|
2002-02-07 23:44:56 -05:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *label;
|
|
|
|
GdkColor desktop_color;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_DESKTOP");
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Desktop");
|
2002-02-07 23:44:56 -05:00
|
|
|
gtk_widget_set_size_request (window,
|
|
|
|
gdk_screen_width (), gdk_screen_height ());
|
|
|
|
gtk_window_move (GTK_WINDOW (window), 0, 0);
|
|
|
|
|
|
|
|
desktop_color.red = 0x5144;
|
|
|
|
desktop_color.green = 0x75D6;
|
|
|
|
desktop_color.blue = 0xA699;
|
|
|
|
|
|
|
|
gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &desktop_color);
|
|
|
|
|
|
|
|
label = focus_label (window);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), label);
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
|
2002-04-12 19:00:46 -04:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
sleep_cb (GtkAction *action,
|
2002-04-12 19:00:46 -04:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
sleep (1000);
|
|
|
|
}
|
|
|
|
|
2003-08-08 12:25:34 -04:00
|
|
|
static void
|
2010-06-14 06:47:12 -04:00
|
|
|
toggle_aspect_ratio (GtkAction *action,
|
2003-07-27 22:09:20 -04:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GdkGeometry geom;
|
2010-06-14 06:47:12 -04:00
|
|
|
GtkWidget *widget = GTK_WIDGET (data);
|
2003-07-27 22:09:20 -04:00
|
|
|
|
|
|
|
if (aspect_on)
|
|
|
|
{
|
|
|
|
geom.min_aspect = 0;
|
|
|
|
geom.max_aspect = 65535;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geom.min_aspect = 1.777778;
|
|
|
|
geom.max_aspect = 1.777778;
|
|
|
|
}
|
|
|
|
|
|
|
|
aspect_on = !aspect_on;
|
|
|
|
|
2010-06-14 06:47:12 -04:00
|
|
|
window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
|
2003-07-27 22:09:20 -04:00
|
|
|
if (window)
|
|
|
|
gtk_window_set_geometry_hints (GTK_WINDOW (window),
|
2010-06-14 06:47:12 -04:00
|
|
|
widget,
|
2003-07-27 22:09:20 -04:00
|
|
|
&geom,
|
|
|
|
GDK_HINT_ASPECT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-08-24 17:49:32 -04:00
|
|
|
static void
|
|
|
|
toggle_decorated_cb (GtkWidget *button,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
2010-06-14 06:47:12 -04:00
|
|
|
window = gtk_widget_get_ancestor (data, GTK_TYPE_WINDOW);
|
2002-08-24 17:49:32 -04:00
|
|
|
if (window)
|
|
|
|
gtk_window_set_decorated (GTK_WINDOW (window),
|
|
|
|
!gtk_window_get_decorated (GTK_WINDOW (window)));
|
|
|
|
}
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
static void
|
2002-04-30 23:23:46 -04:00
|
|
|
clicked_toolbar_cb (GtkWidget *button,
|
|
|
|
gpointer data)
|
2002-02-07 23:44:56 -05:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (data),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"Clicking the toolbar buttons doesn't do anything");
|
|
|
|
|
|
|
|
/* Close dialog on user response */
|
|
|
|
g_signal_connect (G_OBJECT (dialog),
|
|
|
|
"response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_statusbar (GtkTextBuffer *buffer,
|
|
|
|
GtkStatusbar *statusbar)
|
|
|
|
{
|
|
|
|
gchar *msg;
|
|
|
|
gint row, col;
|
|
|
|
gint count;
|
|
|
|
GtkTextIter iter;
|
|
|
|
|
|
|
|
gtk_statusbar_pop (statusbar, 0); /* clear any previous message, underflow is allowed */
|
|
|
|
|
|
|
|
count = gtk_text_buffer_get_char_count (buffer);
|
|
|
|
|
|
|
|
gtk_text_buffer_get_iter_at_mark (buffer,
|
|
|
|
&iter,
|
|
|
|
gtk_text_buffer_get_insert (buffer));
|
|
|
|
|
|
|
|
row = gtk_text_iter_get_line (&iter);
|
|
|
|
col = gtk_text_iter_get_line_offset (&iter);
|
|
|
|
|
|
|
|
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
|
|
|
|
row, col, count);
|
|
|
|
|
|
|
|
gtk_statusbar_push (statusbar, 0, msg);
|
|
|
|
|
|
|
|
g_free (msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mark_set_callback (GtkTextBuffer *buffer,
|
|
|
|
const GtkTextIter *new_location,
|
|
|
|
GtkTextMark *mark,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
update_statusbar (buffer, GTK_STATUSBAR (data));
|
|
|
|
}
|
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
static int window_count = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_cb (GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
--window_count;
|
|
|
|
if (window_count == 0)
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
2010-06-14 06:47:12 -04:00
|
|
|
static const gchar *menu_item_string =
|
|
|
|
"<ui>\n"
|
|
|
|
"<menubar>\n"
|
|
|
|
"<menu name='Windows' action='Windows'>\n"
|
|
|
|
"<menuitem name='Dialog' action='Dialog'/>\n"
|
|
|
|
"<menuitem name='Modal dialog' action='Modal dialog'/>\n"
|
|
|
|
"<menuitem name='Parentless dialog' action='Parentless dialog'/>\n"
|
|
|
|
"<menuitem name='Utility' action='Utility'/>\n"
|
|
|
|
"<menuitem name='Splashscreen' action='Splashscreen'/>\n"
|
|
|
|
"<menuitem name='Top dock' action='Top dock'/>\n"
|
|
|
|
"<menuitem name='Bottom dock' action='Bottom dock'/>\n"
|
|
|
|
"<menuitem name='Left dock' action='Left dock'/>\n"
|
|
|
|
"<menuitem name='Right dock' action='Right dock'/>\n"
|
|
|
|
"<menuitem name='All docks' action='All docks'/>\n"
|
|
|
|
"<menuitem name='Desktop' action='Desktop'/>\n"
|
|
|
|
"<menuitem name='Menu' action='Menu'/>\n"
|
|
|
|
"<menuitem name='Toolbar' action='Toolbar'/>\n"
|
|
|
|
"<menuitem name='Override Redirect' action='Override Redirect'/>\n"
|
|
|
|
"<menuitem name='Border Only' action='Border Only'/>\n"
|
|
|
|
"</menu>\n"
|
|
|
|
"</menubar>\n"
|
|
|
|
"<toolbar>\n"
|
|
|
|
"<toolitem name='New' action='New'/>\n"
|
|
|
|
"<toolitem name='Lock' action='Lock'/>\n"
|
|
|
|
"<toolitem name='Decorations' action='Decorations'/>\n"
|
|
|
|
"<toolitem name='Ratio' action='Ratio'/>\n"
|
|
|
|
"<toolitem name='Quit' action='Quit'/>\n"
|
|
|
|
"</toolbar>\n"
|
|
|
|
"</ui>\n";
|
|
|
|
|
|
|
|
static const GtkActionEntry menu_items[] =
|
2009-08-25 21:31:57 -04:00
|
|
|
{
|
2010-06-14 06:47:12 -04:00
|
|
|
{ "Windows", NULL, "_Windows", NULL,
|
|
|
|
NULL, NULL },
|
|
|
|
{ "Dialog", NULL, "_Dialog", "<control>d",
|
|
|
|
NULL, G_CALLBACK (dialog_cb) },
|
|
|
|
{ "Modal dialog", NULL, "_Modal dialog", NULL,
|
|
|
|
NULL, G_CALLBACK (modal_dialog_cb) },
|
|
|
|
{ "Parentless dialog", NULL, "_Parentless dialog", NULL,
|
|
|
|
NULL, G_CALLBACK (no_parent_dialog_cb) },
|
|
|
|
{ "Utility", NULL, "_Utility", "<control>u",
|
|
|
|
NULL, G_CALLBACK (utility_cb) },
|
|
|
|
{ "Splashscreen", NULL, "_Splashscreen", "<control>s",
|
|
|
|
NULL, G_CALLBACK (splashscreen_cb) },
|
|
|
|
{ "Top dock", NULL, "_Top dock", NULL,
|
|
|
|
NULL, G_CALLBACK (dock_cb) },
|
|
|
|
{ "Bottom dock", NULL, "_Bottom dock", NULL,
|
|
|
|
NULL, G_CALLBACK (dock_cb) },
|
|
|
|
{ "Left dock", NULL, "_Left dock", NULL,
|
|
|
|
NULL, G_CALLBACK (dock_cb) },
|
|
|
|
{ "Right dock", NULL, "_Right dock", NULL,
|
|
|
|
NULL, G_CALLBACK (dock_cb) },
|
|
|
|
{ "All docks", NULL, "_All docks", NULL,
|
|
|
|
NULL, G_CALLBACK (dock_cb) },
|
|
|
|
{ "Desktop", NULL, "Des_ktop", NULL,
|
|
|
|
NULL, G_CALLBACK (desktop_cb) },
|
|
|
|
{ "Menu", NULL, "Me_nu", NULL,
|
|
|
|
NULL, G_CALLBACK (menu_cb) },
|
|
|
|
{ "Toolbar", NULL, "Tool_bar", NULL,
|
|
|
|
NULL, G_CALLBACK (toolbar_cb) },
|
|
|
|
{ "Override Redirect", NULL, "Override Redirect", NULL,
|
|
|
|
NULL, G_CALLBACK (override_redirect_cb) },
|
|
|
|
{ "Border Only", NULL, "Border Only", NULL,
|
|
|
|
NULL, G_CALLBACK (border_only_cb) }
|
|
|
|
};
|
2009-08-25 21:31:57 -04:00
|
|
|
|
2010-06-14 06:47:12 -04:00
|
|
|
static const GtkActionEntry tool_items[] =
|
|
|
|
{
|
|
|
|
{ "New", GTK_STOCK_NEW, NULL, NULL,
|
|
|
|
"Open another one of these windows", G_CALLBACK (do_appwindow) },
|
|
|
|
{ "Lock", GTK_STOCK_OPEN, NULL, NULL,
|
|
|
|
"This is a demo button that"
|
|
|
|
" locks up the demo", G_CALLBACK (sleep_cb) },
|
|
|
|
{ "Decorations", GTK_STOCK_OPEN, NULL, NULL,
|
|
|
|
"This is a demo button that "
|
|
|
|
"toggles window decorations", G_CALLBACK (toggle_decorated_cb) },
|
|
|
|
{ "Quit", GTK_STOCK_QUIT, NULL, NULL,
|
|
|
|
"This is a demo button with "
|
|
|
|
" a 'quit' icon", G_CALLBACK (clicked_toolbar_cb) },
|
|
|
|
{ "Ratio", GTK_STOCK_OPEN, NULL, NULL,
|
|
|
|
"This is a demo button that locks the aspect ratio "
|
|
|
|
"using a hint", G_CALLBACK (toggle_aspect_ratio) }
|
|
|
|
};
|
2009-08-25 21:31:57 -04:00
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
static GtkWidget *
|
|
|
|
do_appwindow (void)
|
|
|
|
{
|
2002-02-08 01:01:58 -05:00
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *handlebox;
|
|
|
|
GtkWidget *statusbar;
|
|
|
|
GtkWidget *contents;
|
|
|
|
GtkWidget *sw;
|
|
|
|
GtkTextBuffer *buffer;
|
2010-06-14 06:47:12 -04:00
|
|
|
GtkActionGroup *action_group;
|
|
|
|
GtkUIManager *ui_manager;
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
/* Create the toplevel window
|
|
|
|
*/
|
|
|
|
|
|
|
|
++window_count;
|
2003-07-27 22:09:20 -04:00
|
|
|
|
|
|
|
aspect_on = FALSE;
|
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
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);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
table = gtk_table_new (1, 4, FALSE);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), table);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
/* Create the menubar
|
|
|
|
*/
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2010-06-14 06:47:12 -04:00
|
|
|
contents = gtk_text_view_new ();
|
2002-02-08 01:01:58 -05:00
|
|
|
|
2010-06-14 06:47:12 -04:00
|
|
|
action_group = gtk_action_group_new ("mainmenu");
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
menu_items,
|
|
|
|
G_N_ELEMENTS (menu_items),
|
|
|
|
window);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
tool_items,
|
|
|
|
G_N_ELEMENTS (tool_items),
|
|
|
|
window);
|
|
|
|
|
|
|
|
ui_manager = gtk_ui_manager_new ();
|
|
|
|
|
|
|
|
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
|
2002-02-08 01:01:58 -05:00
|
|
|
|
|
|
|
/* create menu items */
|
2010-06-14 06:47:12 -04:00
|
|
|
|
|
|
|
gtk_ui_manager_add_ui_from_string (ui_manager, menu_item_string, -1, NULL);
|
2002-02-08 01:01:58 -05:00
|
|
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table),
|
2010-06-14 06:47:12 -04:00
|
|
|
gtk_ui_manager_get_widget (ui_manager, "/ui/menubar"),
|
2002-02-08 01:01:58 -05:00
|
|
|
/* X direction */ /* Y direction */
|
|
|
|
0, 1, 0, 1,
|
|
|
|
GTK_EXPAND | GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
2003-07-27 22:09:20 -04:00
|
|
|
/* 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);
|
|
|
|
|
|
|
|
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_window_set_default_size (GTK_WINDOW (window),
|
|
|
|
200, 200);
|
|
|
|
|
|
|
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
|
|
|
|
PANGO_WRAP_WORD);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (sw),
|
|
|
|
contents);
|
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
/* Create the toolbar
|
|
|
|
*/
|
|
|
|
|
|
|
|
handlebox = gtk_handle_box_new ();
|
|
|
|
|
2010-06-14 06:47:12 -04:00
|
|
|
gtk_container_add (GTK_CONTAINER (handlebox),
|
|
|
|
gtk_ui_manager_get_widget (ui_manager, "/ui/toolbar"));
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_table_attach (GTK_TABLE (table),
|
|
|
|
handlebox,
|
|
|
|
/* X direction */ /* Y direction */
|
|
|
|
0, 1, 1, 2,
|
|
|
|
GTK_EXPAND | GTK_FILL, 0,
|
|
|
|
0, 0);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
/* 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);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
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);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
update_statusbar (buffer, GTK_STATUSBAR (statusbar));
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
gtk_widget_show_all (window);
|
2002-02-07 23:44:56 -05:00
|
|
|
|
2010-06-14 06:47:12 -04:00
|
|
|
g_object_unref (ui_manager);
|
|
|
|
|
2002-02-07 23:44:56 -05:00
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|