[gedit-plugins/gnome-3-10] bookmarks: Update action group sensitivity



commit 7ae3bc899f4ae34e25b9d158044c6d2e3ef38029
Author: Volker Sobek <reklov live com>
Date:   Sun Nov 24 14:57:18 2013 +0100

    bookmarks: Update action group sensitivity
    
    Fix crash that occurred on the toggle bookmark action when no document
    was open. It was possible to trigger the crash because the actions for
    the plugin were always sensitive, even when there was no open
    document.
    
    Additionally protect against NULL in toggle_bookmark.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=715117

 plugins/bookmarks/gedit-bookmarks-plugin.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/plugins/bookmarks/gedit-bookmarks-plugin.c b/plugins/bookmarks/gedit-bookmarks-plugin.c
index 994bc63..452ead5 100644
--- a/plugins/bookmarks/gedit-bookmarks-plugin.c
+++ b/plugins/bookmarks/gedit-bookmarks-plugin.c
@@ -769,6 +769,16 @@ gedit_bookmarks_plugin_activate (GeditWindowActivatable *activatable)
 }
 
 static void
+gedit_bookmarks_plugin_update_state (GeditWindowActivatable *activatable)
+{
+       GeditBookmarksPluginPrivate *priv;
+
+       priv = GEDIT_BOOKMARKS_PLUGIN (activatable)->priv;
+       gtk_action_group_set_sensitive (priv->action_group,
+                                       gedit_window_get_active_view (priv->window) != NULL);
+}
+
+static void
 save_bookmark_metadata (GeditView *view)
 {
        GtkTextIter iter;
@@ -1082,6 +1092,11 @@ toggle_bookmark (GtkSourceBuffer *buffer,
        GtkTextIter start;
        GtkSourceMark *bookmark = NULL;
 
+       if (buffer == NULL)
+       {
+               return;
+       }
+
        bookmark = get_bookmark_and_iter (buffer, iter, &start);
 
        if (bookmark != NULL)
@@ -1101,6 +1116,7 @@ on_toggle_bookmark_activate (GtkAction            *action,
        GtkSourceBuffer *buffer;
 
        buffer = GTK_SOURCE_BUFFER (gedit_window_get_active_document (plugin->priv->window));
+
        toggle_bookmark (buffer, NULL);
 }
 
@@ -1191,6 +1207,7 @@ gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface)
 {
        iface->activate = gedit_bookmarks_plugin_activate;
        iface->deactivate = gedit_bookmarks_plugin_deactivate;
+       iface->update_state = gedit_bookmarks_plugin_update_state;
 }
 
 G_MODULE_EXPORT void


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