[Github-comments] [geany-plugins] Add new "Lineoperations" plugin (#324)

Colomban Wendling notifications at xxxxx
Sun Jan 17 13:57:32 UTC 2016


> +	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), rmemtyln_item);
> +	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), rmwhspln_item);
> +	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), sep2);
> +	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), sortasc_item);
> +	gtk_menu_shell_append(GTK_MENU_SHELL(submenu), sortdesc_item);
> +
> +	gtk_menu_item_set_submenu(GTK_MENU_ITEM(main_menu_item), submenu);
> +
> +	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), main_menu_item);
> +
> +
> +	g_signal_connect(rmdupst_item, "activate", G_CALLBACK(action_rmdupst_item), NULL);
> +	g_signal_connect(rmdupln_item, "activate", G_CALLBACK(action_rmdupln_item), NULL);
> +	g_signal_connect(rmunqln_item, "activate", G_CALLBACK(action_rmunqln_item), NULL);
> +	g_signal_connect(rmemtyln_item, "activate", G_CALLBACK(action_rmemtyln_item), NULL);
> +	g_signal_connect(rmwhspln_item, "activate", G_CALLBACK(action_rmwhspln_item), NULL);

you could lower duplication of the wrapper callbacks by having a single callback that calls the appropriate function (either passed as parameter [1] or referenced as an ID or something), as they all have they all behave the same (but the sort ones).
You may or may not want this, it's merely a suggestion.  And it's even a bad one if you expect to alter the various functions to receive different parameters in the future.

[1] technically in plain C you're not supposed to convert a function pointer to a data pointer.  However, GTK depends on this and it effectively works on all supported platforms (if not all platforms in general).

---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/324/files#r49946615
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160117/e21b51f0/attachment.html>


More information about the Github-comments mailing list