[Glade-devel] [patch, glade3] small cleanup in gpw_refresh_undo_redo



--=-GLgbORrCDl3P4iJzVrJN
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi!

The attached patch is a small cleanup:
glade_project_window_refresh_undo_redo () does not need to take gpw as
an arg since all its callers do glade_project_window_get to retrieve the
gpw. I made it take void and updated the callers in glade-command,
deleting update_gui which is just a wrapper for that function.
In glade_project_window.c I had to reshuffle the code a little since
calling refresh_undo_redo tried to access the global var
glade_project_window before it was set.
I also deleted the refresh_title prototype in glade_project_window.h
since that function has been removed some time ago.

ciao
        paolo

--=-GLgbORrCDl3P4iJzVrJN
Content-Disposition: attachment; filename=gpw_h_cleanup.patch
Content-Type: text/x-patch; name=gpw_h_cleanup.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -upr gnome2/glade3/ChangeLog glade3/ChangeLog
--- gnome2/glade3/ChangeLog     2003-05-24 17:41:46.000000000 +0200
+++ glade3/ChangeLog    2003-05-25 13:25:59.000000000 +0200
@@ -1,3 +1,9 @@
+2003-05-25  Paolo Borelli  <pborelli katamail com>
+
+       * src/glade-project-window.[ch]: make refresh_undo_redo function
+       take void arg. Reorder some code.
+       * src/glade-command.c: update for the above
+
 2003-05-23  Joaquin Cuenca Abela  <e98cuenc yahoo com>
 
        * src/glade-placeholder.c: Make the placeholder work better on any
diff -upr gnome2/glade3/src/glade-command.c glade3/src/glade-command.c
--- gnome2/glade3/src/glade-command.c   2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-command.c  2003-05-25 13:23:37.000000000 +0200
@@ -168,12 +168,6 @@ static MAKE_TYPE(func, type, GLADE_COMMA
 
 /**************************************************/
 
-static void
-update_gui (void)
-{
-       glade_project_window_refresh_undo_redo (glade_project_window_get ());
-}
-
 void
 glade_command_undo (void)
 {
@@ -199,7 +193,7 @@ glade_command_undo (void)
        class->undo_cmd (cmd);
 
        project->prev_redo_item = prev_redo_item->prev;
-       update_gui ();
+       glade_project_window_refresh_undo_redo ();
 }
 
 void
@@ -232,7 +226,7 @@ glade_command_redo (void)
        class->execute_cmd (cmd);
 
        project->prev_redo_item = prev_redo_item ? prev_redo_item->next : project->undo_stack;
-       update_gui ();
+       glade_project_window_refresh_undo_redo ();
 }
 
 const gchar*
@@ -296,7 +290,7 @@ glade_command_push_undo (GladeProject *p
        else
                project->prev_redo_item = g_list_next (project->prev_redo_item);
 
-       update_gui ();
+       glade_project_window_refresh_undo_redo ();
 }
 
 /**************************************************/
@@ -387,7 +381,7 @@ glade_command_set_property_collapse (Gla
        this->description = other->description;
        other->description = NULL;
 
-       update_gui ();
+       glade_project_window_refresh_undo_redo ();
 }
 
 static gchar*
@@ -554,7 +548,7 @@ glade_command_set_name_collapse (GladeCo
        g_free ((gchar *) this->description);
        this->description = g_strdup_printf (_("Renaming %s to %s"), nthis->name, nthis->old_name);
 
-       update_gui ();
+       glade_project_window_refresh_undo_redo ();
 }
 
 /* this function takes the ownership of name */
diff -upr gnome2/glade3/src/glade-project-window.c glade3/src/glade-project-window.c
--- gnome2/glade3/src/glade-project-window.c    2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-project-window.c   2003-05-25 14:00:52.000000000 +0200
@@ -899,7 +899,7 @@ gpw_pop_statusbar_hint (GtkWidget* menui
        gtk_statusbar_pop (GTK_STATUSBAR (gpw->statusbar), gpw->statusbar_menu_context_id);
 }
 
-static void
+static GtkWidget *
 gpw_construct_menu (GladeProjectWindow *gpw)
 {
        GtkItemFactory *item_factory;
@@ -923,8 +923,6 @@ gpw_construct_menu (GladeProjectWindow *
        /* create menu items */
        gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
                                       menu_items, gpw->window);
-       gtk_box_pack_start_defaults (GTK_BOX (gpw->main_vbox),
-                                    gtk_item_factory_get_widget (item_factory, "<main>"));
 
        /* set the tooltips */
        for (i = 1; i < G_N_ELEMENTS (menu_tips); i++) {
@@ -938,9 +936,11 @@ gpw_construct_menu (GladeProjectWindow *
                                  G_CALLBACK (gpw_pop_statusbar_hint),
                                  NULL);
        }
+
+       return gtk_item_factory_get_widget (item_factory, "<main>");
 }
 
-static void
+static GtkWidget *
 gpw_construct_toolbar (GladeProjectWindow *gpw)
 {
        GtkWidget *toolbar;
@@ -980,13 +980,10 @@ gpw_construct_toolbar (GladeProjectWindo
                                  G_CALLBACK (gpw_quit_cb),
                                  gpw, -1);
 
-       gtk_widget_show (toolbar);
-       
-       gtk_box_pack_start_defaults (GTK_BOX (gpw->main_vbox),
-                                    toolbar);
+       return toolbar; 
 }
 
