bringing GNOME Hello to the present



Hi all,

Here comes a patch on gnome-hello which removes GnomeApp stuff,
introduces GtkUIManager and the new GtkAboutDialog, fixes the coding
style a bit (YMMV...) and a couple of other changes. It should be noted
that GNOME Hello has been depending on unstable GTK for a few weeks, so
I'm not adding a new dependency. 

I'd tweak a bit the build set up too (it is not using gnome-common's
autogen.sh and has a couple of files in cvs which should not be there)
but that is harder to get in patch form.

Any complaints on my commiting this?

-- m


-- 
Mariano Suárez-Alvarez <msuarezalvarez arnet com ar>
http://www.gnome.org/~mariano
Index: app.c
===================================================================
RCS file: /cvs/gnome/gnome-hello/src/app.c,v
retrieving revision 1.5
diff -U5 -p -r1.5 app.c
--- app.c	7 Oct 2004 08:45:46 -0000	1.5
+++ app.c	17 Nov 2004 22:32:23 -0000
@@ -16,104 +16,94 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
 
-/*** gnomehello-app */
-
 #include <config.h>
+#include <glib/gi18n.h>
 #include "app.h"
 #include "menus.h"
 
 /* Keep a list of all open application windows */
-static GSList* app_list = NULL;
+static GSList *app_list = NULL;
 
-static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data);
-static void button_click_cb(GtkWidget* w, gpointer data);
+static gint delete_event_cb (GtkWidget *w, GdkEventAny *e, gpointer data);
+static void button_click_cb (GtkWidget *w, gpointer data);
 
-GtkWidget* 
-hello_app_new(const gchar* message, 
-              const gchar* geometry,
-              GSList* greet)
+GtkWidget * 
+hello_app_new (const gchar *message, 
+               const gchar *geometry,
+               GSList      *greet)
 {
-  GtkWidget* app;
-  GtkWidget* button;
-  GtkWidget* label;
-  GtkWidget* status;
-  GtkWidget* frame;
+  GtkWidget *app;
+  GtkWidget *vbox;
+  GtkWidget *button;
+  GtkWidget *alignment;
+  GtkWidget *label;
+  GtkWidget *menubar;
+  GtkUIManager *ui_manager;
+  GtkAccelGroup *accel_group;
 
   /*** gnomehello-widgets */
-  app = gnome_app_new(PACKAGE, _("Gnome Hello"));
-
-  frame = gtk_frame_new(NULL);
-
-  button = gtk_button_new();
-
-  label  = gtk_label_new(message ? message : _("Hello, World!"));
-
-  gtk_window_set_policy(GTK_WINDOW(app), FALSE, TRUE, FALSE);
-  gtk_window_set_default_size(GTK_WINDOW(app), 250, 350);
-  gtk_window_set_wmclass(GTK_WINDOW(app), "hello", "GnomeHello");
-
-  gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
-
-  gtk_container_set_border_width(GTK_CONTAINER(button), 10);
-
-  gtk_container_add(GTK_CONTAINER(button), label);
-
-  gtk_container_add(GTK_CONTAINER(frame), button);
-
-  gnome_app_set_contents(GNOME_APP(app), frame);
-
-  status = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_NEVER);
-
-  gnome_app_set_statusbar(GNOME_APP(app), status);
-
-  hello_install_menus_and_toolbar(app);
-
-  /* gnomehello-widgets ***/
+  app = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_policy (GTK_WINDOW (app), FALSE, TRUE, FALSE);
+  gtk_window_set_default_size (GTK_WINDOW (app), 250, 350);
+  gtk_window_set_wmclass (GTK_WINDOW (app), "hello", "GnomeHello");
+
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (app), vbox);
+
+  ui_manager = create_ui_manager ("GnomeHelloActions", app);
+
+  accel_group = gtk_ui_manager_get_accel_group (ui_manager);
+  gtk_window_add_accel_group (GTK_WINDOW (app), accel_group);
+
+  menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
+  gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
+
+  button = gtk_button_new ();
+  gtk_container_set_border_width (GTK_CONTAINER (button), 10);
+  gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
+
+  label  = gtk_label_new (message ? message : _("Hello, World!"));
+  gtk_container_add (GTK_CONTAINER (button), label);
+
+  g_signal_connect (G_OBJECT (app),
+                    "delete_event",
+                    G_CALLBACK (delete_event_cb),
+                    NULL);
+
+  g_signal_connect (G_OBJECT (button),
+                    "clicked",
+                    G_CALLBACK (button_click_cb),
+                    label);
   
