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?