-static void
+static GtkWidget *
 gpw_construct_statusbar (GladeProjectWindow *gpw)
 {
        GtkWidget *statusbar;
@@ -995,8 +992,8 @@ gpw_construct_statusbar (GladeProjectWin
        gpw->statusbar = statusbar;
        gpw->statusbar_menu_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "menu");
        gpw->statusbar_actions_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), 
"actions");
-               
-       gtk_box_pack_end_defaults (GTK_BOX (gpw->main_vbox), statusbar);        
+
+       return statusbar;
 }
 
 static gboolean
@@ -1008,30 +1005,40 @@ gpw_delete_event (GtkWindow *w, gpointer
        return TRUE;    
 }
 
-static GtkWidget *
-glade_project_window_create (GladeProjectWindow *gpw, GladeProjectView *view)
+static void
+glade_project_window_create (GladeProjectWindow *gpw)
 {
        GtkWidget *app;
        GtkWidget *vbox;
-
-       g_return_val_if_fail (GLADE_IS_PROJECT_VIEW (view), NULL);
+       GtkWidget *menubar;
+       GtkWidget *toolbar;
+       GtkWidget *statusbar;
+       GladeProjectView *view;
 
        app = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gpw->window = app;
+
        vbox = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (app), vbox);
        gpw->main_vbox = vbox;
 
-       gpw_construct_menu (gpw);
-       gpw_construct_toolbar (gpw);
-       gpw_construct_statusbar (gpw);
+       view = glade_project_view_new (GLADE_PROJECT_VIEW_LIST);
+       gpw->views = g_list_prepend (NULL, view);
+       gpw->active_view = view;
+
+       menubar = gpw_construct_menu (gpw);
+       toolbar = gpw_construct_toolbar (gpw);
+       statusbar = gpw_construct_statusbar (gpw);
+
+       gtk_box_pack_start_defaults (GTK_BOX (vbox), menubar);
+       gtk_box_pack_start_defaults (GTK_BOX (vbox), toolbar);
+       gtk_box_pack_start_defaults (GTK_BOX (vbox), glade_project_view_get_widget (view));
+       gtk_box_pack_end_defaults (GTK_BOX (vbox), statusbar);
+
+       glade_project_window_refresh_undo_redo ();
 
-       glade_project_window_refresh_undo_redo (gpw);
-       
        g_signal_connect (G_OBJECT (app), "delete_event",
                          G_CALLBACK (gpw_delete_event), NULL);
-
-       return app;
 }
 
 GladeProjectWindow * glade_project_window = NULL;
@@ -1042,41 +1049,24 @@ glade_project_window_get ()
        return glade_project_window;
 }
 
-static void
-glade_project_window_set_view (GladeProjectWindow *gpw, GladeProjectView *view)
-{
-       if (gpw->active_view == view)
-               return;
-       
-       gpw->active_view = view;
-
-       gtk_box_pack_start_defaults (GTK_BOX (gpw->main_vbox),
-                                    glade_project_view_get_widget (view));
-
-}
-
 GladeProjectWindow *
 glade_project_window_new (GList *catalogs)
 {
        GladeProjectWindow *gpw;
-       GladeProjectView *view;
-
-       view = glade_project_view_new (GLADE_PROJECT_VIEW_LIST);
        
        gpw = g_new0 (GladeProjectWindow, 1);
-       glade_project_window_create (gpw, view);
        gpw->catalogs = catalogs;
-       gpw->views = g_list_prepend (NULL, view);
        gpw->add_class = NULL;
        gpw->active_widget = NULL;
        gpw->active_placeholder = NULL;
-       glade_project_window_set_view (gpw, view);
 
        glade_project_window = gpw;
+
+       glade_project_window_create (gpw);
        gpw_create_palette (gpw);
        gpw_create_editor  (gpw);
        gpw_create_clipboard (gpw);
-       
+
        return gpw;
 }
 
@@ -1216,16 +1206,17 @@ glade_project_window_change_menu_label (
 }
 
 void
-glade_project_window_refresh_undo_redo (GladeProjectWindow *gpw)
+glade_project_window_refresh_undo_redo (void)
 {
+       GladeProjectWindow *gpw;
        GList *prev_redo_item;
        GList *undo_item;
        GList *redo_item;
        const gchar *undo_description = NULL;
        const gchar *redo_description = NULL;
        GladeProject *project;
-       
-       g_return_if_fail (GLADE_IS_PROJECT_WINDOW (gpw));
+
+       gpw = glade_project_window_get ();
 
        project = gpw->project;
        if (project == NULL) {
diff -upr gnome2/glade3/src/glade-project-window.h glade3/src/glade-project-window.h
--- gnome2/glade3/src/glade-project-window.h    2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-project-window.h   2003-05-25 13:23:37.000000000 +0200
@@ -66,8 +66,7 @@ void glade_project_window_set_project   
 
 void glade_project_window_add_project         (GladeProject *project);
 
-void glade_project_window_refresh_undo_redo   (GladeProjectWindow *gpw);
-void glade_project_window_refresh_title       (GladeProjectWindow *gpw);
+void glade_project_window_refresh_undo_redo   (void);
 
 G_END_DECLS
 

--=-GLgbORrCDl3P4iJzVrJN--





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