Author: kelnos
Date: 2008-10-22 10:23:52 +0000 (Wed, 22 Oct 2008)
New Revision: 28357

Modified:
   libexo/trunk/ChangeLog
   libexo/trunk/NEWS
   libexo/trunk/configure.in.in
   libexo/trunk/exo-helper/exo-helper-chooser-dialog.c
   libexo/trunk/exo-helper/exo-helper-chooser-dialog.h
   libexo/trunk/exo-helper/exo-preferred-applications.desktop.in
   libexo/trunk/exo-helper/exo-preferred-applications.in
   libexo/trunk/exo-helper/main.c
Log:
        * configure.in.in: Add 'svn' version tag.
        * exo-helper/exo-helper-chooser-dialog.[ch]: Add function to
          retrieve the toplevel container beneath the GtkDialog's
          GtkVBox.
        * exo-helper/exo-preferred-applications.desktop.in: Add
          X-XfcePluggable and X-XfceHelpFile keys.
        * exo-helper/exo-preferred-applications.in: Pass any extra
          command-line arguments on to exo-helper-0.3.
        * exo-helper/main.c: Use GOption framework for parsing the
          command line.  Add --socket-id parameter so the dialog can
          be embedded in the settings manager.

Modified: libexo/trunk/ChangeLog
===================================================================
--- libexo/trunk/ChangeLog      2008-10-22 10:14:01 UTC (rev 28356)
+++ libexo/trunk/ChangeLog      2008-10-22 10:23:52 UTC (rev 28357)
@@ -1,3 +1,17 @@
+2008-10-22     Brian Tarricone <[EMAIL PROTECTED]>
+
+       * configure.in.in: Add 'svn' version tag.
+       * exo-helper/exo-helper-chooser-dialog.[ch]: Add function to
+         retrieve the toplevel container beneath the GtkDialog's
+         GtkVBox.
+       * exo-helper/exo-preferred-applications.desktop.in: Add
+         X-XfcePluggable and X-XfceHelpFile keys.
+       * exo-helper/exo-preferred-applications.in: Pass any extra
+         command-line arguments on to exo-helper-0.3.
+       * exo-helper/main.c: Use GOption framework for parsing the
+         command line.  Add --socket-id parameter so the dialog can
+         be embedded in the settings manager.
+
 2008-10-10     Jannis Pohlmann <[EMAIL PROTECTED]>
 
        * exo-helper/helpers/Makefile.am, 

Modified: libexo/trunk/NEWS
===================================================================
--- libexo/trunk/NEWS   2008-10-22 10:14:01 UTC (rev 28356)
+++ libexo/trunk/NEWS   2008-10-22 10:23:52 UTC (rev 28357)
@@ -1,3 +1,9 @@
+0.3.92
+======
+- Make Preferred Applications dialog pluggable into the new settings
+  manager.
+
+
 0.3.91
 ======
 - Add midori helper (bug #4446)

Modified: libexo/trunk/configure.in.in
===================================================================
--- libexo/trunk/configure.in.in        2008-10-22 10:14:01 UTC (rev 28356)
+++ libexo/trunk/configure.in.in        2008-10-22 10:23:52 UTC (rev 28357)
@@ -15,7 +15,7 @@
 m4_define([libexo_version_micro], [91])
 m4_define([libexo_version_nano], [])
 m4_define([libexo_version_build], [EMAIL PROTECTED]@])
-m4_define([libexo_version_tag], [])
+m4_define([libexo_version_tag], [svn])
 m4_define([libexo_version], 
[libexo_version_major().libexo_version_minor().libexo_version_micro()ifelse(libexo_version_nano(),
 [], [], [.libexo_version_nano()])ifelse(libexo_version_tag(), [svn], 
[libexo_version_tag()-libexo_version_build()], [libexo_version_tag()])])
 
 dnl ********************************************

