[Github-comments] [geany/geany-plugins] Disable menu general menu item in case of unsupported file type (#922)
LarsGit223
notifications at xxxxx
Sun Oct 6 13:24:29 UTC 2019
LarsGit223 requested changes on this pull request.
> @@ -338,6 +351,31 @@ void cb_table_convert_type(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gp
convert_to_table(TRUE, GPOINTER_TO_INT(gdata));
}
+void cb_table_convert_change_document(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata)
This is a local function so IMHO it should be static and only declared in ```tableconvert.c``` not in ```tableconvert.h```.
> @@ -338,6 +351,31 @@ void cb_table_convert_type(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gp
convert_to_table(TRUE, GPOINTER_TO_INT(gdata));
}
+void cb_table_convert_change_document(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata)
+{
+ set_activate_state();
+}
+
+void set_activate_state()
+{
The same here. This is only a static function.
> @@ -71,5 +71,7 @@ extern TableConvertRule tablerules[];
extern void cb_table_convert(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata);
extern void cb_table_convert_type(G_GNUC_UNUSED GtkMenuItem *menuitem, gpointer gdata);
extern void convert_to_table(gboolean header, gint file_type);
+extern void cb_table_convert_change_document(G_GNUC_UNUSED GtkMenuItem *menuitem, gpointer gdata);
+extern void set_activate_state();
I suggest to move this two function declarations above to the beginning of ```tableconvert.c```. And I would remove the not required ```extern```.
> @@ -338,6 +351,31 @@ void cb_table_convert_type(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gp
convert_to_table(TRUE, GPOINTER_TO_INT(gdata));
}
+void cb_table_convert_change_document(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata)
+{
+ set_activate_state();
+}
+
+void set_activate_state()
+{
+ // getting document
+ GeanyDocument *doc = NULL;
+ doc = document_get_current();
+
+ if (
+ doc != NULL && (
This should also check if there is a current selection or not. The function ```convert_to_table()``` is only doing something if there is a selection (```if (sci_has_selection(doc->editor->sci)) ...```).
> @@ -35,6 +35,19 @@ PLUGIN_SET_TRANSLATABLE_INFO(
GeanyPlugin *geany_plugin;
GeanyData *geany_data;
+
+PluginCallback plugin_callbacks[] =
+{
+ { "editor-notify", (GCallback) &cb_table_convert_change_document, FALSE, NULL },
+ { "document-activate", (GCallback) &cb_table_convert_change_document, FALSE, NULL },
+ { "document-filetype-set", (GCallback) &cb_table_convert_change_document, FALSE, NULL },
+ { "document-new", (GCallback) &cb_table_convert_change_document, FALSE, NULL},
+ { "geany-startup-complete", (GCallback) &cb_table_convert_change_document, FALSE, NULL },
+ { "document-close", (GCallback) &cb_table_convert_change_document, FALSE, NULL},
+ { NULL, NULL, FALSE, NULL }
+};
Do you really need all of this callbacks? I guess at least ```geany-startup-complete``` is not required or am I overseeing something?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/922#pullrequestreview-297838319
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20191006/76ea9eb5/attachment.html>
More information about the Github-comments
mailing list