[Glade-devel] [patch, glade3] insensitive Cut,Copy etc in popup menu



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

Il dom, 2003-05-11 alle 22:37, Joaquin Cuenca Abela ha scritto:
Paolo, making the menu items insensitive when the action is not allowed
will give you several love points ;-)

Here it is a ten minutes patch which should do.
For paste it works ok, note however that currently there is always a
widget selected so copy, cut and delete end up being always sensitive.
What I mean is that when you add a vbox and select one of its slots,
even if is empty, copy/cut work: they put the whole vbox on the
clipboard. I don't know if this is a bug or if it is the intended
behaviour.
If it is the intended behaviour can you suggest when the items should be
unsensitive?

PS: the patch is not against latest cvs because I wanted to send it out
yesterday, but I was in hurry for the Pat Metheny show :) anyway it
should apply fine.

ciao
        paolo

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

diff -upr gnome2/glade3/ChangeLog glade3/ChangeLog
--- gnome2/glade3/ChangeLog     2003-05-12 18:36:12.000000000 +0200
+++ glade3/ChangeLog    2003-05-13 15:25:04.000000000 +0200
@@ -1,3 +1,8 @@
+2003-05-12  Paolo Borelli  <pborelli katamail com>
+
+       * src/glade-popup.c: make popup menu items insensitive when 
+       appropriate.
+
 2003-05-11  Joaquin Cuenca Abela  <e98cuenc yahoo com>
 
        * src/glade-command.c: fix cut & paste undo commands.  We should
diff -upr gnome2/glade3/src/glade-popup.c glade3/src/glade-popup.c
--- gnome2/glade3/src/glade-popup.c     2003-05-12 18:36:15.000000000 +0200
+++ glade3/src/glade-popup.c    2003-05-13 15:21:56.000000000 +0200
@@ -140,18 +140,34 @@ static GtkWidget *
 glade_popup_create_menu (GladeWidget *widget, gboolean add_childs)
 {
        GtkWidget *popup_menu;
+       GladeProjectWindow *gpw;
+       gboolean cut_sens = FALSE;
+       gboolean copy_sens = FALSE;
+       gboolean paste_sens = FALSE;
+       gboolean del_sens = FALSE;
 
        popup_menu = gtk_menu_new ();
 
+       gpw = glade_project_window_get ();
+
+       /* check which items should be sensitive */
+       if (gpw->active_widget != NULL) {
+               cut_sens = TRUE;
+               copy_sens = TRUE;
+               del_sens = TRUE;
+       }
+       if (gpw->clipboard->curr != NULL)
+               paste_sens = TRUE;
+
        glade_popup_append_item (popup_menu, NULL, _("_Select"), TRUE,
                                 glade_popup_select_cb, widget);
-       glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, TRUE,
+       glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, cut_sens,
                                 glade_popup_cut_cb, widget);
-       glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, TRUE,
+       glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, copy_sens,
                                 glade_popup_copy_cb, widget);
-       glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, TRUE,
+       glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, paste_sens,
                                 glade_popup_paste_cb, widget);
-       glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, TRUE,
+       glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, del_sens,
                                 glade_popup_delete_cb, widget);
 
        if (add_childs && widget->parent)
@@ -165,10 +181,18 @@ glade_popup_create_placeholder_menu (Gla
 {
        GtkWidget *popup_menu;
        GladeWidget *parent;
+       GladeProjectWindow *gpw;
+       gboolean paste_sens = FALSE;
        
        popup_menu = gtk_menu_new ();
 
-       glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, TRUE,
+       gpw = glade_project_window_get ();
+
+       /* check if paste should be sensitive */
+       if (gpw->clipboard->curr != NULL)
+               paste_sens = TRUE;
+
+       glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, paste_sens,
                                 glade_popup_placeholder_paste_cb, placeholder);
 
        if ((parent = glade_placeholder_get_parent(placeholder)) != NULL)

--=-UsAm8qSx49PKB9gXic3D--





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