-  /*** gnomehello-signals */
-  g_signal_connect(G_OBJECT(app),
-                   "delete_event",
-                   G_CALLBACK(delete_event_cb),
-                   NULL);
-
-  g_signal_connect(G_OBJECT(button),
-                   "clicked",
-                   G_CALLBACK(button_click_cb),
-                   label);
-  /* gnomehello-signals ***/
-
-  /* gnomehello-geometry ***/
   if (geometry != NULL) 
     {
-      if (!gtk_window_parse_geometry (GTK_WINDOW(app), geometry)) 
+      if (!gtk_window_parse_geometry (GTK_WINDOW (app), geometry)) 
         {
-          g_error(_("Could not parse geometry string `%s'"), geometry);
+          g_error (_("Could not parse geometry string `%s'"), geometry);
         }
     }
 
-  /* gnomehello-geometry ***/
-
   if (greet != NULL)
     {
-      GtkWidget* dialog;
-      gchar* greetings = g_strdup(_("Special Greetings to:\n"));
-      GSList* tmp = greet;
+      GtkWidget *dialog;
+      gchar *greetings = g_strdup (_("Special Greetings to:\n"));
+      GSList *tmp = greet;
 
       while (tmp != NULL)
         {
-          gchar* old = greetings;
+          gchar *old = greetings;
 
-          greetings = g_strconcat(old, 
-                                  (gchar*) tmp->data,
-                                  "\n",
-                                  NULL);
-          g_free(old);
+          greetings = g_strconcat (old, 
+                                   (gchar *) tmp->data,
+                                   "\n",
+                                   NULL);
+          g_free (old);
 
-          tmp = g_slist_next(tmp);
+          tmp = g_slist_next (tmp);
         }
       
       dialog = gtk_message_dialog_new (GTK_WINDOW (app),
 				       GTK_DIALOG_DESTROY_WITH_PARENT,
 				       GTK_MESSAGE_INFO,
@@ -122,64 +112,58 @@ hello_app_new(const gchar* message, 
 				       NULL);
       g_signal_connect (dialog, "response",
 			G_CALLBACK (gtk_object_destroy), NULL);
       gtk_widget_show (dialog);
 
-      g_free(greetings);
-
+      g_free (greetings);
     }
 
-  app_list = g_slist_prepend(app_list, app);
+  app_list = g_slist_prepend (app_list, app);
+
+  gtk_widget_show_all (vbox);
 
   return app;
 }
 
 void       
-hello_app_close(GtkWidget* app)
+hello_app_close (GtkWidget *app)
 {
-  g_return_if_fail(GNOME_IS_APP(app));
-
-  app_list = g_slist_remove(app_list, app);
+  app_list = g_slist_remove (app_list, app);
 
-  gtk_widget_destroy(app);
+  gtk_widget_destroy (app);
 
   if (app_list == NULL)
     {
       /* No windows remaining */
-      gtk_main_quit();
+      gtk_main_quit ();
     }
 }
 
-/*** gnomehello-quit */
 static gint 
-delete_event_cb(GtkWidget* window, GdkEventAny* e, gpointer data)
+delete_event_cb (GtkWidget *window, GdkEventAny *e, gpointer data)
 {
-  hello_app_close(window);
+  hello_app_close (window);
 
   /* Prevent the window's destruction, since we destroyed it 
    * ourselves with hello_app_close()
    */
   return TRUE;
 }
