[Glade-devel] [patch, glade3] turn "how Clipboard" into a toggle item



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

This is the second part of the patch that went in some days ago. It turn also "Show Clipboard" into a toggle 
button.

PS
Joaquin: the two trivial patches deleting gpw_widget_tree_keypress_cb and changing the "save as" stock item 
simply got lost or you didn't merge them because they were broken? 

--=-54TRvhHndnhEwMXAuzxY
Content-Disposition: attachment; filename=toggle-clipboard.patch
Content-Type: text/x-patch; name=toggle-clipboard.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -pur gnome2/glade3/ChangeLog glade3/ChangeLog
--- gnome2/glade3/ChangeLog     2003-03-13 23:21:06.000000000 +0100
+++ glade3/ChangeLog    2003-03-13 23:26:44.000000000 +0100
@@ -1,3 +1,11 @@
+2003-03-13 Paolo Borelli <pborelli katamail com>
+
+       * src/glade-project-window.c: turn also the "Show Clipboard" menu item
+       into a toggle item.
+       * src/glade-clipboard.[ch]: removed glade_clipboard_create() and
+       glade_clipboard_show_view(), replaced by equivalent static functions 
+       in glade-project-window.c where they belong.
+
 2003-03-12  Joaquin Cuenca Abela  <e98cuenc yahoo com>
 
        * src/glade-property-class.c: fix a memory leak, and remove yet another

diff -pur gnome2/glade3/src/glade-clipboard.c glade3/src/glade-clipboard.c
--- gnome2/glade3/src/glade-clipboard.c 2002-05-02 11:11:09.000000000 +0200
+++ glade3/src/glade-clipboard.c        2003-03-13 23:17:09.000000000 +0100
@@ -253,36 +253,3 @@ glade_clipboard_paste (GladeClipboard * 
        glade_clipboard_remove (clipboard, widget);
 }
 
