gnome-terminal r2611 - trunk/src



Author: chpe
Date: Thu May 29 19:38:31 2008
New Revision: 2611
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2611&view=rev

Log:
Move terminal_util_* to terminal-util.[ch].


Added:
   trunk/src/terminal-util.c
   trunk/src/terminal-util.h
      - copied, changed from r2610, /trunk/src/terminal.h
Modified:
   trunk/src/Makefile.am
   trunk/src/encoding.c
   trunk/src/profile-editor.c
   trunk/src/skey-popup.c
   trunk/src/terminal-accels.c
   trunk/src/terminal-app.c
   trunk/src/terminal-screen.c
   trunk/src/terminal-screen.h
   trunk/src/terminal-window.c
   trunk/src/terminal.c
   trunk/src/terminal.h

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu May 29 19:38:31 2008
@@ -28,6 +28,8 @@
 	terminal-tabs-menu.h \
 	terminal-type-builtins.c \
 	terminal-type-builtins.h \
+	terminal-util.c \
+	terminal-util.h \
 	terminal-window.c \
 	terminal-window.h \
 	$(NULL)

Modified: trunk/src/encoding.c
==============================================================================
--- trunk/src/encoding.c	(original)
+++ trunk/src/encoding.c	Thu May 29 19:38:31 2008
@@ -27,6 +27,7 @@
 #include "encoding.h"
 
 #include "terminal-profile.h"
+#include "terminal-util.h"
 
 #include <glade/glade.h>
 #include <gtk/gtktreeview.h>

Modified: trunk/src/profile-editor.c
==============================================================================
--- trunk/src/profile-editor.c	(original)
+++ trunk/src/profile-editor.c	Thu May 29 19:38:31 2008
@@ -25,6 +25,7 @@
 
 #include "profile-editor.h"
 #include "terminal.h"
+#include "terminal-util.h"
 #include <glade/glade.h>
 #include <gio/gio.h>
 #include <libgnomeui/gnome-file-entry.h>

Modified: trunk/src/skey-popup.c
==============================================================================
--- trunk/src/skey-popup.c	(original)
+++ trunk/src/skey-popup.c	Thu May 29 19:38:31 2008
@@ -22,6 +22,7 @@
 #include "terminal-intl.h"
 
 #include "terminal.h"
+#include "terminal-util.h"
 #include "terminal-screen.h"
 #include "skey-popup.h"
 #include <glade/glade.h>

Modified: trunk/src/terminal-accels.c
==============================================================================
--- trunk/src/terminal-accels.c	(original)
+++ trunk/src/terminal-accels.c	Thu May 29 19:38:31 2008
@@ -24,6 +24,7 @@
 
 #include "terminal-accels.h"
 #include "terminal-profile.h"
+#include "terminal-util.h"
 #include "terminal.h"
 #include <string.h>
 #include <glade/glade.h>

Modified: trunk/src/terminal-app.c
==============================================================================
--- trunk/src/terminal-app.c	(original)
+++ trunk/src/terminal-app.c	Thu May 29 19:38:31 2008
@@ -32,6 +32,7 @@
 #include "terminal-app.h"
 #include "terminal-accels.h"
 #include "terminal-window.h"
+#include "terminal-util.h"
 #include "profile-editor.h"
 #include "encoding.h"
 #include <gconf/gconf-client.h>

Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c	(original)
+++ trunk/src/terminal-screen.c	Thu May 29 19:38:31 2008
@@ -40,6 +40,7 @@
 #include "terminal-window.h"
 #include "terminal-profile.h"
 #include "terminal-screen-container.h"
+#include "terminal-util.h"
 #include "terminal.h"
 #include "skey-popup.h"
 #include <libgnome/gnome-util.h> /* gnome_util_user_shell */

Modified: trunk/src/terminal-screen.h
==============================================================================
--- trunk/src/terminal-screen.h	(original)
+++ trunk/src/terminal-screen.h	Thu May 29 19:38:31 2008
@@ -28,6 +28,12 @@
 
 G_BEGIN_DECLS
 
+typedef enum {
+  FLAVOR_AS_IS,
+  FLAVOR_DEFAULT_TO_HTTP,
+  FLAVOR_EMAIL
+} TerminalURLFlavour;
+
 /* Forward decls */
 typedef struct _TerminalScreenPopupInfo TerminalScreenPopupInfo;
 typedef struct _TerminalWindow        TerminalWindow;