-/* gnomehello-quit ***/
 
 static void 
-button_click_cb(GtkWidget* w, gpointer data)
+button_click_cb (GtkWidget *w, gpointer data)
 {
-  GtkWidget* label;
-  gchar* text;
-  gchar* tmp;
+  GtkWidget *label;
+  const gchar *text;
+  gchar *tmp;
 
-  label = GTK_WIDGET(data);
+  label = GTK_WIDGET (data);
 
-  gtk_label_get(GTK_LABEL(label), &text);
+  text = gtk_label_get_text (GTK_LABEL (label));
+  tmp = g_strdup (text);
 
-  tmp = g_strdup(text);
+  g_strreverse (tmp);
 
-  g_strreverse(tmp);
-
-  gtk_label_set_text(GTK_LABEL(label), tmp);
+  gtk_label_set_text (GTK_LABEL (label), tmp);
 
   g_free(tmp);
 }
-
-/* gnomehello-app ***/
Index: app.h
===================================================================
RCS file: /cvs/gnome/gnome-hello/src/app.h,v
retrieving revision 1.1
diff -U5 -p -r1.1 app.h
--- app.h	28 Jun 1999 01:49:29 -0000	1.1
+++ app.h	17 Nov 2004 22:32:23 -0000
@@ -16,12 +16,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
 
-/*** gnomehello-apph */
-
 #ifndef GNOMEHELLO_APP_H
 #define GNOMEHELLO_APP_H
 
 #include <gnome.h>
 
@@ -30,7 +28,5 @@ GtkWidget* hello_app_new(const gchar* me
                          GSList* greet);
 
 void       hello_app_close(GtkWidget* app);
                          
 #endif
-
-/* gnomehello-apph ***/
Index: hello.c
===================================================================
RCS file: /cvs/gnome/gnome-hello/src/hello.c,v
retrieving revision 1.7
diff -U5 -p -r1.7 hello.c
--- hello.c	7 Oct 2004 08:45:46 -0000	1.7
+++ hello.c	17 Nov 2004 22:32:23 -0000
@@ -16,28 +16,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
 
-/*** gnomehello */
-
 #include <config.h>
 #include <glib-object.h>
 #include <gnome.h>
+#include <glib/gi18n.h>
 
 #include "app.h"
 
 
-static void session_die(GnomeClient* client, gpointer client_data);
-
-static gint save_session(GnomeClient *client, gint phase, 
-                         GnomeSaveStyle save_style,
-                         gint is_shutdown, GnomeInteractStyle interact_style,
-                         gint is_fast, gpointer client_data);
+static void session_die  (GnomeClient* client, gpointer client_data);
+static gint save_session (GnomeClient *client, gint phase, 
+                          GnomeSaveStyle save_style,
+                          gint is_shutdown, GnomeInteractStyle interact_style,
+                          gint is_fast, gpointer client_data);
 
 
-/*** gnomehello-popttable */
 static int greet_mode = FALSE;
 static char* message  = NULL;
 static char* geometry = NULL;
 
 struct poptOption options[] = {
@@ -66,142 +63,120 @@ struct poptOption options[] = {
     &geometry,
     0,
     N_("Specify the geometry of the main window"),
     N_("GEOMETRY")
   },
-  {
-    NULL,
-    '\0',
-    0,
-    NULL,
-    0,
-    NULL,
-    NULL
-  }
+  POPT_TABLEEND
 };
-/* gnomehello-popttable ***/
 
 int 