Modified: libexo/trunk/exo-helper/exo-helper-chooser-dialog.c
===================================================================
--- libexo/trunk/exo-helper/exo-helper-chooser-dialog.c 2008-10-22 10:14:01 UTC 
(rev 28356)
+++ libexo/trunk/exo-helper/exo-helper-chooser-dialog.c 2008-10-22 10:23:52 UTC 
(rev 28357)
@@ -42,6 +42,8 @@
 struct _ExoHelperChooserDialog
 {
   XfceTitledDialog __parent__;
+
+  GtkWidget       *plug_child;
 };
 
 
@@ -88,6 +90,7 @@
   GtkWidget      *button;
   GtkWidget      *frame;
   GtkWidget      *label;
+  GtkWidget      *topcontainer;
   GtkWidget      *vbox;
   GtkWidget      *box;
 
@@ -107,9 +110,14 @@
   gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG 
(chooser_dialog)->action_area), button, TRUE);
   gtk_widget_show (button);
 
+  topcontainer = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (chooser_dialog)->vbox), 
topcontainer, TRUE, TRUE, 0);
+  gtk_widget_show (topcontainer);
+  chooser_dialog->plug_child = topcontainer;
+
   notebook = gtk_notebook_new ();
   gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (chooser_dialog)->vbox), notebook, 
TRUE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (topcontainer), notebook);
   gtk_widget_show (notebook);
 
   /* allocate shared bold label attributes */
@@ -279,3 +287,18 @@
 }
 
 
+/**
+ * exo_helper_chooser_dialog_get_plug_child:
+ * @dialog: A #ExoHelperChooserDialog.
+ *
+ * Gets the non-window toplevel container of the dialog.
+ *
+ * Return value: a non-window #GtkWidget.
+ **/
+GtkWidget *
+exo_helper_chooser_dialog_get_plug_child (ExoHelperChooserDialog *dialog)
+{
+  return dialog->plug_child;
+}
+
+

Modified: libexo/trunk/exo-helper/exo-helper-chooser-dialog.h
===================================================================
--- libexo/trunk/exo-helper/exo-helper-chooser-dialog.h 2008-10-22 10:14:01 UTC 
(rev 28356)
+++ libexo/trunk/exo-helper/exo-helper-chooser-dialog.h 2008-10-22 10:23:52 UTC 
(rev 28357)
@@ -38,6 +38,8 @@
 
 GtkWidget *exo_helper_chooser_dialog_new      (void) G_GNUC_MALLOC;
 
+GtkWidget *exo_helper_chooser_dialog_get_plug_child (ExoHelperChooserDialog 
*dialog);
+
 G_END_DECLS;
 
 #endif /* !__EXO_HELPER_CHOOSER_DIALOG_H__ */

Modified: libexo/trunk/exo-helper/exo-preferred-applications.desktop.in
===================================================================
--- libexo/trunk/exo-helper/exo-preferred-applications.desktop.in       
2008-10-22 10:14:01 UTC (rev 28356)
+++ libexo/trunk/exo-helper/exo-preferred-applications.desktop.in       
2008-10-22 10:23:52 UTC (rev 28357)
@@ -11,3 +11,5 @@
 _GenericName=Preferred Applications
 _Name=Xfce 4 Preferred Applications
 _Comment=Preferred Applications (Web Browser, Mail Reader and Terminal 
Emulator)
+X-XfcePluggable=true
+X-XfceHelpFile=exo-preferred-applications.html

Modified: libexo/trunk/exo-helper/exo-preferred-applications.in
===================================================================
--- libexo/trunk/exo-helper/exo-preferred-applications.in       2008-10-22 
10:14:01 UTC (rev 28356)
+++ libexo/trunk/exo-helper/exo-preferred-applications.in       2008-10-22 
10:23:52 UTC (rev 28357)
@@ -9,4 +9,4 @@
 # Browser, Mail Reader and Terminal Emulator.
 #
 