Added: trunk/src/terminal-util.c
==============================================================================
--- (empty file)
+++ trunk/src/terminal-util.c	Thu May 29 19:38:31 2008
@@ -0,0 +1,248 @@
+/* terminal program */
+/*
+ * Copyright  2001, 2002 Havoc Pennington
+ * Copyright  2002 Red Hat, Inc.
+ * Copyright  2002 Sun Microsystems
+ * Copyright  2003 Mariano Suarez-Alvarez
+ * Copyright  2008 Christian Persch
+ *
+ * This file is part of gnome-terminal.
+ *
+ * Gnome-terminal 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.
+ *
+ * Gnome-terminal 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 <config.h>
+
+#include "terminal-intl.h"
+
+#include <locale.h>
+
+#include "terminal.h"
+#include "terminal-app.h"
+#include "terminal-accels.h"
+#include "terminal-window.h"
+#include "terminal-util.h"
+#include "profile-editor.h"
+#include "encoding.h"
+#include <gconf/gconf-client.h>
+#include <libgnome/gnome-program.h>
+#include <libgnome/gnome-help.h>
+#include <libgnomeui/gnome-ui-init.h>
+#include <libgnomeui/gnome-url.h>
+#include <libgnomeui/gnome-client.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+
+void
+terminal_util_set_unique_role (GtkWindow *window, const char *prefix)
+{
+  char *role;
+
+  role = g_strdup_printf ("%s-%d-%d-%d", prefix, getpid (), g_random_int (), (int) time (NULL));
+  gtk_window_set_role (window, role);
+  g_free (role);
+}
+
+/**
+ * terminal_util_show_error_dialog:
+ * @transient_parent: parent of the future dialog window;
+ * @weap_ptr: pointer to a #Widget pointer, to control the population.
+ * @message_format: printf() style format string
+ *
+ * Create a #GtkMessageDialog window with the message, and present it, handling its buttons.
+ * If @weap_ptr is not #NULL, only create the dialog if <literal>*weap_ptr</literal> is #NULL 
+ * (and in that * case, set @weap_ptr to be a weak pointer to the new dialog), otherwise just 
+ * present <literal>*weak_ptr</literal>. Note that in this last case, the message <emph>will</emph>
+ * be changed.
+ */
+
+void
+terminal_util_show_error_dialog (GtkWindow *transient_parent, GtkWidget **weak_ptr, const char *message_format, ...)
+{
+  char *message;
+  va_list args;
+
+  if (message_format)
+    {
+      va_start (args, message_format);
+      message = g_strdup_vprintf (message_format, args);
+      va_end (args);
+    }
+  else message = NULL;
+
+  if (weak_ptr == NULL || *weak_ptr == NULL)
+    {
+      GtkWidget *dialog;
+      dialog = gtk_message_dialog_new (transient_parent,
+                                       GTK_DIALOG_DESTROY_WITH_PARENT,
+                                       GTK_MESSAGE_ERROR,
+                                       GTK_BUTTONS_OK,
+                                       message ? "%s" : NULL,
+				       message);
+
+      g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), NULL);
+
+      if (weak_ptr != NULL)
+        {
+        *weak_ptr = dialog;
+        g_object_add_weak_pointer (G_OBJECT (dialog), (void**)weak_ptr);
+        }
+
+      gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+      
+      gtk_widget_show_all (dialog);
+    }
+  else 
+    {
+      g_return_if_fail (GTK_IS_MESSAGE_DIALOG (*weak_ptr));
+
+      gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (*weak_ptr)->label), message);
+
+      gtk_window_present (GTK_WINDOW (*weak_ptr));
+    }
+  }
+
+void
+terminal_util_show_help (const char *topic, 
+                         GtkWindow  *transient_parent)
+{
+  GError *err;
+
+  err = NULL;
+
+  gnome_help_display ("gnome-terminal", topic, &err);
+  
+  if (err)
+    {
+      terminal_util_show_error_dialog (GTK_WINDOW (transient_parent), NULL,
+                                       _("There was an error displaying help: %s"),
+                                      err->message);
+      g_error_free (err);
+    }
+}
+ 
+/* sets accessible name and description for the widget */
+
+void
+terminal_util_set_atk_name_description (GtkWidget  *widget,
+                                        const char *name,
+                                        const char *desc)
+{
+  AtkObject *obj;
+  
+  obj = gtk_widget_get_accessible (widget);
+
+  if (obj == NULL)
+    {
+      g_warning ("%s: for some reason widget has no GtkAccessible",
+                 G_STRFUNC);
+      return;
+    }
+
+  
+  if (!GTK_IS_ACCESSIBLE (obj))
+    return; /* This means GAIL is not loaded so we have the NoOp accessible */
+      
+  g_return_if_fail (GTK_IS_ACCESSIBLE (obj));  
+  if (desc)
+    atk_object_set_description (obj, desc);
+  if (name)
+    atk_object_set_name (obj, name);
+}
+
+GladeXML*
+terminal_util_load_glade_file (const char *filename,
+                               const char *widget_root,
+                               GtkWindow  *error_dialog_parent)
+{
+  char *path;
+  GladeXML *xml;
+
+  xml = NULL;
+  path = g_strconcat ("./", filename, NULL);
+  
+  if (g_file_test (path,
+                   G_FILE_TEST_EXISTS))
+    {
+      /* Try current dir, for debugging */
+      xml = glade_xml_new (path,
+                           widget_root,
+                           GETTEXT_PACKAGE);
+    }
+  
+  if (xml == NULL)
+    {
+      g_free (path);
+      
+      path = g_build_filename (TERM_GLADE_DIR, filename, NULL);
+
+      xml = glade_xml_new (path,
+                           widget_root,
+                           GETTEXT_PACKAGE);
+    }
+
+  if (xml == NULL)
+    {
+      static GtkWidget *no_glade_dialog = NULL;
+
+      terminal_util_show_error_dialog (error_dialog_parent, &no_glade_dialog, 
+                                       _("The file \"%s\" is missing. This indicates that the application is installed incorrectly."), path);
+    }
+
+  g_free (path);
+
+  return xml;
+}
+
+void
+terminal_util_open_url (GtkWidget *parent,
+                        const char *orig_url,
+                        TerminalURLFlavour flavor)
+{
+  GError *error = NULL;
+  char *url;
+  
+  g_return_if_fail (orig_url != NULL);
+
+  switch (flavor)
+    {
+    case FLAVOR_DEFAULT_TO_HTTP:
+      url = g_strdup_printf ("http:%s", orig_url);
+      break;
+    case FLAVOR_EMAIL:
+      if (strncmp ("mailto:";, orig_url, 7))
+	url = g_strdup_printf ("mailto:%s";, orig_url);
+      else
+	url = g_strdup (orig_url);
+      break;
+    case FLAVOR_AS_IS:
+      url = g_strdup (orig_url);
+      break;
+    default:
+      url = NULL;
+      g_assert_not_reached ();
+    }
+
+  if (!gnome_url_show_on_screen (url, gtk_widget_get_screen (parent), &error))
+    {
+      terminal_util_show_error_dialog (GTK_WINDOW (parent), NULL,
+                                       _("Could not open the address \"%s\":\n%s"),
+                                       url, error->message);
+      
+      g_error_free (error);
+    }
+
+  g_free (url);
+}

