[geany/geany-plugins] 1083fe: pohelper: Make menu sensitivity depend on current document

Colomban Wendling git-noreply at xxxxx
Sat May 11 23:02:47 UTC 2013


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 11 May 2013 23:02:47 UTC
Commit:      1083fee4f0d8345c9cb4f57c691f8e43756c15a3
             https://github.com/geany/geany-plugins/commit/1083fee4f0d8345c9cb4f57c691f8e43756c15a3

Log Message:
-----------
pohelper: Make menu sensitivity depend on current document


Modified Paths:
--------------
    pohelper/src/gph-plugin.c

Modified: pohelper/src/gph-plugin.c
39 files changed, 39 insertions(+), 0 deletions(-)
===================================================================
@@ -472,6 +472,39 @@ enum {
 }
 
 static void
+update_menus (GeanyDocument *doc)
+{
+  if (plugin.menu_item) {
+    gtk_widget_set_sensitive (plugin.menu_item, doc_is_po (doc));
+  }
+}
+
+static void
+on_document_activate (GObject        *obj,
+                      GeanyDocument  *doc,
+                      gpointer        user_data)
+{
+  update_menus (doc);
+}
+
+static void
+on_document_filetype_set (GObject        *obj,
+                          GeanyDocument  *doc,
+                          GeanyFiletype  *old_ft,
+                          gpointer        user_data)
+{
+  update_menus (doc);
+}
+
+static void
+on_document_close (GObject       *obj,
+                   GeanyDocument *doc,
+                   gpointer       user_data)
+{
+  update_menus (NULL);
+}
+
+static void
 on_kb_goto_prev (guint key_id)
 {
   goto_prev (document_get_current ());
@@ -1159,6 +1192,12 @@ enum {
   }
   
   /* signal handlers */
+  plugin_signal_connect (geany_plugin, NULL, "document-activate", TRUE,
+                         G_CALLBACK (on_document_activate), NULL);
+  plugin_signal_connect (geany_plugin, NULL, "document-filetype-set", TRUE,
+                         G_CALLBACK (on_document_filetype_set), NULL);
+  plugin_signal_connect (geany_plugin, NULL, "document-close", TRUE,
+                         G_CALLBACK (on_document_close), NULL);
   plugin_signal_connect (geany_plugin, NULL, "document-before-save", TRUE,
                          G_CALLBACK (on_document_save), NULL);
   



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list