Commit 072df93b authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

tools: remove window demo

parent fc403da3
......@@ -208,10 +208,6 @@ Debugging information
work--but if you disable the keybindings for the global Metacity then
the Metacity under the Xnest can then get those keybinding notifications).
metacity-window-demo
metacity-window-demo is good for trying behavior of various kinds
of window without launching a full desktop.
Technical gotchas to keep in mind
Files that include gdk.h or gtk.h are not supposed to include
display.h or window.h or other core files. Files in the core
......
......@@ -175,7 +175,6 @@ AC_ARG_ENABLE(render,
## here we get the flags we'll actually use
PKG_CHECK_MODULES(ALL, glib-2.0 >= $GLIB_REQUIRED_VERSION gthread-2.0 >= $GLIB_REQUIRED_VERSION)
PKG_CHECK_MODULES(METACITY_MESSAGE, gtk+-3.0 >= $GTK_REQUIRED_VERSION)
PKG_CHECK_MODULES(METACITY_WINDOW_DEMO, gtk+-3.0 >= $GTK_REQUIRED_VERSION)
# Unconditionally use this dir to avoid a circular dep with gnomecc
GNOME_KEYBINDINGS_KEYSDIR="${datadir}/gnome-control-center/keybindings"
......@@ -294,7 +293,6 @@ fi
METACITY_LIBS="$ALL_LIBS $METACITY_LIBS $RANDR_LIBS -lX11 -lXext $X_EXTRA_LIBS $LIBM"
METACITY_MESSAGE_LIBS="$METACITY_MESSAGE_LIBS -lX11 $X_EXTRA_LIBS"
METACITY_WINDOW_DEMO_LIBS="$METACITY_WINDOW_DEMO_LIBS -lX11 $X_EXTRA_LIBS $LIBM"
METACITY_PROPS_LIBS="$METACITY_PROPS_LIBS -lX11 $X_EXTRA_LIBS"
found_sm=no
......
man_MANS = metacity.1 metacity-theme-viewer.1 \
metacity-window-demo.1 metacity-message.1
NULL =
man_MANS = \
metacity.1 \
metacity-message.1 \
metacity-theme-viewer.1 \
$(NULL)
EXTRA_DIST = $(man_MANS)
......
......@@ -39,5 +39,4 @@ This manual page was written by Jose M. Moya <josem@die.upm.es>, for
the Debian GNU/Linux system (but may be used by others).
.SH "SEE ALSO"
.\" Always quote multiple words for .SH
.BR metacity (1),
.BR metacity-window-demo (1).
.BR metacity (1).
.\" In .TH, FOO should be all caps, SECTION should be 1-8, maybe w/ subsection
.\" other parms are allowed: see man(7), man(1)
.\"
.\" Based on template provided by Tom Christiansen <tchrist@jhereg.perl.com>.
.\"
.TH METACITY-WINDOW-DEMO 1 "1 June 2004"
.SH NAME
metacity-window-demo \- demo of window features
.SH SYNOPSIS
.B metacity-window-demo
.SH DESCRIPTION
.\" Putting a newline after each sentence can generate better output.
This program demonstrates various kinds of windows that window
managers and window manager themes should handle.
.PP
Be sure to tear off the menu and toolbar, those are also a special
kind of window.
.SH AUTHOR
This manual page was written by Jose M. Moya <josem@die.upm.es>, for
the Debian GNU/Linux system (but may be used by others).
.SH "SEE ALSO"
.\" Always quote multiple words for .SH
.BR x-window-manager (1),
.BR metacity (1),
.BR metacity-theme-viewer (1).
NULL =
icondir=$(pkgdatadir)/icons
icon_DATA=metacity-window-demo.png
bin_PROGRAMS = metacity-message
AM_CPPFLAGS=@METACITY_WINDOW_DEMO_CFLAGS@ @METACITY_MESSAGE_CFLAGS@ \
metacity_message_CFLAGS = \
-DMETACITY_ICON_DIR=\"$(pkgdatadir)/icons\" \
-DMETACITY_LOCALEDIR=\""$(localedir)"\" \
$(METACITY_MESSAGE_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
$(NULL)
metacity_message_SOURCES= \
metacity-message.c
metacity_window_demo_SOURCES= \
metacity-window-demo.c
bin_PROGRAMS=metacity-message metacity-window-demo
metacity_message_SOURCES = \
metacity-message.c \
$(NULL)
metacity_message_LDADD= @METACITY_MESSAGE_LIBS@
metacity_window_demo_LDADD= @METACITY_WINDOW_DEMO_LIBS@
metacity_message_LDADD = \
$(METACITY_MESSAGE_LIBS) \
$(NULL)
EXTRA_DIST=$(icon_DATA)
......
/* Metacity window types/properties demo 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, see <http://www.gnu.org/licenses/>.
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
#include <unistd.h>
static void
do_appwindow (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
static gboolean aspect_on;
static void
set_gdk_window_struts (GdkWindow *window,
int left,
int right,
int top,
int bottom)
{
long vals[12];
vals[0] = left;
vals[1] = right;
vals[2] = top;
vals[3] = bottom;
vals[4] = 000;
vals[5] = 400;
vals[6] = 200;
vals[7] = 600;
vals[8] = 76;
vals[9] = 676;
vals[10] = 200;
vals[11] = 800;
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
XInternAtom (GDK_WINDOW_XDISPLAY (window),
"_NET_WM_STRUT_PARTIAL", False),
XA_CARDINAL, 32, PropModeReplace,
(guchar *)vals, 12);
}
static void
on_realize_set_struts (GtkWindow *window,
gpointer data)
{
GtkWidget *widget;
int left;
int right;
int top;
int bottom;
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_realized (widget));
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"));
set_gdk_window_struts (gtk_widget_get_window (widget),
left, right, top, bottom);
}
static void
set_gtk_window_struts (GtkWidget *window,
int left,
int right,
int top,
int bottom)
{
GtkWidget *widget;
widget = GTK_WIDGET (window);
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));
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
on_realize_set_struts,
NULL);
g_signal_connect_after (G_OBJECT (window),
"realize",
G_CALLBACK (on_realize_set_struts),
NULL);
if (gtk_widget_get_realized (widget))
set_gdk_window_struts (gtk_widget_get_window (widget),
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),
GDK_WINDOW_XID (window),
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)
{
GtkWidget *widget;
const char *type;
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_realized (widget));
type = g_object_get_data (G_OBJECT (window), "meta-window-type");
g_return_if_fail (type != NULL);
set_gdk_window_type (gtk_widget_get_window (widget),
type);
}
static void
set_gtk_window_type (GtkWindow *window,
const char *type)
{
GtkWidget *widget;
widget = GTK_WIDGET (window);
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);
if (gtk_widget_get_realized (widget))
set_gdk_window_type (gtk_widget_get_window (widget),
type);
}
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)
{
GtkWidget *widget;
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_realized (widget));
set_gdk_window_border_only (gtk_widget_get_window (widget));
}
static void
set_gtk_window_border_only (GtkWindow *window)
{
GtkWidget *widget;
widget = GTK_WIDGET (window);
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);
if (gtk_widget_get_realized (widget))
set_gdk_window_border_only (gtk_widget_get_window (widget));
}
int
main (int argc, char **argv)
{
GList *list;
GdkPixbuf *pixbuf;
GError *err;
gtk_init (&argc, &argv);
err = NULL;
pixbuf = gdk_pixbuf_new_from_file (METACITY_ICON_DIR"/metacity-window-demo.png",
&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);
}
do_appwindow (NULL, NULL, NULL);
gtk_main ();
return 0;
}
static void
response_cb (GtkDialog *dialog,
int response_id,
void *data);
static void
make_dialog (GtkWidget *parent,
int depth)
{
GtkWidget *dialog;
char *str;
dialog = gtk_message_dialog_new (parent ? GTK_WINDOW (parent) : NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
parent ? "Here is a dialog %d" :
"Here is a dialog %d with no transient parent",
depth);
str = g_strdup_printf ("%d dialog", depth);
gtk_window_set_title (GTK_WINDOW (dialog), str);
g_free (str);
gtk_dialog_add_button (GTK_DIALOG (dialog),
"Open child dialog",
GTK_RESPONSE_ACCEPT);
/* Close dialog on user response */
g_signal_connect (G_OBJECT (dialog),
"response",
G_CALLBACK (response_cb),
NULL);
g_object_set_data (G_OBJECT (dialog), "depth",
GINT_TO_POINTER (depth));
gtk_widget_show (dialog);
}
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
dialog_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
make_dialog (GTK_WIDGET (callback_data), 1);
}
static void
modal_dialog_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
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);
}
static void
no_parent_dialog_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
make_dialog (NULL, 1);
}
static void
utility_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
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");
gtk_window_set_title (GTK_WINDOW (window), "Utility");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (callback_data));
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 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);
}
static void
toolbar_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
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_box_new (GTK_ORIENTATION_VERTICAL, 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
menu_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
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_box_new (GTK_ORIENTATION_VERTICAL, 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);
}
static void
override_redirect_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *label;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_title (GTK_WINDOW (window), "Override Redirect");
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 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);
gtk_widget_show_all (window);
}
static void
border_only_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
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_box_new (GTK_ORIENTATION_VERTICAL, 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);
}
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");
return TRUE;
}
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");
return TRUE;
}
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
splashscreen_cb (GSimpleAction *action,
GVariant *parameter,
gpointer callback_data)
{
GtkWidget *window;
GtkWidget *image;
GtkWidget *vbox;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_SPLASH");
gtk_window_set_title (GTK_WINDOW (window), "Splashscreen");
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
image = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
gtk_box_pack_start (