Copied: trunk/src/terminal-util.h (from r2610, /trunk/src/terminal.h)
==============================================================================
--- /trunk/src/terminal.h	(original)
+++ trunk/src/terminal-util.h	Thu May 29 19:38:31 2008
@@ -19,23 +19,15 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef TERMINAL_H
-#define TERMINAL_H
+#ifndef TERMINAL_UTIL_H
+#define TERMINAL_UTIL_H
 
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
 #include <glade/glade.h>
 
-typedef enum {
-  FLAVOR_AS_IS,
-  FLAVOR_DEFAULT_TO_HTTP,
-  FLAVOR_EMAIL
-} TerminalURLFlavour;
-
 #include "terminal-screen.h"
 
-#define GNOME_TERMINAL_ICON_NAME "utilities-terminal"
-
 void terminal_util_set_unique_role (GtkWindow *window, const char *prefix);
 
 void terminal_util_show_error_dialog (GtkWindow *transient_parent, 
@@ -58,4 +50,4 @@
                              TerminalURLFlavour flavor);
 
 
-#endif /* TERMINAL_H */
+#endif /* TERMINAL_UTIL_H */

Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c	(original)
+++ trunk/src/terminal-window.c	Thu May 29 19:38:31 2008
@@ -28,6 +28,7 @@
 #include "terminal-window.h"
 #include "terminal-screen-container.h"
 #include "terminal-tabs-menu.h"
