From: Jim Evins Date: Fri, 4 Dec 2009 02:31:24 +0000 (-0500) Subject: Follow focus when setting sensitivity of selection verbs X-Git-Tag: glabels-2_3_0~122 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=520ea9f42482012404000e7eebe436c94bca4440;p=glabels Follow focus when setting sensitivity of selection verbs The previous commit did not completely work right. Selection verb sensitivity now follows the focus of the glView widget. --- diff --git a/src/ui.c b/src/ui.c index ae190dcc..f62231c3 100644 --- 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)); diff --git a/src/ui.h b/src/ui.h index 81f36673..f6db062b 100644 --- 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); diff --git a/src/window.c b/src/window.c index 7a7f7a66..c9896605 100644 --- a/src/window.c +++ b/src/window.c @@ -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); }