-exec @libexecdir@/[EMAIL PROTECTED]@[EMAIL PROTECTED]@ --configure
+exec @libexecdir@/[EMAIL PROTECTED]@[EMAIL PROTECTED]@ --configure "$@"

Modified: libexo/trunk/exo-helper/main.c
===================================================================
--- libexo/trunk/exo-helper/main.c      2008-10-22 10:14:01 UTC (rev 28356)
+++ libexo/trunk/exo-helper/main.c      2008-10-22 10:23:52 UTC (rev 28357)
@@ -46,35 +46,6 @@
 
 
 
-static void
-usage (void)
-{
-  g_print ("%s\n", _("Usage: exo-helper [OPTION...]"));
-  g_print ("\n");
-  g_print ("%s\n", _("  -h, --help                          Print this help 
message and exit"));
-  g_print ("%s\n", _("  -v, --version                       Print version 
information and exit"));
-  g_print ("\n");
-  g_print ("%s\n", _("  --configure                         Open the Preferred 
Applications\n"
-                     "                                      configuration 
dialog"));
-  g_print ("\n");
-  g_print ("%s\n", _("  --launch TYPE [PARAMETER]           Launch the default 
helper of TYPE\n"
-                     "                                      with the optional 
PARAMETER, where\n"
-                     "                                      TYPE is one of the 
following values."));
-  g_print ("\n");
-  g_print ("%s\n", _("The following TYPEs are supported for the --launch 
command:"));
-  g_print ("\n");
-
-  /* Note to Translators: Do not translate the TYPEs (WebBrowser, MailReader, 
TerminalEmulator),
-   * since the exo-helper utility will not accept localized TYPEs.
-   */
-  g_print ("%s\n", _("  WebBrowser       - The preferred Web Browser.\n"
-                     "  MailReader       - The preferred Mail Reader.\n"
-                     "  TerminalEmulator - The preferred Terminal Emulator."));
-  g_print ("\n");
-}
-
-
-
 int
 main (int argc, char **argv)
 {
@@ -85,6 +56,21 @@
   GError            *error = NULL;
   gint               result = EXIT_SUCCESS;
 
+  gboolean           opt_version = FALSE;
+  gboolean           opt_configure = FALSE;
+  gchar             *opt_launch_type = NULL;
+  GdkNativeWindow    opt_socket_id = 0;
+
+  GOptionContext    *opt_ctx;
+  GOptionGroup      *gtk_option_group;
+  GOptionEntry       option_entries[] = {
+    { "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &opt_version, 
N_("Print version information and exit"), NULL, },
+    { "configure", 'c', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, 
&opt_configure, N_("Open the Preferred Applications\nconfiguration dialog"), 
NULL, },
+    { "launch", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, 
&opt_launch_type, N_("Launch the default helper of TYPE with the optional 
PARAMETER, where TYPE is one of the following values."), N_("TYPE 
[PARAMETER]"), },
+    { "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, 
&opt_socket_id, N_("Settings manager socket"), N_("SOCKET ID"), },
+    { NULL, },
+  };
+
   /* sanity check helper categories */
   g_assert (EXO_HELPER_N_CATEGORIES == G_N_ELEMENTS (CATEGORY_EXEC_ERRORS));
 
@@ -93,6 +79,35 @@
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
 #endif
 
+  /* set up options */
+  opt_ctx = g_option_context_new (NULL);
+
+  gtk_option_group = gtk_get_option_group (FALSE);
+  g_option_context_add_group (opt_ctx, gtk_option_group);
+
+  g_option_context_add_main_entries (opt_ctx, option_entries, NULL);
+  /* Note to Translators: Do not translate the TYPEs (WebBrowser, MailReader, 
TerminalEmulator),
+   * since the exo-helper utility will not accept localized TYPEs.
+   */
+  g_option_context_set_description (opt_ctx,
+                                    _("The following TYPEs are supported for 
the --launch command:\n\n"
+                                      "  WebBrowser       - The preferred Web 
Browser.\n"
+                                      "  MailReader       - The preferred Mail 
Reader.\n"
+                                      "  TerminalEmulator - The preferred 
Terminal Emulator."));
+
+  if (!g_option_context_parse (opt_ctx, &argc, &argv, &error))
+    {
+      if (G_LIKELY (error)) {
+            g_printerr ("%s: %s.\n", G_LOG_DOMAIN, error->message);
+            g_printerr (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
+            g_printerr ("\n");
+            g_error_free (error);
+        } else
+            g_error ("Unable to open display.");
+
+        return EXIT_FAILURE;
+    }
+
   /* initialize Gtk+ */
   gtk_init (&argc, &argv);
 
@@ -100,18 +115,38 @@
   gtk_window_set_default_icon_name 
("preferences-desktop-default-applications");
 
   /* check for the action to perform */
-  if (argc == 2 && strcmp (argv[1], "--configure") == 0)
+  if (opt_configure == TRUE)
     {
       dialog = exo_helper_chooser_dialog_new ();
-      gtk_dialog_run (GTK_DIALOG (dialog));
+
+      if (opt_socket_id != 0)
+        {
+          GtkWidget *plug, *plug_child;
+
+          plug = gtk_plug_new (opt_socket_id);
+          gtk_widget_show (plug);
+          g_signal_connect (plug, "delete-event", G_CALLBACK (gtk_main_quit), 
NULL);
+
+          plug_child = exo_helper_chooser_dialog_get_plug_child 
(EXO_HELPER_CHOOSER_DIALOG (dialog));
+          gtk_widget_reparent (plug_child, plug);
+          gtk_widget_show (plug_child);
+
+          gtk_main ();
+          gtk_widget_destroy (plug);
+        }
+      else
+        {
+          gtk_dialog_run (GTK_DIALOG (dialog));
+        }
+
       gtk_widget_destroy (dialog);
     }
-  else if ((argc == 3 || argc == 4) && strcmp (argv[1], "--launch") == 0)
+  else if (opt_launch_type != NULL)
     {
       /* try to parse the type */
-      if (!exo_helper_category_from_string (argv[2], &category))
+      if (!exo_helper_category_from_string (opt_launch_type, &category))
         {
-          g_warning (_("Invalid helper type \"%s\""), argv[2]);
+          g_warning (_("Invalid helper type \"%s\""), opt_launch_type);
           return EXIT_FAILURE;
         }
 
@@ -136,7 +171,7 @@
       if (G_LIKELY (helper != NULL))
         {
           /* try to execute the helper with the given parameter */
-          if (!exo_helper_execute (helper, NULL, (argc > 3) ? argv[3] : NULL, 
&error))
+          if (!exo_helper_execute (helper, NULL, (argc > 1) ? argv[1] : NULL, 
&error))
             {
               dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, 
GTK_BUTTONS_CLOSE,
                                                "%s.", 
_(CATEGORY_EXEC_ERRORS[category]));
@@ -149,12 +184,8 @@
           g_object_unref (G_OBJECT (helper));
         }
     }
-  else if (argc == 2 && strcmp (argv[1], "--help") == 0)
+  else if (opt_version == TRUE)
     {
-      usage ();
-    }
-  else if (argc == 2 && strcmp (argv[1], "--version") == 0)
-    {
       g_print (_("%s (Xfce %s)\n\n"
                  "Copyright (c) 2003-2006\n"
                  "        os-cillation e.K. All rights reserved.\n\n"
@@ -169,8 +200,10 @@
   else
     {
       result = EXIT_FAILURE;
-      usage ();
+      g_printerr (g_option_context_get_help (opt_ctx, FALSE, NULL));
     }
 
+  g_option_context_free (opt_ctx);
+
   return result;
 }

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to