+#include "terminal-util.h"
 #include "terminal.h"
 #include "encoding.h"
 #include <string.h>

Modified: trunk/src/terminal.c
==============================================================================
--- trunk/src/terminal.c	(original)
+++ trunk/src/terminal.c	Thu May 29 19:38:31 2008
@@ -34,6 +34,7 @@
 #include "terminal-app.h"
 #include "terminal-accels.h"
 #include "terminal-window.h"
+#include "terminal-util.h"
 #include "profile-editor.h"
 #include "encoding.h"
 #include <gconf/gconf-client.h>
@@ -1220,212 +1221,6 @@
   return 0;
 }
 
-/*
- * Utility stuff
- */
-
-void
-terminal_util_set_unique_role (GtkWindow *window, const char *prefix)
-{
-  char *role;
-
-  role = g_strdup_printf ("%s-%d-%d-%d", prefix, getpid (), g_random_int (), (int) time (NULL));
-  gtk_window_set_role (window, role);
-  g_free (role);
-}
-
-/**
- * terminal_util_show_error_dialog:
- * @transient_parent: parent of the future dialog window;
- * @weap_ptr: pointer to a #Widget pointer, to control the population.
- * @message_format: printf() style format string
- *
- * Create a #GtkMessageDialog window with the message, and present it, handling its buttons.
- * If @weap_ptr is not #NULL, only create the dialog if <literal>*weap_ptr</literal> is #NULL 
- * (and in that * case, set @weap_ptr to be a weak pointer to the new dialog), otherwise just 
- * present <literal>*weak_ptr</literal>. Note that in this last case, the message <emph>will</emph>
- * be changed.
- */
-
-void
-terminal_util_show_error_dialog (GtkWindow *transient_parent, GtkWidget **weak_ptr, const char *message_format, ...)
-{
-  char *message;
-  va_list args;
-
-  if (message_format)
-    {
-      va_start (args, message_format);
-      message = g_strdup_vprintf (message_format, args);
-      va_end (args);
-    }
-  else message = NULL;
-
-  if (weak_ptr == NULL || *weak_ptr == NULL)
-    {
-      GtkWidget *dialog;
-      dialog = gtk_message_dialog_new (transient_parent,
-                                       GTK_DIALOG_DESTROY_WITH_PARENT,
-                                       GTK_MESSAGE_ERROR,
-                                       GTK_BUTTONS_OK,
-                                       message ? "%s" : NULL,
-				       message);
-
-      g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), NULL);
-
-      if (weak_ptr != NULL)
-        {
-        *weak_ptr = dialog;
-        g_object_add_weak_pointer (G_OBJECT (dialog), (void**)weak_ptr);
-        }
-
-      gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-      
-      gtk_widget_show_all (dialog);
-    }
-  else 
-    {
-      g_return_if_fail (GTK_IS_MESSAGE_DIALOG (*weak_ptr));
-
-      gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (*weak_ptr)->label), message);
-
-      gtk_window_present (GTK_WINDOW (*weak_ptr));
-    }
-  }
-
-void
-terminal_util_show_help (const char *topic, 
-                         GtkWindow  *transient_parent)
-{
-  GError *err;
-
-  err = NULL;
-
-  gnome_help_display ("gnome-terminal", topic, &err);
-  
-  if (err)
-    {
-      terminal_util_show_error_dialog (GTK_WINDOW (transient_parent), NULL,
-                                       _("There was an error displaying help: %s"),
-                                      err->message);
-      g_error_free (err);
-    }
-}
- 
-/* sets accessible name and description for the widget */
-
-void
-terminal_util_set_atk_name_description (GtkWidget  *widget,
-                                        const char *name,
-                                        const char *desc)
-{
-  AtkObject *obj;
-  
-  obj = gtk_widget_get_accessible (widget);
-
-  if (obj == NULL)
-    {
-      g_warning ("%s: for some reason widget has no GtkAccessible",
-                 G_STRFUNC);
-      return;
-    }
-
-  
-  if (!GTK_IS_ACCESSIBLE (obj))
-    return; /* This means GAIL is not loaded so we have the NoOp accessible */
-      
-  g_return_if_fail (GTK_IS_ACCESSIBLE (obj));  
-  if (desc)
-    atk_object_set_description (obj, desc);
-  if (name)
-    atk_object_set_name (obj, name);
-}
-
-GladeXML*
-terminal_util_load_glade_file (const char *filename,
-                               const char *widget_root,
-                               GtkWindow  *error_dialog_parent)
-{
-  char *path;
-  GladeXML *xml;
-
-  xml = NULL;
-  path = g_strconcat ("./", filename, NULL);
-  
-  if (g_file_test (path,
-                   G_FILE_TEST_EXISTS))
-    {
-      /* Try current dir, for debugging */
-      xml = glade_xml_new (path,
-                           widget_root,
-                           GETTEXT_PACKAGE);
-    }
-  
-  if (xml == NULL)
-    {
-      g_free (path);
-      
-      path = g_build_filename (TERM_GLADE_DIR, filename, NULL);
-
-      xml = glade_xml_new (path,
-                           widget_root,
-                           GETTEXT_PACKAGE);
-    }
-
-  if (xml == NULL)
-    {
-      static GtkWidget *no_glade_dialog = NULL;
-
-      terminal_util_show_error_dialog (error_dialog_parent, &no_glade_dialog, 
-                                       _("The file \"%s\" is missing. This indicates that the application is installed incorrectly."), path);
-    }
-
-  g_free (path);
-
-  return xml;
-}
-
-void
-terminal_util_open_url (GtkWidget *parent,
-                        const char *orig_url,
-                        TerminalURLFlavour flavor)
-{
-  GError *error = NULL;
-  char *url;
-  
-  g_return_if_fail (orig_url != NULL);
-
-  switch (flavor)
-    {
-    case FLAVOR_DEFAULT_TO_HTTP:
-      url = g_strdup_printf ("http:%s", orig_url);
-      break;
-    case FLAVOR_EMAIL:
-      if (strncmp ("mailto:";, orig_url, 7))
-	url = g_strdup_printf ("mailto:%s";, orig_url);
-      else
-	url = g_strdup (orig_url);
-      break;
-    case FLAVOR_AS_IS:
-      url = g_strdup (orig_url);
-      break;
-    default:
-      url = NULL;
-      g_assert_not_reached ();
-    }
-
-  if (!gnome_url_show_on_screen (url, gtk_widget_get_screen (parent), &error))
-    {
-      terminal_util_show_error_dialog (GTK_WINDOW (parent), NULL,
-                                       _("Could not open the address \"%s\":\n%s"),
-                                       url, error->message);
-      
-      g_error_free (error);
-    }
-
-  g_free (url);
-}
-
 /* Factory stuff */
 
 typedef struct

