metacity r4163 - in trunk: . src src/core src/include src/ui



Author: tthurman
Date: Fri Feb 20 19:48:04 2009
New Revision: 4163
URL: http://svn.gnome.org/viewvc/metacity?rev=4163&view=rev

Log:
	Use zenity for the session management dialogue that warns about
	clueless clients, not metacity-dialog.  This is the last change
	away from metacity-dialog and therefore closes #521914.
	* src/Makefile.am:
	* src/core/session.c:
	* src/core/util.c:
	* src/include/util.h:
	* src/ui/metacity-dialog.c (deleted):



Removed:
   trunk/src/ui/metacity-dialog.c
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/core/session.c
   trunk/src/core/util.c
   trunk/src/include/util.h

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Fri Feb 20 19:48:04 2009
@@ -134,9 +134,6 @@
 metacity_theme_viewer_SOURCES=  \
 	ui/theme-viewer.c
 
-metacity_dialog_SOURCES= 	\
-	ui/metacity-dialog.c
-
 schema_bindings_SOURCES =       \
         core/schema-bindings.c			\
 	metacity.schemas.in.in
@@ -147,12 +144,10 @@
 	${builddir}/schema_bindings ${srcdir}/metacity.schemas.in.in ${builddir}/metacity.schemas.in
 
 bin_PROGRAMS=metacity metacity-theme-viewer
-libexec_PROGRAMS=metacity-dialog
 
 EFENCE=
 metacity_LDADD= METACITY_LIBS@ $(EFENCE)
 metacity_theme_viewer_LDADD= @METACITY_LIBS@ libmetacity-private.la
-metacity_dialog_LDADD= METACITY_LIBS@
 
 testboxes_SOURCES=include/util.h core/util.c include/boxes.h core/boxes.c core/testboxes.c
 testgradient_SOURCES=ui/gradient.h ui/gradient.c ui/testgradient.c

Modified: trunk/src/core/session.c
==============================================================================
--- trunk/src/core/session.c	(original)
+++ trunk/src/core/session.c	Fri Feb 20 19:48:04 2009
@@ -1731,13 +1731,6 @@
   return g_utf8_collate (a->title, b->title);
 }
 
-typedef struct
-{
-  int child_pid;
-  int child_pipe;
-  gboolean shutdown;
-} LameClientsDialogData;
-
 static void
 finish_interact (gboolean shutdown)
 {
@@ -1749,63 +1742,26 @@
     }
 }
 
-static gboolean  
-io_from_warning_dialog (GIOChannel   *channel,
-                        GIOCondition  condition,
-                        gpointer      data)
+static void
+sigchld_handler (MetaNexus *nexus, guint arg1, gpointer arg2, gpointer user_data)
 {
-  LameClientsDialogData *d;
-
-  d = data;
-  
-  meta_topic (META_DEBUG_PING,
-              "IO handler from lame clients dialog, condition = %x\n",
-              condition);
-  
-  if (condition & (G_IO_HUP | G_IO_NVAL | G_IO_ERR))
-    {
-      finish_interact (d->shutdown);
+  gboolean shutdown = GPOINTER_TO_INT (user_data);
 
-      /* Remove the callback, freeing data */
-      return FALSE; 
-    }
-  else if (condition & G_IO_IN)
+  if (arg1 == 0) /* pressed "OK" */
     {
-      /* Check for EOF */
-      
-      char buf[16];
-      int ret;
- 
-      ret = read (d->child_pipe, buf, sizeof (buf));
-      if (ret == 0)
- 	{
- 	  finish_interact (d->shutdown);
- 	  return FALSE;
- 	}
+      finish_interact (shutdown);
     }
-
-  /* Keep callback installed */
-  return TRUE;
 }
 
 static void
 warn_about_lame_clients_and_finish_interact (gboolean shutdown)
 {
-  GSList *lame;
+  GSList *lame = NULL;
   GSList *windows;
-  char **argv;
-  int i;
+  GSList *lame_details = NULL;
   GSList *tmp;
-  int len;
-  int child_pid;
-  int child_pipe;
-  GError *err;
-  GIOChannel *channel;
-  LameClientsDialogData *d;
-  guint32 timestamp;
-  char timestampbuf[32];
+  GSList *columns = NULL;
   
-  lame = NULL;
   windows = meta_display_list_windows (meta_get_display ());
   tmp = windows;
   while (tmp != NULL)
@@ -1832,77 +1788,43 @@
       finish_interact (shutdown);
       return;
     }
-  
-  lame = g_slist_sort (lame, (GCompareFunc) windows_cmp_by_title);
 
-  timestamp = meta_display_get_current_time_roundtrip (meta_get_display ());
-  sprintf (timestampbuf, "%u", timestamp);
+  columns = g_slist_prepend (columns, "Window");
+  columns = g_slist_prepend (columns, "Class");
 
-  len = g_slist_length (lame);
-  len *= 2; /* titles and also classes */
-  len += 2; /* --timestamp flag and actual timestamp */
-  len += 1; /* NULL term */
-  len += 2; /* metacity-dialog command and option */
-  
-  argv = g_new0 (char*, len);
-  
-  i = 0;
+  lame = g_slist_sort (lame, (GCompareFunc) windows_cmp_by_title);
 