-main(int argc, char** argv)
+main (int argc, char **argv)
 {
-  /*** gnomehello-parsing */
-  GtkWidget* app;
+  GtkWidget *app;
   GnomeProgram *gnome_hello;
-  GnomeClient* client;
+  GnomeClient *client;
   GValue value = {0,};
   poptContext pctx; 
-  GSList* greet = NULL;
-  char** args;
+  GSList *greet = NULL;
+  char **args;
   int i;
 
-  bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);  
-  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-  textdomain(GETTEXT_PACKAGE);
-
-  gnome_hello = gnome_program_init(PACKAGE, VERSION, LIBGNOMEUI_MODULE,
-				   argc, argv, 
-				   GNOME_PARAM_POPT_TABLE, options, 
-				   GNOME_PARAM_APP_DATADIR,DATADIR, NULL);
+  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);  
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
+  gnome_hello = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
+				    argc, argv, 
+				    GNOME_PARAM_POPT_TABLE, options, 
+				    GNOME_PARAM_APP_DATADIR,DATADIR, NULL);
   gtk_window_set_default_icon_name ("gnome-hello-logo");
 
   g_value_init (&value, G_TYPE_POINTER);
   g_object_get_property (G_OBJECT(gnome_hello), 
-			   GNOME_PARAM_POPT_CONTEXT, &value);
+			 GNOME_PARAM_POPT_CONTEXT, &value);
   
   (poptContext)pctx = g_value_get_pointer (&value);
 
-  /* Argument parsing */
   args = (char **) poptGetArgs(pctx);
 
   if (greet_mode && args)
     {
       i = 0;
       while (args[i] != NULL) 
         {
-          greet = g_slist_prepend(greet, args[i]);
+          greet = g_slist_prepend (greet, args[i]);
           ++i;
         } 
-      /* Put them in order */ 
-      greet = g_slist_reverse(greet); 
+      
+      greet = g_slist_reverse (greet); 
     }
   else if (greet_mode && args == NULL)
     {
-      g_printerr(_("You must specify someone to greet.\n"));
+      g_printerr (_("You must specify someone to greet.\n"));
       return 1;
     }
   else if (args != NULL)
     {
-      g_printerr(_("Command line arguments are only allowed with --greet.\n"));
+      g_printerr (_("Command line arguments are only allowed with --greet.\n"));
       return 1;
     }
   else
     { 
-      g_assert(!greet_mode && args == NULL);
+      g_assert (!greet_mode && args == NULL);
     }
 
-  poptFreeContext(pctx); 
-  /* gnomehello-parsing ***/
+  poptFreeContext (pctx); 
 
-  /* Session Management */
-  
-  /*** gnomehello-client */
   client = gnome_master_client ();
   g_signal_connect (G_OBJECT (client), "save_yourself",
-                      G_CALLBACK (save_session), argv[0]);
+                    G_CALLBACK (save_session), argv[0]);
   g_signal_connect (G_OBJECT (client), "die",
-                      G_CALLBACK (session_die), NULL);
-  /* gnomehello-client ***/
-
+                    G_CALLBACK (session_die), NULL);
   
-  /* Main app */
+  app = hello_app_new (message, geometry, greet);
 
-  app = hello_app_new(message, geometry, greet);
+  g_slist_free (greet);
 
-  g_slist_free(greet);
-
-  /*** gnomehello-main */
   gtk_widget_show_all(app);
 
   gtk_main();
 
   return 0;
-  /* gnomehello-main ***/
 }
 
-/*** gnomehello-save-session */
 static gint
-save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_style,
-              gint is_shutdown, GnomeInteractStyle interact_style,
-              gint is_fast, gpointer client_data)
+save_session (GnomeClient       *client, 
+              gint               phase, 
+              GnomeSaveStyle     save_style,
+              gint               is_shutdown, 
+              GnomeInteractStyle interact_style,
+              gint               is_fast, 
+              gpointer           client_data)
 {
-  gchar** argv;
+  gchar **argv;
   guint argc;
 
-  /* allocate 0-filled, so it will be NULL-terminated */
-  argv = g_malloc0(sizeof(gchar*)*4);
-  argc = 1;
+  argv = g_new0 (gchar*, 4);
+  argc = 0;
 
-  argv[0] = client_data;
+  argv[argc++] = client_data;
 
-  if (message)
+  if (message != NULL)
     {
-      argv[1] = "--message";
-      argv[2] = message;
-      argc = 3;
+      argv[argc++] = "--message";
+      argv[argc++] = message;
     }
+
+  argv[argc] = NULL;
   
   gnome_client_set_clone_command (client, argc, argv);
   gnome_client_set_restart_command (client, argc, argv);
 
   return TRUE;
 }