Modified: trunk/src/terminal.h
==============================================================================
--- trunk/src/terminal.h	(original)
+++ trunk/src/terminal.h	Thu May 29 19:38:31 2008
@@ -22,40 +22,6 @@
 #ifndef TERMINAL_H
 #define TERMINAL_H
 
-#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
-#include <glade/glade.h>
-
-typedef enum {
-  FLAVOR_AS_IS,
-  FLAVOR_DEFAULT_TO_HTTP,
-  FLAVOR_EMAIL
-} TerminalURLFlavour;
-
-#include "terminal-screen.h"
-
 #define GNOME_TERMINAL_ICON_NAME "utilities-terminal"
 
-void terminal_util_set_unique_role (GtkWindow *window, const char *prefix);
-
-void terminal_util_show_error_dialog (GtkWindow *transient_parent, 
-                                      GtkWidget **weap_ptr, 
-                                      const char *message_format, ...) G_GNUC_PRINTF(3, 4);
-
-void terminal_util_show_help (const char *topic, GtkWindow  *transient_parent);
-
-void terminal_util_set_labelled_by          (GtkWidget  *widget,
-                                             GtkLabel   *label);
-void terminal_util_set_atk_name_description (GtkWidget  *widget,
-                                             const char *name,
-                                             const char *desc);
-GladeXML* terminal_util_load_glade_file (const char *filename,
-                                         const char *widget_root,
-                                         GtkWindow  *error_dialog_parent);
-
-void terminal_util_open_url (GtkWidget *parent,
-                             const char *orig_url,
-                             TerminalURLFlavour flavor);
-
-
 #endif /* TERMINAL_H */



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