mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
make one of the toolbar buttons lock up the demo
2002-04-12 Havoc Pennington <hp@redhat.com> * src/tools/metacity-window-demo.c (do_appwindow): make one of the toolbar buttons lock up the demo * src/window.c (meta_window_delete): move error trap to be around a narrower part of the function, and add part of the ping stuff, nothing user-visible yet * src/metacity-dialog.c (main): metacity-dialog executable to live in libexecdir and pop up dialogs for us.
This commit is contained in:
parent
38ff6a49c4
commit
f965726d15
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2002-04-12 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* src/tools/metacity-window-demo.c (do_appwindow): make one of the
|
||||||
|
toolbar buttons lock up the demo
|
||||||
|
|
||||||
|
* src/window.c (meta_window_delete): move error trap to be around
|
||||||
|
a narrower part of the function, and add part of the ping stuff,
|
||||||
|
nothing user-visible yet
|
||||||
|
|
||||||
|
* src/metacity-dialog.c (main): metacity-dialog executable to
|
||||||
|
live in libexecdir and pop up dialogs for us.
|
||||||
|
|
||||||
2002-04-09 Havoc Pennington <hp@pobox.com>
|
2002-04-09 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
* src/theme.c (multiply_alpha): fix alpha multiplication routine
|
* src/theme.c (multiply_alpha): fix alpha multiplication routine
|
||||||
|
@ -76,10 +76,15 @@ metacity_theme_viewer_SOURCES= \
|
|||||||
util.c \
|
util.c \
|
||||||
util.h
|
util.h
|
||||||
|
|
||||||
|
metacity_dialog_SOURCES= \
|
||||||
|
metacity-dialog.c
|
||||||
|
|
||||||
bin_PROGRAMS=metacity metacity-theme-viewer
|
bin_PROGRAMS=metacity metacity-theme-viewer
|
||||||
|
libexec_PROGRAMS=metacity-dialog
|
||||||
|
|
||||||
metacity_LDADD= @METACITY_LIBS@
|
metacity_LDADD= @METACITY_LIBS@
|
||||||
metacity_theme_viewer_LDADD= @METACITY_LIBS@
|
metacity_theme_viewer_LDADD= @METACITY_LIBS@
|
||||||
|
metacity_dialog_LDADD=@METACITY_LIBS@
|
||||||
|
|
||||||
testgradient_SOURCES=gradient.h gradient.c testgradient.c
|
testgradient_SOURCES=gradient.h gradient.c testgradient.c
|
||||||
|
|
||||||
|
90
src/metacity-dialog.c
Normal file
90
src/metacity-dialog.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/* Metacity dialog process */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <libintl.h>
|
||||||
|
#define _(x) dgettext (GETTEXT_PACKAGE, x)
|
||||||
|
#define N_(x) x
|
||||||
|
|
||||||
|
static int
|
||||||
|
kill_window_question (const char *window_name)
|
||||||
|
{
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
|
dialog = gtk_message_dialog_new (NULL, 0,
|
||||||
|
GTK_MESSAGE_QUESTION,
|
||||||
|
GTK_BUTTONS_NONE,
|
||||||
|
_("The window \"%s\" is not responding.\n"
|
||||||
|
"Force this application to exit?"),
|
||||||
|
window_name);
|
||||||
|
|
||||||
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||||
|
GTK_STOCK_CANCEL,
|
||||||
|
GTK_RESPONSE_REJECT,
|
||||||
|
_("Kill application"),
|
||||||
|
GTK_RESPONSE_ACCEPT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
|
||||||
|
|
||||||
|
/* return 0 if we should kill the application */
|
||||||
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
|
g_print ("Y");
|
||||||
|
else
|
||||||
|
g_print ("N");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
bindtextdomain (GETTEXT_PACKAGE, METACITY_LOCALEDIR);
|
||||||
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
g_printerr ("bad args to metacity-dialog\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp (argv[1], "--kill-window-question") == 0)
|
||||||
|
{
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
g_printerr ("bad args to metacity-dialog\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return kill_window_question (argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_printerr ("bad args to metacity-dialog\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
@ -22,6 +22,7 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
static GtkWidget* do_appwindow (void);
|
static GtkWidget* do_appwindow (void);
|
||||||
|
|
||||||
@ -472,6 +473,13 @@ static GtkItemFactoryEntry menu_items[] =
|
|||||||
{ "/Windows/Des_ktop", NULL, desktop_cb, 0, NULL }
|
{ "/Windows/Des_ktop", NULL, desktop_cb, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
sleep_cb (GtkWidget *button,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
sleep (1000);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toolbar_cb (GtkWidget *button,
|
toolbar_cb (GtkWidget *button,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -611,9 +619,9 @@ do_appwindow (void)
|
|||||||
|
|
||||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||||
GTK_STOCK_OPEN,
|
GTK_STOCK_OPEN,
|
||||||
"This is a demo button with an 'open' icon",
|
"This is a demo button that locks up the demo",
|
||||||
NULL,
|
NULL,
|
||||||
G_CALLBACK (toolbar_cb),
|
G_CALLBACK (sleep_cb),
|
||||||
window, /* user data for callback */
|
window, /* user data for callback */
|
||||||
-1); /* -1 means "append" */
|
-1); /* -1 means "append" */
|
||||||
|
|
||||||
|
65
src/window.c
65
src/window.c
@ -2483,6 +2483,61 @@ meta_window_get_outer_rect (MetaWindow *window,
|
|||||||
*rect = window->rect;
|
*rect = window->rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_ping_reply_func (MetaDisplay *display,
|
||||||
|
Window xwindow,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
MetaWindow *window = user_data;
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_PING,
|
||||||
|
"Got reply to delete ping for %s\n",
|
||||||
|
window->desc);
|
||||||
|
|
||||||
|
/* we do nothing */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_ping_timeout_func (MetaDisplay *display,
|
||||||
|
Window xwindow,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
MetaWindow *window = user_data;
|
||||||
|
GError *err;
|
||||||
|
int child_pid;
|
||||||
|
int outpipe;
|
||||||
|
char *argv[4];
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_PING,
|
||||||
|
"Got delete ping timeout for %s\n",
|
||||||
|
window->desc);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
argv[0] = METACITY_LIBEXECDIR"/metacity-dialog";
|
||||||
|
argv[1] = "--kill-window-question";
|
||||||
|
argv[2] = window->title;
|
||||||
|
argv[3] = NULL;
|
||||||
|
|
||||||
|
err = NULL;
|
||||||
|
if (!g_spawn_async_with_pipes ("/",
|
||||||
|
argv,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL, NULL,
|
||||||
|
&child_pid,
|
||||||
|
NULL,
|
||||||
|
&outpipe,
|
||||||
|
NULL,
|
||||||
|
&err))
|
||||||
|
{
|
||||||
|
meta_warning (_("Error launching metacity-dialog to ask about killing an application: %s\n"),
|
||||||
|
err->message);
|
||||||
|
g_error_free (err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_delete (MetaWindow *window,
|
meta_window_delete (MetaWindow *window,
|
||||||
Time timestamp)
|
Time timestamp)
|
||||||
@ -2504,6 +2559,14 @@ meta_window_delete (MetaWindow *window,
|
|||||||
window->desc);
|
window->desc);
|
||||||
XKillClient (window->display->xdisplay, window->xwindow);
|
XKillClient (window->display->xdisplay, window->xwindow);
|
||||||
}
|
}
|
||||||
|
meta_error_trap_pop (window->display);
|
||||||
|
|
||||||
|
meta_display_ping_window (window->display,
|
||||||
|
window,
|
||||||
|
timestamp,
|
||||||
|
delete_ping_reply_func,
|
||||||
|
delete_ping_timeout_func,
|
||||||
|
window);
|
||||||
|
|
||||||
if (window->has_focus)
|
if (window->has_focus)
|
||||||
{
|
{
|
||||||
@ -2522,8 +2585,6 @@ meta_window_delete (MetaWindow *window,
|
|||||||
"Window %s was deleted/killed but didn't have focus\n",
|
"Window %s was deleted/killed but didn't have focus\n",
|
||||||
window->desc);
|
window->desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_error_trap_pop (window->display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user