]> git.sur5r.net Git - glabels/commitdiff
Follow focus when setting sensitivity of selection verbs
authorJim Evins <evins@snaught.com>
Fri, 4 Dec 2009 02:31:24 +0000 (21:31 -0500)
committerJim Evins <evins@snaught.com>
Fri, 4 Dec 2009 02:35:38 +0000 (21:35 -0500)
The previous commit did not completely work right.  Selection verb
sensitivity now follows the focus of the glView widget.

src/ui.c
src/ui.h
src/window.c

index ae190dccbdfa381103533334da1a2b478fa5c18f..f62231c31ea92ead533813bb920a902155e4989e 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -862,13 +862,13 @@ gl_ui_update_modified_verbs (GtkUIManager *ui,
 /*****************************************************************************/
 void
 gl_ui_update_selection_verbs (GtkUIManager *ui,
-                             glView       *view)
+                             glView       *view,
+                              gboolean      has_focus)
 {
        gl_debug (DEBUG_UI, "START");
 
-        if ( gtk_widget_has_focus (GTK_WIDGET (view->canvas)) )
+        if ( has_focus )
         {
-
                 gl_ui_util_set_verb_list_sensitive (ui, selection_verbs,
                                                     !gl_label_is_selection_empty (view->label));
 
index 81f366736f81177e15aafc964042658e05871e0d..f6db062b28374cc9e61d8b847edd4c29ba90618d 100644 (file)
--- a/src/ui.h
+++ b/src/ui.h
@@ -43,7 +43,8 @@ void          gl_ui_update_modified_verbs  (GtkUIManager      *ui,
                                            glLabel           *label);
 
 void          gl_ui_update_selection_verbs (GtkUIManager      *ui,
-                                           glView            *view);
+                                           glView            *view,
+                                            gboolean           has_focus);
 
 void          gl_ui_update_zoom_verbs      (GtkUIManager      *ui,
                                            glView            *view);
index 7a7f7a660c3d884fae060e01656cb68e448956ed..c98966055d5a39df0cc8f5ce733723dcc1d86f40 100644 (file)
@@ -102,8 +102,8 @@ static void     focus_widget_changed_cb(GtkWindow     *gtk_window,
                                         GtkWidget     *widget,
                                        glWindow      *window);
 
-static void     set_paste_sensitivity  (glWindow      *window,
-                                        GtkWidget     *focus_widget);
+static void     set_copy_paste_sensitivity  (glWindow      *window,
+                                             GtkWidget     *focus_widget);
 
 
 /****************************************************************************/
@@ -441,7 +441,7 @@ gl_window_set_label (glWindow    *window,
 
         /* Initialize "Paste" sensitivity. */
         focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
-        set_paste_sensitivity (window, focus_widget);
+        set_copy_paste_sensitivity (window, focus_widget);
 
        gl_debug (DEBUG_WINDOW, "END");
 }
@@ -523,7 +523,7 @@ selection_changed_cb (glLabel  *label,
        g_return_if_fail (label && GL_IS_LABEL (label));
        g_return_if_fail (window && GL_IS_WINDOW (window));
 
-        gl_ui_update_selection_verbs (window->ui, GL_VIEW (window->view));
+        gl_ui_update_selection_verbs (window->ui, GL_VIEW (window->view), TRUE);
 
        gl_debug (DEBUG_WINDOW, "END");
 }
@@ -688,7 +688,7 @@ clipboard_changed_cb (GtkClipboard *clipboard,
        g_return_if_fail (window && GL_IS_WINDOW (window));
 
         focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
-        set_paste_sensitivity (window, focus_widget);
+        set_copy_paste_sensitivity (window, focus_widget);
 
        gl_debug (DEBUG_WINDOW, "END");
 }
@@ -712,7 +712,7 @@ focus_widget_changed_cb (GtkWindow *gtk_window,
                           widget,
                           G_OBJECT_TYPE_NAME (widget));
 
-                set_paste_sensitivity (window, widget);
+                set_copy_paste_sensitivity (window, widget);
         }
 
        gl_debug (DEBUG_WINDOW, "END");
@@ -723,8 +723,8 @@ focus_widget_changed_cb (GtkWindow *gtk_window,
 /** PRIVATE.  Set paste sensitivity.                                         */
 /*---------------------------------------------------------------------------*/
 static void
-set_paste_sensitivity (glWindow  *window,
-                       GtkWidget *focus_widget)
+set_copy_paste_sensitivity (glWindow  *window,
+                            GtkWidget *focus_widget)
 {
         GtkClipboard *glabels_clipboard;
 
@@ -737,11 +737,15 @@ set_paste_sensitivity (glWindow  *window,
 
         if ( focus_widget == GL_VIEW(window->view)->canvas )
         {
+                gl_ui_update_selection_verbs (window->ui, GL_VIEW (window->view), TRUE);
+
                 gl_ui_update_paste_verbs (window->ui,
                                           gtk_clipboard_wait_is_text_available (glabels_clipboard));
+
         }
         else
         {
+                gl_ui_update_selection_verbs (window->ui, GL_VIEW (window->view), FALSE);
                 gl_ui_update_paste_verbs (window->ui, FALSE);
         }