-  argv[i] = METACITY_LIBEXECDIR"/metacity-dialog";
-  ++i;
-  argv[i] = "--timestamp";
-  ++i;
-  argv[i] = timestampbuf;
-  ++i;
-  argv[i] = "--warn-about-no-sm-support";
-  ++i;
-  
   tmp = lame;
   while (tmp != NULL)
     {
       MetaWindow *w = tmp->data;
 
-      argv[i] = w->title;
-      ++i;
-      argv[i] = w->res_class ? w->res_class : "";
-      ++i;
+      lame_details = g_slist_prepend (lame_details,
+                                      w->res_class ? w->res_class : "");
+      lame_details = g_slist_prepend (lame_details,
+                                      w->title);
 
       tmp = tmp->next;
     }
-
-  child_pipe = -1;
-  child_pid = -1;
-  err = NULL;
-  if (!g_spawn_async_with_pipes ("/",
-                                 argv,
-                                 NULL,
-                                 0,
-                                 NULL, NULL,
-                                 &child_pid,
-                                 NULL,
-                                 &child_pipe,
-                                 NULL,
-                                 &err))
-    {
-      meta_warning (_("Error launching metacity-dialog to warn about apps that don't support session management: %s\n"),
-                    err->message);
-      g_error_free (err);
-    }
-
-  g_free (argv);
   g_slist_free (lame);
 
-  d = g_new0 (LameClientsDialogData, 1);
-  d->child_pipe = child_pipe;
-  d->child_pid = child_pid;
-  d->shutdown = shutdown;
-  
-  channel = g_io_channel_unix_new (d->child_pipe);
-  g_io_add_watch_full (channel, G_PRIORITY_DEFAULT,
-                       G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-                       io_from_warning_dialog,
-                       d, g_free);
-  g_io_channel_unref (channel);
+  meta_show_dialog("--list",
+                   _("These windows do not support "save current setup" "
+                     "and will have to be restarted manually next time "
+                     "you log in."),
+                   "240",
+                   meta_screen_get_screen_number (meta_get_display()->active_screen),
+                   NULL, NULL,
+                   None,
+                   columns,
+                   lame_details);
+
+  g_slist_free (lame_details);
+
+  g_signal_connect (sigchld_nexus, "sigchld",
+                    G_CALLBACK (sigchld_handler),
+                    GINT_TO_POINTER (shutdown));
+
 }
 
 #endif /* HAVE_SM */

Modified: trunk/src/core/util.c
==============================================================================
--- trunk/src/core/util.c	(original)
+++ trunk/src/core/util.c	Fri Feb 20 19:48:04 2009
@@ -548,29 +548,18 @@
                   const char *ok_text,
                   const char *cancel_text,
                   const int transient_for,
-                  const char **columns,
-                  const char **entries)
+                  GSList *columns,
+                  GSList *entries)
 {
   GError *error = NULL;
   char *screen_number_text = g_strdup_printf("%d", screen_number);
-
-  /*
-  We want:
-  
-zenity --display X --screen S --title Metacity --error --text "There was an error running <tt>terminal</tt>:\n\nYour computer is on fire."
-  ** with no pipes
-  
-zenity --display X --screen S --title Metacity --question --text "<big><b><tt>%s</tt> is not responding.</b></big>\n\n<i>You may choose to wait a short while for it to continue or force the application to quit entirely.</i>"
-
-zenity --display X --screen S --title Metacity --list --timeout 240 --text "These windows do not support \"save current setup\" and will have to be restarted manually next time you log in." --column "Window" --column "Class" "Firefox" "foo" "Duke Nukem Forever" "bar"
-  */
-
-  const char **argvl;
-  char **envl;
+  GSList *tmp;
   int i=0;
   GPid child_pid;
-
-  argvl = g_malloc(sizeof (char*) * 15);
+  const char **argvl = g_malloc(sizeof (char*) *
+                                (15 +
+                                 g_slist_length (columns)*2 +
+                                 g_slist_length (entries)));
 
   argvl[i++] = "zenity";
   argvl[i++] = type;
@@ -594,22 +583,35 @@
       argvl[i++] = ok_text;
      }
 
-   if (cancel_text)
+  if (cancel_text)
     {
       argvl[i++] = "--cancel-label";
       argvl[i++] = cancel_text;
-     }
+    }
+  
+  tmp = columns;
+  while (tmp)
+    {
+      argvl[i++] = "--column";
+      argvl[i++] = tmp->data;
+      tmp = tmp->next;
+    }
 
+  tmp = entries;
+  while (tmp)
+    {
+      argvl[i++] = tmp->data;
+      tmp = tmp->next;
+    }
+    
   argvl[i] = NULL;
 
   if (transient_for)
     {
-        gchar *env = g_strdup_printf("%d", transient_for);
-        setenv ("WINDOWID", env, 1);
-        g_free (env);
+      gchar *env = g_strdup_printf("%d", transient_for);
+      setenv ("WINDOWID", env, 1);
+      g_free (env);
     }
-  else
-    envl = NULL;
 
   g_spawn_async (
                  "/",
@@ -621,6 +623,9 @@
                  &error
                  );
 
+  if (transient_for)
+    unsetenv ("WINDOWID");
+
   g_free (argvl);
   g_free (screen_number_text);
 

Modified: trunk/src/include/util.h
==============================================================================
--- trunk/src/include/util.h	(original)
+++ trunk/src/include/util.h	Fri Feb 20 19:48:04 2009
@@ -105,8 +105,8 @@
                        const char *ok_text,
                        const char *cancel_text,
                        const int transient_for,
-                       const char **columns,
-                       const char **entries);
+                       GSList *columns,
+                       GSList *entries);
 
 /* To disable verbose mode, we make these functions into no-ops */
 #ifdef WITH_VERBOSE_MODE



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]