-void
-glade_clipboard_create (GladeProjectWindow * gpw)
-{
-       g_return_if_fail (gpw != NULL);
-
-       if (gpw->clipboard == NULL) {
-               GladeClipboard *clipboard;
-
-               clipboard = glade_clipboard_new ();
-               gpw->clipboard = clipboard;
-       }
-}
-
-void
-glade_clipboard_show_view (GladeProjectWindow * gpw)
-{
-       g_return_if_fail (gpw != NULL);
-
-       if (gpw->clipboard->view == NULL) {
-               GtkWidget *view;
-
-               view = glade_clipboard_view_new (gpw->clipboard);
-               gtk_window_set_title (GTK_WINDOW (view), _("Clipboard"));
-               g_signal_connect_data (G_OBJECT (view), "delete_event",
-                                      G_CALLBACK (gtk_widget_hide),
-                                      view, NULL, 0);
-
-               gpw->clipboard->view = view;
-       }
-
-       if (!GTK_WIDGET_VISIBLE (gpw->clipboard->view))
-               gtk_widget_show (GTK_WIDGET (gpw->clipboard->view));
-}
diff -pur gnome2/glade3/src/glade-clipboard.h glade3/src/glade-clipboard.h
--- gnome2/glade3/src/glade-clipboard.h 2002-03-18 09:39:43.000000000 +0100
+++ glade3/src/glade-clipboard.h        2003-03-13 19:53:48.000000000 +0100
@@ -32,8 +32,5 @@ void glade_clipboard_copy (GladeClipboar
 void glade_clipboard_paste (GladeClipboard * clipboard,
                            GladePlaceholder * placeholder);
 
-void glade_clipboard_create (GladeProjectWindow * gpw);
-void glade_clipboard_show_view (GladeProjectWindow * gpw);
-
 G_END_DECLS
 #endif                         /* __GLADE_CLIPBOARD_H__ */
diff -pur gnome2/glade3/src/glade-project-window.c glade3/src/glade-project-window.c
--- gnome2/glade3/src/glade-project-window.c    2003-03-11 15:22:01.000000000 +0100
+++ glade3/src/glade-project-window.c   2003-03-13 20:14:49.000000000 +0100
@@ -28,6 +28,7 @@
 #include "glade-palette.h"
 #include "glade-editor.h"
 #include "glade-clipboard.h"
+#include "glade-clipboard-view.h"
 #include "glade-widget.h"
 #include "glade-widget-class.h"
 #include "glade-parameter.h"
@@ -50,7 +51,7 @@ static void gpw_quit_cb (void);
 static void gpw_toggle_palette_cb (void);
 static void gpw_toggle_editor_cb (void);
 static void gpw_toggle_widget_tree_cb (void);
-static void gpw_show_clipboard_cb (void);
+static void gpw_toggle_clipboard_cb (void);
 
 static void gpw_undo_cb (void);
 static void gpw_redo_cb (void);
@@ -219,8 +220,7 @@ static GtkItemFactoryEntry menu_items[] 
   { "/View/_Palette",         NULL, gpw_toggle_palette_cb,     0, "<ToggleItem>" },
   { "/View/Property _Editor", NULL, gpw_toggle_editor_cb,      0, "<ToggleItem>" },
   { "/View/_Widget Tree",     NULL, gpw_toggle_widget_tree_cb, 0, "<ToggleItem>" },
-  { "/View/sep1",             NULL, NULL,                      0, "<Separator>" },
-  { "/View/Show _Clipboard",  NULL, gpw_show_clipboard_cb,     0, "<Item>" },
+  { "/View/_Clipboard",       NULL, gpw_toggle_clipboard_cb,   0, "<ToggleItem>" },
 
   /* ============ PROJECT=================== */
   { "/Project", NULL, 0, 0, "<Branch>" },
@@ -530,6 +509,90 @@ gpw_hide_widget_tree (GladeProjectWindow
 
 }
 
+static void 
+gpw_create_clipboard (GladeProjectWindow *gpw)
+{
+       g_return_if_fail (gpw != NULL);
+
+       if (gpw->clipboard == NULL) {
+               GladeClipboard *clipboard;
+
+               clipboard = glade_clipboard_new ();
+               gpw->clipboard = clipboard;
+       }
+}
+
+static gboolean
+gpw_hide_clipboard_view_on_delete (GtkWidget *clipboard_view, gpointer not_used,
+               GtkItemFactory *item_factory)
+{
+       GtkWidget *clipboard_item;
+
+       gtk_widget_hide (clipboard_view);
+
+       clipboard_item = gtk_item_factory_get_item (item_factory,
+                                                   "<main>/View/Clipboard");
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (clipboard_item), FALSE);
+
+       /* return true so that the clipboard view is not destroyed */
+       return TRUE;
+}
+
+static void 
+gpw_create_clipboard_view (GladeProjectWindow *gpw)
+{
+       GtkWidget *view;
+       GtkWidget *clipboard_item;
+
+       gpw_create_clipboard (gpw);
+       
+       view = glade_clipboard_view_new (gpw->clipboard);
+       gtk_window_set_title (GTK_WINDOW (view), _("Clipboard"));
+       g_signal_connect (G_OBJECT (view), "delete_event",
+                         G_CALLBACK (gpw_hide_clipboard_view_on_delete),
+                         gpw->item_factory);
+       gpw->clipboard->view = view;
+
+       clipboard_item = gtk_item_factory_get_item (gpw->item_factory,
+                                                   "<main>/View/Clipboard");
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (clipboard_item), TRUE);
+}
+
+static void
+gpw_show_clipboard_view (GladeProjectWindow *gpw)
+{
+       GtkWidget *clipboard_item;
+
+       g_return_if_fail (gpw != NULL);
+
+       if (gpw->clipboard == NULL)
+               gpw_create_clipboard (gpw);
+
+       if (gpw->clipboard->view == NULL)
+               gpw_create_clipboard_view (gpw);
+       
+       gtk_widget_show_all (GTK_WIDGET (gpw->clipboard->view));
+
+       clipboard_item = gtk_item_factory_get_item (gpw->item_factory,
+                                                   "<main>/View/Clipboard");
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (clipboard_item), TRUE);
+}
+
+static void
+gpw_hide_clipboard_view (GladeProjectWindow *gpw)
+{
+       GtkWidget *clipboard_item;
+
+       g_return_if_fail (gpw != NULL);
+
+       gtk_widget_hide (GTK_WIDGET (gpw->clipboard->view));
+
+       clipboard_item = gtk_item_factory_get_item (gpw->item_factory,
+                                                   "<main>/View/Clipboard");
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (clipboard_item), FALSE);
+
+}
+
 static void
 gpw_toggle_palette_cb (void)
 {
@@ -579,11 +642,19 @@ gpw_toggle_widget_tree_cb (void) 
 }
 
 static void
-gpw_show_clipboard_cb (void)
+gpw_toggle_clipboard_cb (void)
 {
+       GtkWidget *clipboard_item;
+
        GladeProjectWindow *gpw = glade_project_window_get ();
 
-       glade_clipboard_show_view (gpw);
+       clipboard_item = gtk_item_factory_get_item (gpw->item_factory,
+                                                   "<main>/View/Clipboard");
+
+       if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (clipboard_item)))
+               gpw_show_clipboard_view (gpw);
+       else
+               gpw_hide_clipboard_view (gpw);
 }
 
 static GtkWidget *
@@ -651,7 +722,7 @@ glade_project_window_new (GList *catalog
        glade_project_window = gpw;
        gpw_create_palette (gpw);
        gpw_create_editor  (gpw);
-       glade_clipboard_create (gpw);
+       gpw_create_clipboard (gpw);
        
        return gpw;
 }

--=-54TRvhHndnhEwMXAuzxY--





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