-/* gnomehello-save-session ***/
 
-/*** gnomehello-session-die */
 static void
-session_die(GnomeClient* client, gpointer client_data)
+session_die (GnomeClient* client, 
+             gpointer client_data)
 {
   gtk_main_quit ();
 }
-/* gnomehello-session-die ***/
-
-/* gnomehello ***/
Index: menus.c
===================================================================
RCS file: /cvs/gnome/gnome-hello/src/menus.c,v
retrieving revision 1.9
diff -U5 -p -r1.9 menus.c
--- menus.c	7 Oct 2004 08:45:46 -0000	1.9
+++ menus.c	17 Nov 2004 22:32:23 -0000
@@ -16,95 +16,92 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
 
-/*** gnomehello-menus */
-
 #include <config.h>
+#include <glib/gi18n.h>
 #include "menus.h"
 #include "app.h"
 
-static void nothing_cb(GtkWidget* widget, gpointer data);
-static void new_app_cb(GtkWidget* widget, gpointer data);
-static void close_cb  (GtkWidget* widget, gpointer data);
-static void exit_cb   (GtkWidget* widget, gpointer data);
-static void about_cb  (GtkWidget* widget, gpointer data);
-
-
-static GnomeUIInfo file_menu [] = {
-  GNOMEUIINFO_MENU_NEW_ITEM(N_("_New Hello"),
-                            N_("Create a new hello"),
-                            new_app_cb, NULL),
-
-  GNOMEUIINFO_MENU_OPEN_ITEM(nothing_cb, NULL),
-
-  GNOMEUIINFO_MENU_SAVE_ITEM(nothing_cb, NULL),
-
-  GNOMEUIINFO_MENU_SAVE_AS_ITEM(nothing_cb, NULL),
-
-  GNOMEUIINFO_SEPARATOR,
-
-  GNOMEUIINFO_MENU_CLOSE_ITEM(close_cb, NULL),
-
-  GNOMEUIINFO_MENU_EXIT_ITEM(exit_cb, NULL),
-
-  GNOMEUIINFO_END
-};
-
-static GnomeUIInfo edit_menu [] = {
-  GNOMEUIINFO_MENU_CUT_ITEM(nothing_cb, NULL), 
-  GNOMEUIINFO_MENU_COPY_ITEM(nothing_cb, NULL),
-  GNOMEUIINFO_MENU_PASTE_ITEM(nothing_cb, NULL),
-  GNOMEUIINFO_MENU_SELECT_ALL_ITEM(nothing_cb, NULL), 
-  GNOMEUIINFO_MENU_CLEAR_ITEM(nothing_cb, NULL),
-  GNOMEUIINFO_MENU_UNDO_ITEM(nothing_cb, NULL),
-  GNOMEUIINFO_MENU_REDO_ITEM(nothing_cb, NULL), 
-  GNOMEUIINFO_MENU_FIND_ITEM(nothing_cb, NULL), 
-  GNOMEUIINFO_MENU_FIND_AGAIN_ITEM(nothing_cb, NULL), 
-  GNOMEUIINFO_MENU_REPLACE_ITEM(nothing_cb, NULL),
-  GNOMEUIINFO_MENU_PROPERTIES_ITEM(nothing_cb, NULL),
-  GNOMEUIINFO_END
-};
-
-static GnomeUIInfo help_menu [] = {
-  GNOMEUIINFO_HELP ("gnome-hello"),
-  
-  GNOMEUIINFO_MENU_ABOUT_ITEM(about_cb, NULL),
-  
-  GNOMEUIINFO_END
-};
-
-static GnomeUIInfo menu [] = {
-  GNOMEUIINFO_MENU_FILE_TREE(file_menu),
-  GNOMEUIINFO_MENU_EDIT_TREE(edit_menu),
-  GNOMEUIINFO_MENU_HELP_TREE(help_menu),
-  GNOMEUIINFO_END
+static void nothing_action_callback (GtkAction* action, gpointer data);
+static void new_action_callback     (GtkAction* action, gpointer data);
+static void close_action_callback   (GtkAction* action, gpointer data);
+static void quit_action_callback    (GtkAction* action, gpointer data);
+static void about_action_callback   (GtkAction* action, gpointer data);
+
+static const gchar *ui =
+  "<ui>"
+  "  <menubar>"
+  "    <menu action='file'>"
+  "      <menuitem action='new'/>"
+  "      <menuitem action='open'/>"
+  "      <menuitem action='save'/>"
+  "      <menuitem action='save-as'/>"
+  "      <separator/>"
+  "      <menuitem action='close'/>"
+  "      <menuitem action='quit'/>"
+  "    </menu>"
+  "    <menu action='edit'>"
+  "      <menuitem action='cut'/>"
+  "      <menuitem action='copy'/>"
+  "      <menuitem action='paste'/>"
+  "      <menuitem action='select-all'/>"
+  "      <menuitem action='clear'/>"
+  "      <separator/>"
+  "      <menuitem action='undo'/>"
+  "      <menuitem action='redo'/>"
+  "      <separator/>"
+  "      <menuitem action='find'/>"
+  "      <menuitem action='find-again'/>"
+  "      <menuitem action='replace'/>"
+  "      <separator/>"
+  "      <menuitem action='properties'/>"
+  "    </menu>"
+  "    <menu action='help'>"
+  "      <menuitem action='contents'/>"
+  "      <menuitem action='about'/>"
+  "    </menu>"
+  "  </menubar>"
+  "  <toolbar>"
+  "    <toolitem action='new'/>"
+  "    <separator/>"
+  "    <toolitem action='prev'/>"
+  "    <toolitem action='next'/>"
+  "  </toolbar>"
+  "</ui>";
+
+static GtkActionEntry entries[] =
+{
+  { "file", NULL, N_("_File"), NULL, NULL, NULL },
+  { "edit", NULL, N_("_Edit"), NULL, NULL, NULL },
+  { "help", NULL, N_("_Help"), NULL, NULL, NULL },
+  { "new", GTK_STOCK_NEW, N_("_New"), "<Ctrl>N", NULL, G_CALLBACK (new_action_callback) },
+  { "open", GTK_STOCK_OPEN, N_("_Open"), "<Ctrl>O", NULL, G_CALLBACK (nothing_action_callback) },
+  { "save", GTK_STOCK_SAVE, N_("_Save"), "<Ctrl>S", NULL, G_CALLBACK (nothing_action_callback) },
+  { "save-as", GTK_STOCK_SAVE_AS, N_("Save _As"), "<Ctrl><Shift>S", NULL, G_CALLBACK (nothing_action_callback) },
+  { "close", GTK_STOCK_CLOSE, N_("_Close"), "<Ctrl>W", NULL, G_CALLBACK (close_action_callback) },
+  { "quit", GTK_STOCK_QUIT, N_("_Quit"), "<Ctrl>Q", NULL, G_CALLBACK (quit_action_callback) },
+  { "cut", GTK_STOCK_CUT, N_("Cu_t"), "<Ctrl>X", NULL, G_CALLBACK (nothing_action_callback) },
+  { "copy", GTK_STOCK_COPY, N_("_Copy"), "<Ctrl>C", NULL, G_CALLBACK (nothing_action_callback) },
+  { "paste", GTK_STOCK_PASTE, N_("_Paste"), "<Ctrl>V", NULL, G_CALLBACK (nothing_action_callback) },
+  { "select-all", NULL, N_("Select _All"), "<Ctrl>A", NULL, G_CALLBACK (nothing_action_callback) },
+  { "clear", GTK_STOCK_CLEAR, N_("C_lear"), NULL, NULL, G_CALLBACK (nothing_action_callback) },
+  { "undo", GTK_STOCK_UNDO, N_("_Undo"), "<Ctrl>Z", NULL, G_CALLBACK (nothing_action_callback) },
+  { "redo", GTK_STOCK_REDO, N_("_Redo"), "<Ctrl><Shift>Z", NULL, G_CALLBACK (nothing_action_callback) },
+  { "find", GTK_STOCK_FIND, N_("_Find"), "<Ctrl>F", NULL, G_CALLBACK (nothing_action_callback) },
+  { "find-again", GTK_STOCK_FIND, N_("Find Ne_xt"), "<Ctrl>G", NULL, G_CALLBACK (nothing_action_callback) },
+  { "replace", GTK_STOCK_FIND_AND_REPLACE, N_("R_eplace"), "<Ctrl>R", NULL, G_CALLBACK (nothing_action_callback) },
+  { "properties", GTK_STOCK_PROPERTIES, N_("Pr_operties"), "<Ctrl>P", NULL, G_CALLBACK (nothing_action_callback) },
+  { "contents", GTK_STOCK_HELP, N_("_Contents"), "F1", NULL, G_CALLBACK (nothing_action_callback) },
+  { "about", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK (about_action_callback) },
+  { "prev", GTK_STOCK_GO_BACK, N_("_Previous"), NULL, NULL, G_CALLBACK (nothing_action_callback) },
+  { "next", GTK_STOCK_GO_FORWARD, N_("_Next"), NULL, NULL, G_CALLBACK (nothing_action_callback) },
 };
 
-static GnomeUIInfo toolbar [] = {
-  GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new hello"), new_app_cb, GTK_STOCK_NEW),
-
-  GNOMEUIINFO_SEPARATOR,
-
-  GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Previous hello"), nothing_cb, GTK_STOCK_GO_BACK),
-  GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Next hello"), nothing_cb, GTK_STOCK_GO_FORWARD),
-
-  GNOMEUIINFO_END
-};
-
-
-void 
-hello_install_menus_and_toolbar(GtkWidget* app)
-{
-  gnome_app_create_toolbar_with_data(GNOME_APP(app), toolbar, app);
-  gnome_app_create_menus_with_data(GNOME_APP(app), menu, app);
-  gnome_app_install_menu_hints(GNOME_APP(app), menu);
-}
-
 static void 
-nothing_cb(GtkWidget* widget, gpointer data)
+nothing_action_callback (GtkAction* action, gpointer data)
 {
   GtkWidget* dialog;
   GtkWidget* app;
   
   app = (GtkWidget*) data;
@@ -118,83 +115,90 @@ nothing_cb(GtkWidget* widget, gpointer d
   gtk_dialog_run (GTK_DIALOG (dialog));
   gtk_widget_destroy (dialog);
 }
 
 static void 
-new_app_cb(GtkWidget* widget, gpointer data)
+new_action_callback (GtkAction* action, gpointer data)
 {
   GtkWidget* app;
 
-  app = hello_app_new(_("Hello, World!"), NULL, NULL);
+  app = hello_app_new (_("Hello, World!"), NULL, NULL);
 
-  gtk_widget_show_all(app);
+  gtk_widget_show_all (app);
 }
 
 static void 
-close_cb(GtkWidget* widget, gpointer data)
+close_action_callback (GtkAction* action, gpointer data)
 {
   GtkWidget* app;
 
   app = (GtkWidget*) data;
 
-  hello_app_close(app);
+  hello_app_close (app);
 }
 
 static void 
-exit_cb(GtkWidget* widget, gpointer data)
+quit_action_callback (GtkAction* action, gpointer data)
 {
-  gtk_main_quit();
+  gtk_main_quit ();
 }
 
 static void 
-about_cb(GtkWidget* widget, gpointer data)
+about_action_callback (GtkAction* action, gpointer data)
 {
   static GtkWidget* dialog = NULL;
   GtkWidget* app;
 
   app = (GtkWidget*) data;
 
   if (dialog != NULL) 
     {
-      gtk_window_present(GTK_WINDOW(dialog));
+      gtk_window_present (GTK_WINDOW (dialog));
     }
   else
     {        
+      const gchar *copyright = "\xc2\xa9 1999 Havoc Pennington";
       const gchar *authors[] = {
         "Havoc Pennington <hp pobox com>",
         NULL
       };
-      GdkPixbuf* logo;
-      GdkScreen *screen;
-      GtkIconTheme *icon_theme;
-
-      /* XXXX this does not follow icon theme changes ... */
-      screen = gtk_widget_get_screen(app);
-      icon_theme = gtk_icon_theme_get_for_screen(screen);
-      logo = gtk_icon_theme_load_icon(icon_theme,
-				      "gnome-hello-logo",
-				      48, 0, NULL);
-
-      dialog = gnome_about_new (_("GNOME Hello"), 
-				VERSION,
-                                "(C) 1999 Havoc Pennington",
-                                _("A sample GNOME application."),
-                                authors,
-				NULL,
-				NULL,
-                                logo);
+
+      dialog = gtk_about_dialog_new ();
+
+      gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (dialog), _("GNOME Hello"));
+      gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (dialog), VERSION);
+      gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (dialog), copyright);
+      gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (dialog), authors);
+      gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (dialog), _("translator-credits"));
+      gtk_about_dialog_set_logo_icon_name (GTK_ABOUT_DIALOG (dialog), "gnome-hello-logo");
 
       gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (app));	
-      if (logo)
-	g_object_unref (logo);
 
-      g_signal_connect(G_OBJECT(dialog),
-                         "destroy",
-                         G_CALLBACK(gtk_widget_destroyed),
-                         &dialog); 
+      g_object_add_weak_pointer (G_OBJECT (dialog), (void**) &dialog);
 
-      gtk_widget_show(dialog);
+      gtk_widget_show (dialog);
     }
 }
 
+GtkUIManager *
+create_ui_manager (const gchar *group, gpointer user_data)
+{
+  GtkActionGroup *action_group;
+  GtkUIManager *ui_manager;
+  GError *error;
+
+  action_group = gtk_action_group_new (group);
+  gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries), user_data);
+  
+  ui_manager = gtk_ui_manager_new ();
+  gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
 
-/* gnomehello-menus ***/
+  error = NULL;
+  if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error))
+    {
+      g_message ("Building menus failed: %s", error->message);
+      g_error_free (error);
+      exit (1);
+    }
+
+  return ui_manager;
+}
Index: menus.h
===================================================================
RCS file: /cvs/gnome/gnome-hello/src/menus.h,v
retrieving revision 1.1
diff -U5 -p -r1.1 menus.h
--- menus.h	28 Jun 1999 01:49:29 -0000	1.1
+++ menus.h	17 Nov 2004 22:32:23 -0000
@@ -16,18 +16,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
 
-/*** gnomehello-menush */
-
 #ifndef GNOMEHELLO_MENUS_H
 #define GNOMEHELLO_MENUS_H
 
-#include <gnome.h>
-
-void hello_install_menus_and_toolbar(GtkWidget* app);
-      
-#endif
+#include <gtk/gtk.h>
 
-/* gnomehello-menush ***/
+GtkUIManager *create_ui_manager (const gchar *group, gpointer user_data);
 
+#endif

Attachment: signature.asc
Description: This is a digitally signed message part



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