lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
List overview
Plugins-Commits
July 2019
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
plugins-commits@lists.geany.org
1 participants
35 discussions
Start a n
N
ew thread
[geany/geany-plugins] f922a5: Merge pull request #864 from LarsGit223/treebrowser-gtk3
by Frank Lanitz
02 Jul '19
02 Jul '19
Branch: refs/heads/master Author: Frank Lanitz <frank(a)frank.uvena.de> Committer: GitHub <noreply(a)github.com> Date: Tue, 02 Jul 2019 07:31:21 UTC Commit: f922a57a7f68218537cd2aa5e2cbcef84d076865
https://github.com/geany/geany-plugins/commit/f922a57a7f68218537cd2aa5e2cbc…
Log Message: ----------- Merge pull request #864 from LarsGit223/treebrowser-gtk3 treebrowser: fixed deprecated gtk calls for gtk3 Modified Paths: -------------- build/treebrowser.m4 treebrowser/src/Makefile.am treebrowser/src/treebrowser.c Modified: build/treebrowser.m4 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -1,6 +1,8 @@ AC_DEFUN([GP_CHECK_TREEBROWSER], [ GP_ARG_DISABLE([Treebrowser], [auto]) + GP_CHECK_UTILSLIB([Treebrowser]) + if [[ "$enable_treebrowser" != no ]]; then AC_CHECK_FUNC([creat], [enable_treebrowser=yes], Modified: treebrowser/src/Makefile.am 6 lines changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -5,8 +5,10 @@ geanyplugins_LTLIBRARIES = treebrowser.la treebrowser_la_SOURCES = treebrowser.c treebrowser_la_CPPFLAGS = $(AM_CPPFLAGS) -DG_LOG_DOMAIN=\"TreeBrowser\" -treebrowser_la_CFLAGS = $(AM_CFLAGS) $(GIO_CFLAGS) -treebrowser_la_LIBADD = $(COMMONLIBS) $(GIO_LIBS) +treebrowser_la_CFLAGS = $(AM_CFLAGS) $(GIO_CFLAGS) \ + -I$(top_srcdir)/utils/src +treebrowser_la_LIBADD = $(COMMONLIBS) $(GIO_LIBS) \ + $(top_builddir)/utils/src/libgeanypluginutils.la AM_CPPCHECKFLAGS = --suppress='deallocDealloc:$(srcdir)/treebrowser.c' AM_CPPCHECKFLAGS += --suppress='doubleFree:$(srcdir)/treebrowser.c' Modified: treebrowser/src/treebrowser.c 236 lines changed, 235 insertions(+), 1 deletions(-) =================================================================== @@ -18,6 +18,7 @@ #include "geany.h" #include "geanyplugin.h" +#include <gp_gtkcompat.h> #include <gio/gio.h> @@ -179,6 +180,27 @@ tree_view_row_expanded_iter(GtkTreeView *tree_view, GtkTreeIter *iter) return expanded; } +#if GTK_CHECK_VERSION(3, 10, 0) +static GdkPixbuf * +utils_pixbuf_from_name(const gchar *icon_name) +{ + GError *error = NULL; + GtkIconTheme *icon_theme; + GdkPixbuf *pixbuf; + + icon_theme = gtk_icon_theme_get_default (); + pixbuf = gtk_icon_theme_load_icon(icon_theme, icon_name, 16, 0, &error); + + if (!pixbuf) + { + g_warning("Couldn't load icon: %s", error->message); + g_error_free(error); + return NULL; + } + + return pixbuf; +} +#else static GdkPixbuf * utils_pixbuf_from_stock(const gchar *stock_id) { @@ -192,6 +214,7 @@ utils_pixbuf_from_stock(const gchar *stock_id) GTK_STATE_NORMAL, GTK_ICON_SIZE_MENU, NULL, NULL); return NULL; } +#endif static GdkPixbuf * utils_pixbuf_from_path(gchar *path) @@ -405,16 +428,31 @@ static gboolean treebrowser_checkdir(gchar *directory) { gboolean is_dir; + static gboolean old_value = TRUE; +#if !GTK_CHECK_VERSION(3, 0, 0) static const GdkColor red = {0, 0xffff, 0x6666, 0x6666}; static const GdkColor white = {0, 0xffff, 0xffff, 0xffff}; - static gboolean old_value = TRUE; +#endif is_dir = g_file_test(directory, G_FILE_TEST_IS_DIR); if (old_value != is_dir) { +#if GTK_CHECK_VERSION(3, 0, 0) + GtkStyleContext *context; + context = gtk_widget_get_style_context(GTK_WIDGET(addressbar)); + if (is_dir) + { + gtk_style_context_remove_class(context, "invalid"); + } + else + { + gtk_style_context_add_class(context, "invalid"); + } +#else gtk_widget_modify_base(GTK_WIDGET(addressbar), GTK_STATE_NORMAL, is_dir ? NULL : &red); gtk_widget_modify_text(GTK_WIDGET(addressbar), GTK_STATE_NORMAL, is_dir ? NULL : &white); +#endif old_value = is_dir; } @@ -516,7 +554,11 @@ treebrowser_browse(gchar *directory, gpointer parent) gtk_tree_iter_free(last_dir_iter); } last_dir_iter = gtk_tree_iter_copy(&iter); +#if GTK_CHECK_VERSION(3, 10, 0) + icon = CONFIG_SHOW_ICONS ? utils_pixbuf_from_name("folder") : NULL; +#else icon = CONFIG_SHOW_ICONS ? utils_pixbuf_from_stock(GTK_STOCK_DIRECTORY) : NULL; +#endif gtk_tree_store_set(treestore, &iter, TREEBROWSER_COLUMN_ICON, icon, TREEBROWSER_COLUMN_NAME, fname, @@ -536,7 +578,11 @@ treebrowser_browse(gchar *directory, gpointer parent) icon = CONFIG_SHOW_ICONS == 2 ? utils_pixbuf_from_path(uri) : CONFIG_SHOW_ICONS +#if GTK_CHECK_VERSION(3, 10, 0) + ? utils_pixbuf_from_name("text-x-generic") +#else ? utils_pixbuf_from_stock(GTK_STOCK_FILE) +#endif : NULL; gtk_tree_store_append(treestore, &iter, parent); gtk_tree_store_set(treestore, &iter, @@ -610,7 +656,11 @@ treebrowser_load_bookmarks(void) else { gtk_tree_store_prepend(treestore, &bookmarks_iter, NULL); +#if GTK_CHECK_VERSION(3, 10, 0) + icon = CONFIG_SHOW_ICONS ? utils_pixbuf_from_name("go-home") : NULL; +#else icon = CONFIG_SHOW_ICONS ? utils_pixbuf_from_stock(GTK_STOCK_HOME) : NULL; +#endif gtk_tree_store_set(treestore, &bookmarks_iter, TREEBROWSER_COLUMN_ICON, icon, TREEBROWSER_COLUMN_NAME, _("Bookmarks"), @@ -646,7 +696,11 @@ treebrowser_load_bookmarks(void) gchar *file_name = g_path_get_basename(path_full); gtk_tree_store_append(treestore, &iter, &bookmarks_iter); +#if GTK_CHECK_VERSION(3, 10, 0) + icon = CONFIG_SHOW_ICONS ? utils_pixbuf_from_name("folder") : NULL; +#else icon = CONFIG_SHOW_ICONS ? utils_pixbuf_from_stock(GTK_STOCK_DIRECTORY) : NULL; +#endif gtk_tree_store_set(treestore, &iter, TREEBROWSER_COLUMN_ICON, icon, TREEBROWSER_COLUMN_NAME, file_name, @@ -1197,15 +1251,27 @@ create_popup_menu(const gchar *name, const gchar *uri) gboolean is_dir = is_exists ? g_file_test(uri, G_FILE_TEST_IS_DIR) : FALSE; gboolean is_document = document_find_by_filename(uri) != NULL ? TRUE : FALSE; +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("go-up", _("Go _Up")); +#else item = ui_image_menu_item_new(GTK_STOCK_GO_UP, _("Go _Up")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_go_up), NULL); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("go-up", _("Set _Path From Document")); +#else item = ui_image_menu_item_new(GTK_STOCK_GO_UP, _("Set _Path From Document")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_current_path), NULL); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("document-open", _("_Open Externally")); +#else item = ui_image_menu_item_new(GTK_STOCK_OPEN, _("_Open Externally")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect_data(item, "activate", G_CALLBACK(on_menu_open_externally), g_strdup(uri), (GClosureNotify)g_free, 0); gtk_widget_set_sensitive(item, is_exists); @@ -1214,55 +1280,95 @@ create_popup_menu(const gchar *name, const gchar *uri) gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect_data(item, "activate", G_CALLBACK(on_menu_open_terminal), g_strdup(uri), (GClosureNotify)g_free, 0); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("go-top", _("Set as _Root")); +#else item = ui_image_menu_item_new(GTK_STOCK_GOTO_TOP, _("Set as _Root")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect_data(item, "activate", G_CALLBACK(on_menu_set_as_root), g_strdup(uri), (GClosureNotify)g_free, 0); gtk_widget_set_sensitive(item, is_dir); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("view-refresh", _("Refres_h")); +#else item = ui_image_menu_item_new(GTK_STOCK_REFRESH, _("Refres_h")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_refresh), NULL); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("edit-find", _("_Find in Files")); +#else item = ui_image_menu_item_new(GTK_STOCK_FIND, _("_Find in Files")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect_data(item, "activate", G_CALLBACK(on_menu_find_in_files), g_strdup(uri), (GClosureNotify)g_free, 0); gtk_widget_set_sensitive(item, is_dir); item = gtk_separator_menu_item_new(); gtk_container_add(GTK_CONTAINER(menu), item); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("list-add", _("N_ew Folder")); +#else item = ui_image_menu_item_new(GTK_STOCK_ADD, _("N_ew Folder")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_create_new_object), (gpointer)"directory"); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("document-new", _("_New File")); +#else item = ui_image_menu_item_new(GTK_STOCK_NEW, _("_New File")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_create_new_object), (gpointer)"file"); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("document-save-as", _("Rena_me")); +#else item = ui_image_menu_item_new(GTK_STOCK_SAVE_AS, _("Rena_me")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_rename), NULL); gtk_widget_set_sensitive(item, is_exists); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("edit-delete", _("_Delete")); +#else item = ui_image_menu_item_new(GTK_STOCK_DELETE, _("_Delete")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_delete), NULL); gtk_widget_set_sensitive(item, is_exists); item = gtk_separator_menu_item_new(); gtk_container_add(GTK_CONTAINER(menu), item); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("window-close", g_strdup_printf(_("Close: %s"), name)); +#else item = ui_image_menu_item_new(GTK_STOCK_CLOSE, g_strdup_printf(_("Close: %s"), name)); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect_data(item, "activate", G_CALLBACK(on_menu_close), g_strdup(uri), (GClosureNotify)g_free, 0); gtk_widget_set_sensitive(item, is_document); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("window-close", g_strdup_printf(_("Clo_se Child Documents "))); +#else item = ui_image_menu_item_new(GTK_STOCK_CLOSE, g_strdup_printf(_("Clo_se Child Documents "))); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect_data(item, "activate", G_CALLBACK(on_menu_close_children), g_strdup(uri), (GClosureNotify)g_free, 0); gtk_widget_set_sensitive(item, is_dir); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("edit-copy", _("_Copy Full Path to Clipboard")); +#else item = ui_image_menu_item_new(GTK_STOCK_COPY, _("_Copy Full Path to Clipboard")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect_data(item, "activate", G_CALLBACK(on_menu_copy_uri), g_strdup(uri), (GClosureNotify)g_free, 0); gtk_widget_set_sensitive(item, is_exists); @@ -1271,11 +1377,19 @@ create_popup_menu(const gchar *name, const gchar *uri) gtk_container_add(GTK_CONTAINER(menu), item); gtk_widget_show(item); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("go-next", _("E_xpand All")); +#else item = ui_image_menu_item_new(GTK_STOCK_GO_FORWARD, _("E_xpand All")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_expand_all), NULL); +#if GTK_CHECK_VERSION(3, 10, 0) + item = ui_image_menu_item_new("go-previous", _("Coll_apse All")); +#else item = ui_image_menu_item_new(GTK_STOCK_GO_BACK, _("Coll_apse All")); +#endif gtk_container_add(GTK_CONTAINER(menu), item); g_signal_connect(item, "activate", G_CALLBACK(on_menu_collapse_all), NULL); @@ -1404,7 +1518,12 @@ on_treeview_mouseclick(GtkWidget *widget, GdkEventButton *event, GtkTreeSelectio -1); menu = create_popup_menu(name != NULL ? name : "", uri != NULL ? uri : ""); + +#if GTK_CHECK_VERSION(3, 22, 0) + gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *)event); +#else gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time); +#endif g_free(name); g_free(uri); @@ -1452,7 +1571,11 @@ on_treeview_keypress(GtkWidget *widget, GdkEventKey *event) -1); menu = create_popup_menu(name != NULL ? name : "", uri != NULL ? uri : ""); +#if GTK_CHECK_VERSION(3, 22, 0) + gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *)event); +#else gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, event->time); +#endif g_free(name); g_free(uri); @@ -1562,7 +1685,11 @@ on_treeview_row_expanded(GtkWidget *widget, GtkTreeIter *iter, GtkTreePath *path } if (CONFIG_SHOW_ICONS) { +#if GTK_CHECK_VERSION(3, 10, 0) + GdkPixbuf *icon = utils_pixbuf_from_name("document-open"); +#else GdkPixbuf *icon = utils_pixbuf_from_stock(GTK_STOCK_OPEN); +#endif gtk_tree_store_set(treestore, iter, TREEBROWSER_COLUMN_ICON, icon, -1); g_object_unref(icon); @@ -1580,7 +1707,11 @@ on_treeview_row_collapsed(GtkWidget *widget, GtkTreeIter *iter, GtkTreePath *pat return; if (CONFIG_SHOW_ICONS) { +#if GTK_CHECK_VERSION(3, 10, 0) + GdkPixbuf *icon = utils_pixbuf_from_name("folder"); +#else GdkPixbuf *icon = utils_pixbuf_from_stock(GTK_STOCK_DIRECTORY); +#endif gtk_tree_store_set(treestore, iter, TREEBROWSER_COLUMN_ICON, icon, -1); g_object_unref(icon); @@ -1712,11 +1843,29 @@ create_sidebar(void) GtkWidget *wid; GtkTreeSelection *selection; +#if GTK_CHECK_VERSION(3, 0, 0) + GtkCssProvider *provider; + GdkDisplay *display; + GdkScreen *screen; + + provider = gtk_css_provider_new (); + display = gdk_display_get_default (); + screen = gdk_display_get_default_screen (display); + gtk_style_context_add_provider_for_screen (screen, + GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_css_provider_load_from_data (GTK_CSS_PROVIDER(provider), + "#addressbar.invalid {color: #ffffff; background: #ff6666;}", + -1, NULL); +#endif + treeview = create_view_and_model(); sidebar_vbox = gtk_vbox_new(FALSE, 0); sidebar_vbox_bars = gtk_vbox_new(FALSE, 0); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); addressbar = gtk_entry_new(); +#if GTK_CHECK_VERSION(3, 10, 0) + gtk_widget_set_name(addressbar, "addressbar"); +#endif filter = gtk_entry_new(); scrollwin = gtk_scrolled_window_new(NULL, NULL); @@ -1726,32 +1875,62 @@ create_sidebar(void) gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU); gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); +#if GTK_CHECK_VERSION(3, 10, 0) + wid = gtk_image_new_from_icon_name("go-up", GTK_ICON_SIZE_SMALL_TOOLBAR); + wid = GTK_WIDGET(gtk_tool_button_new(wid, NULL)); +#else wid = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_GO_UP)); +#endif gtk_widget_set_tooltip_text(wid, _("Go up")); g_signal_connect(wid, "clicked", G_CALLBACK(on_button_go_up), NULL); gtk_container_add(GTK_CONTAINER(toolbar), wid); +#if GTK_CHECK_VERSION(3, 10, 0) + wid = gtk_image_new_from_icon_name("view-refresh", GTK_ICON_SIZE_SMALL_TOOLBAR); + wid = GTK_WIDGET(gtk_tool_button_new(wid, NULL)); +#else wid = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH)); +#endif gtk_widget_set_tooltip_text(wid, _("Refresh")); g_signal_connect(wid, "clicked", G_CALLBACK(on_button_refresh), NULL); gtk_container_add(GTK_CONTAINER(toolbar), wid); +#if GTK_CHECK_VERSION(3, 10, 0) + wid = gtk_image_new_from_icon_name("go-home", GTK_ICON_SIZE_SMALL_TOOLBAR); + wid = GTK_WIDGET(gtk_tool_button_new(wid, NULL)); +#else wid = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_HOME)); +#endif gtk_widget_set_tooltip_text(wid, _("Home")); g_signal_connect(wid, "clicked", G_CALLBACK(on_button_go_home), NULL); gtk_container_add(GTK_CONTAINER(toolbar), wid); +#if GTK_CHECK_VERSION(3, 10, 0) + wid = gtk_image_new_from_icon_name("go-jump", GTK_ICON_SIZE_SMALL_TOOLBAR); + wid = GTK_WIDGET(gtk_tool_button_new(wid, NULL)); +#else wid = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_JUMP_TO)); +#endif gtk_widget_set_tooltip_text(wid, _("Set path from document")); g_signal_connect(wid, "clicked", G_CALLBACK(on_button_current_path), NULL); gtk_container_add(GTK_CONTAINER(toolbar), wid); +#if GTK_CHECK_VERSION(3, 10, 0) + wid = gtk_image_new_from_icon_name("folder", GTK_ICON_SIZE_SMALL_TOOLBAR); + wid = GTK_WIDGET(gtk_tool_button_new(wid, NULL)); +#else wid = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_DIRECTORY)); +#endif gtk_widget_set_tooltip_text(wid, _("Track path")); g_signal_connect(wid, "clicked", G_CALLBACK(treebrowser_track_current), NULL); gtk_container_add(GTK_CONTAINER(toolbar), wid); +#if GTK_CHECK_VERSION(3, 10, 0) + wid = gtk_image_new_from_icon_name("window-close", GTK_ICON_SIZE_SMALL_TOOLBAR); + wid = GTK_WIDGET(gtk_tool_button_new(wid, NULL)); +#else wid = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_CLOSE)); +#endif gtk_widget_set_tooltip_text(wid, _("Hide bars")); g_signal_connect(wid, "clicked", G_CALLBACK(on_button_hide_bars), NULL); gtk_container_add(GTK_CONTAINER(toolbar), wid); @@ -1936,7 +2115,12 @@ plugin_configure(GtkDialog *dialog) label = gtk_label_new(_("External open command")); configure_widgets.OPEN_EXTERNAL_CMD = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(configure_widgets.OPEN_EXTERNAL_CMD), CONFIG_OPEN_EXTERNAL_CMD); +#if GTK_CHECK_VERSION(3, 14, 0) + gtk_widget_set_halign(label, 0); + gtk_widget_set_valign(label, 0.5); +#else gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); +#endif gtk_widget_set_tooltip_text(configure_widgets.OPEN_EXTERNAL_CMD, _("The command to execute when using \"Open with\". You can use %f and %d wildcards.\n" "%f will be replaced with the filename including full path\n" @@ -1949,7 +2133,13 @@ plugin_configure(GtkDialog *dialog) label = gtk_label_new(_("Terminal")); configure_widgets.OPEN_TERMINAL = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(configure_widgets.OPEN_TERMINAL), CONFIG_OPEN_TERMINAL); + +#if GTK_CHECK_VERSION(3, 14, 0) + gtk_widget_set_halign(label, 0); + gtk_widget_set_valign(label, 0.5); +#else gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); +#endif gtk_widget_set_tooltip_text(configure_widgets.OPEN_TERMINAL, _("The terminal to use with the command \"Open Terminal\"")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 6); @@ -1981,61 +2171,105 @@ plugin_configure(GtkDialog *dialog) gtk_combo_box_set_active(GTK_COMBO_BOX(configure_widgets.SHOW_ICONS), CONFIG_SHOW_ICONS); configure_widgets.SHOW_HIDDEN_FILES = gtk_check_button_new_with_label(_("Show hidden files")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.SHOW_HIDDEN_FILES, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.SHOW_HIDDEN_FILES), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.SHOW_HIDDEN_FILES), CONFIG_SHOW_HIDDEN_FILES); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.SHOW_HIDDEN_FILES, FALSE, FALSE, 0); gtk_widget_set_tooltip_text(configure_widgets.SHOW_HIDDEN_FILES, _("On Windows, this just hide files that are prefixed with '.' (dot)")); configure_widgets.HIDE_OBJECT_FILES = gtk_check_button_new_with_label(_("Hide object files")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.HIDE_OBJECT_FILES, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.HIDE_OBJECT_FILES), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.HIDE_OBJECT_FILES), CONFIG_HIDE_OBJECT_FILES); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.HIDE_OBJECT_FILES, FALSE, FALSE, 0); gtk_widget_set_tooltip_text(configure_widgets.HIDE_OBJECT_FILES, _("Don't show generated object files in the file browser, this includes *.o, *.obj. *.so, *.dll, *.a, *.lib")); configure_widgets.REVERSE_FILTER = gtk_check_button_new_with_label(_("Reverse filter")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.REVERSE_FILTER, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.REVERSE_FILTER), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.REVERSE_FILTER), CONFIG_REVERSE_FILTER); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.REVERSE_FILTER, FALSE, FALSE, 0); configure_widgets.FOLLOW_CURRENT_DOC = gtk_check_button_new_with_label(_("Follow current document")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.FOLLOW_CURRENT_DOC, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.FOLLOW_CURRENT_DOC), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.FOLLOW_CURRENT_DOC), CONFIG_FOLLOW_CURRENT_DOC); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.FOLLOW_CURRENT_DOC, FALSE, FALSE, 0); configure_widgets.ONE_CLICK_CHDOC = gtk_check_button_new_with_label(_("Single click, open document and focus it")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.ONE_CLICK_CHDOC, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.ONE_CLICK_CHDOC), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.ONE_CLICK_CHDOC), CONFIG_ONE_CLICK_CHDOC); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.ONE_CLICK_CHDOC, FALSE, FALSE, 0); configure_widgets.CHROOT_ON_DCLICK = gtk_check_button_new_with_label(_("Double click open directory")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.ONE_CLICK_CHDOC, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.CHROOT_ON_DCLICK), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.CHROOT_ON_DCLICK), CONFIG_CHROOT_ON_DCLICK); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.CHROOT_ON_DCLICK, FALSE, FALSE, 0); configure_widgets.ON_DELETE_CLOSE_FILE = gtk_check_button_new_with_label(_("On delete file, close it if is opened")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.ON_DELETE_CLOSE_FILE, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.ON_DELETE_CLOSE_FILE), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.ON_DELETE_CLOSE_FILE), CONFIG_ON_DELETE_CLOSE_FILE); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.ON_DELETE_CLOSE_FILE, FALSE, FALSE, 0); configure_widgets.ON_OPEN_FOCUS_EDITOR = gtk_check_button_new_with_label(_("Focus editor on file open")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.ON_OPEN_FOCUS_EDITOR, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.ON_OPEN_FOCUS_EDITOR), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.ON_OPEN_FOCUS_EDITOR), CONFIG_ON_OPEN_FOCUS_EDITOR); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.ON_OPEN_FOCUS_EDITOR, FALSE, FALSE, 0); configure_widgets.SHOW_TREE_LINES = gtk_check_button_new_with_label(_("Show tree lines")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.SHOW_TREE_LINES, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.SHOW_TREE_LINES), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.SHOW_TREE_LINES), CONFIG_SHOW_TREE_LINES); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.SHOW_TREE_LINES, FALSE, FALSE, 0); configure_widgets.SHOW_BOOKMARKS = gtk_check_button_new_with_label(_("Show bookmarks")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.SHOW_BOOKMARKS, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.SHOW_BOOKMARKS), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.SHOW_BOOKMARKS), CONFIG_SHOW_BOOKMARKS); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.SHOW_BOOKMARKS, FALSE, FALSE, 0); configure_widgets.OPEN_NEW_FILES = gtk_check_button_new_with_label(_("Open new files")); +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_set_focus_on_click(configure_widgets.OPEN_NEW_FILES, FALSE); +#else gtk_button_set_focus_on_click(GTK_BUTTON(configure_widgets.OPEN_NEW_FILES ), FALSE); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configure_widgets.OPEN_NEW_FILES ), CONFIG_OPEN_NEW_FILES); gtk_box_pack_start(GTK_BOX(vbox), configure_widgets.OPEN_NEW_FILES , FALSE, FALSE, 0); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] c4de25: lineoperations: unnecessary heap allocations
by Sylvan Mostert
02 Jul '19
02 Jul '19
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Wed, 08 Mar 2017 03:34:06 UTC Commit: c4de25225a192aed99b247dd39fa43cdac68147b
https://github.com/geany/geany-plugins/commit/c4de25225a192aed99b247dd39fa4…
Log Message: ----------- lineoperations: unnecessary heap allocations Modified Paths: -------------- lineoperations/src/lineoperations.c Modified: lineoperations/src/lineoperations.c 40 lines changed, 13 insertions(+), 27 deletions(-) =================================================================== @@ -156,42 +156,37 @@ action_indir_manip_item(GtkMenuItem *menuitem, gpointer gdata) /* function pointer to function to be used */ gint (*func)(gchar **lines, gint num_lines, gchar *new_file) = gdata; GeanyDocument *doc = document_get_current(); - g_return_if_fail(doc != NULL); + struct lo_lines sel; gint num_chars = 0; gint i = 0; gint lines_affected = 0; - struct lo_lines *sel = g_malloc(sizeof(struct lo_lines)); - sel->is_selection = FALSE; - sel->start_line = 0; - sel->end_line = 0; - - get_current_sel_lines(doc->editor->sci, sel); - gint num_lines = (sel->end_line - sel->start_line) + 1; + get_current_sel_lines(doc->editor->sci, &sel); + gint num_lines = (sel.end_line - sel.start_line) + 1; /* if last line within selection ensure that the file ends with newline */ - if((sel->end_line + 1) == sci_get_line_count(doc->editor->sci)) - ensure_final_newline(doc->editor, &num_lines, sel); + if((sel.end_line + 1) == sci_get_line_count(doc->editor->sci)) + ensure_final_newline(doc->editor, &num_lines, &sel); /* get num_chars and **lines */ gchar **lines = g_malloc(sizeof(gchar *) * num_lines); for(i = 0; i < num_lines; i++) { num_chars += (sci_get_line_length(doc->editor->sci, - (i + sel->start_line))); + (i + sel.start_line))); lines[i] = sci_get_line(doc->editor->sci, - (i + sel->start_line)); + (i + sel.start_line)); } gchar *new_file = g_malloc(sizeof(gchar) * (num_chars + 1)); new_file[0] = '\0'; /* select lines that will be replaced with array */ - select_lines(doc->editor, sel); + select_lines(doc->editor, &sel); sci_start_undo_action(doc->editor->sci); @@ -202,9 +197,7 @@ action_indir_manip_item(GtkMenuItem *menuitem, gpointer gdata) sci_replace_sel(doc->editor->sci, new_file); /* select affected lines and set statusbar message */ - user_indicate(doc->editor, lines_affected, sel); - - g_free(sel); + user_indicate(doc->editor, lines_affected, &sel); sci_end_undo_action(doc->editor->sci); @@ -227,26 +220,19 @@ action_sci_manip_item(GtkMenuItem *menuitem, gpointer gdata) /* function pointer to gdata -- function to be used */ gint (*func)(ScintillaObject *, gint, gint) = gdata; GeanyDocument *doc = document_get_current(); - g_return_if_fail(doc != NULL); - struct lo_lines *sel = g_malloc(sizeof(struct lo_lines)); - sel->is_selection = FALSE; - sel->start_line = 0; - sel->end_line = 0; - - get_current_sel_lines(doc->editor->sci, sel); + struct lo_lines sel; + get_current_sel_lines(doc->editor->sci, &sel); gint lines_affected = 0; sci_start_undo_action(doc->editor->sci); - lines_affected = func(doc->editor->sci, sel->start_line, sel->end_line); + lines_affected = func(doc->editor->sci, sel.start_line, sel.end_line); /* put message in ui_statusbar, and highlight lines that were affected */ - user_indicate(doc->editor, lines_affected, sel); - - g_free(sel); + user_indicate(doc->editor, lines_affected, &sel); sci_end_undo_action(doc->editor->sci); } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 42e701: lineoperations: removed check for doc
by Sylvan Mostert
02 Jul '19
02 Jul '19
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Wed, 08 Mar 2017 02:25:47 UTC Commit: 42e701b2c84b822d435d4d3d26c6a6c092f8ff17
https://github.com/geany/geany-plugins/commit/42e701b2c84b822d435d4d3d26c6a…
Log Message: ----------- lineoperations: removed check for doc Items are added with ui_add_document_sensitive so doc is never null. Modified Paths: -------------- lineoperations/src/lineoperations.c Modified: lineoperations/src/lineoperations.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -197,6 +197,7 @@ action_indir_manip_item(GtkMenuItem *menuitem, gpointer gdata) lines_affected = func(lines, num_lines, new_file); + /* set new document */ sci_replace_sel(doc->editor->sci, new_file); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] fefecc: lineoperations: fixed -Werror=aggregate-return
by Sylvan Mostert
02 Jul '19
02 Jul '19
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Wed, 08 Mar 2017 02:23:42 UTC Commit: fefeccc4e22b64e4e2ddcfb2bf9e696c988d2699
https://github.com/geany/geany-plugins/commit/fefeccc4e22b64e4e2ddcfb2bf9e6…
Log Message: ----------- lineoperations: fixed -Werror=aggregate-return Functions no longer work with structure, instead pointer to structure. Modified Paths: -------------- lineoperations/src/lineoperations.c Modified: lineoperations/src/lineoperations.c 72 lines changed, 42 insertions(+), 30 deletions(-) =================================================================== @@ -41,24 +41,23 @@ struct lo_lines { /* selects lines in document (based off of lo_lines struct parameter) */ static void -select_lines(GeanyEditor *editor, struct lo_lines sel) +select_lines(GeanyEditor *editor, struct lo_lines *sel) { /* set the selection to beginning of first line */ sci_set_selection_start(editor->sci, - sci_get_position_from_line(editor->sci, sel.start_line)); + sci_get_position_from_line(editor->sci, sel->start_line)); /* set the selection to end of last line */ sci_set_selection_end(editor->sci, - sci_get_line_end_position(editor->sci, sel.end_line) + + sci_get_line_end_position(editor->sci, sel->end_line) + editor_get_eol_char_len(editor)); } -/* get lo_lines struct based off of document */ -static struct lo_lines -get_current_sel_lines(ScintillaObject *sci) +/* get lo_lines struct 'sel' from document */ +static void +get_current_sel_lines(ScintillaObject *sci, struct lo_lines *sel) { - struct lo_lines sel = { FALSE, 0, 0 }; gint start_posn = 0; /* position of selection start */ gint end_posn = 0; /* position of selection end */ @@ -70,27 +69,25 @@ get_current_sel_lines(ScintillaObject *sci) end_posn = sci_get_selection_end (sci); /* get the *line number* of those positions */ - sel.start_line = scintilla_send_message(sci, + sel->start_line = scintilla_send_message(sci, SCI_LINEFROMPOSITION, start_posn, 0); - sel.end_line = scintilla_send_message(sci, + sel->end_line = scintilla_send_message(sci, SCI_LINEFROMPOSITION, end_posn, 0); - sel.is_selection = TRUE; + sel->is_selection = TRUE; } else { /* if there is no selection, start at first line */ - sel.start_line = 0; + sel->start_line = 0; /* and end at last one */ - sel.end_line = (sci_get_line_count(sci) - 1); + sel->end_line = (sci_get_line_count(sci) - 1); - sel.is_selection = FALSE; + sel->is_selection = FALSE; } - - return sel; } @@ -109,32 +106,32 @@ ensure_final_newline(GeanyEditor *editor, gint *num_lines, struct lo_lines *sel) /* re-adjust the selection */ (*num_lines)++; - (*sel).end_line++; + sel->end_line++; } } /* set statusbar with message and select altered lines */ static void -user_indicate(GeanyEditor *editor, gint lines_affected, struct lo_lines sel) +user_indicate(GeanyEditor *editor, gint lines_affected, struct lo_lines *sel) { if(lines_affected < 0) { ui_set_statusbar(FALSE, _("Operation successful! %d lines removed."), -lines_affected); /* select lines to indicate to user what lines were altered */ - sel.end_line += lines_affected; + sel->end_line += lines_affected; - if(sel.is_selection) + if(sel->is_selection) select_lines(editor, sel); } else if(lines_affected == 0) { ui_set_statusbar(FALSE, _("Operation successful! No lines removed.")); /* select lines to indicate to user what lines were altered */ - if(sel.is_selection) + if(sel->is_selection) select_lines(editor, sel); } else @@ -143,7 +140,7 @@ user_indicate(GeanyEditor *editor, gint lines_affected, struct lo_lines sel) lines_affected); /* select lines to indicate to user what lines were altered */ - if(sel.is_selection) + if(sel->is_selection) select_lines(editor, sel); } } @@ -162,27 +159,32 @@ action_indir_manip_item(GtkMenuItem *menuitem, gpointer gdata) g_return_if_fail(doc != NULL); - struct lo_lines sel = get_current_sel_lines(doc->editor->sci); - gint num_lines = (sel.end_line - sel.start_line) + 1; - gint num_chars = 0; gint i = 0; gint lines_affected = 0; + struct lo_lines *sel = g_malloc(sizeof(struct lo_lines)); + sel->is_selection = FALSE; + sel->start_line = 0; + sel->end_line = 0; + + get_current_sel_lines(doc->editor->sci, sel); + gint num_lines = (sel->end_line - sel->start_line) + 1; + /* if last line within selection ensure that the file ends with newline */ - if((sel.end_line + 1) == sci_get_line_count(doc->editor->sci)) - ensure_final_newline(doc->editor, &num_lines, &sel); + if((sel->end_line + 1) == sci_get_line_count(doc->editor->sci)) + ensure_final_newline(doc->editor, &num_lines, sel); /* get num_chars and **lines */ gchar **lines = g_malloc(sizeof(gchar *) * num_lines); for(i = 0; i < num_lines; i++) { num_chars += (sci_get_line_length(doc->editor->sci, - (i + sel.start_line))); + (i + sel->start_line))); lines[i] = sci_get_line(doc->editor->sci, - (i + sel.start_line)); + (i + sel->start_line)); } gchar *new_file = g_malloc(sizeof(gchar) * (num_chars + 1)); @@ -201,6 +203,8 @@ action_indir_manip_item(GtkMenuItem *menuitem, gpointer gdata) /* select affected lines and set statusbar message */ user_indicate(doc->editor, lines_affected, sel); + g_free(sel); + sci_end_undo_action(doc->editor->sci); /* free used memory */ @@ -225,16 +229,24 @@ action_sci_manip_item(GtkMenuItem *menuitem, gpointer gdata) g_return_if_fail(doc != NULL); - struct lo_lines sel = get_current_sel_lines(doc->editor->sci); + struct lo_lines *sel = g_malloc(sizeof(struct lo_lines)); + sel->is_selection = FALSE; + sel->start_line = 0; + sel->end_line = 0; + + get_current_sel_lines(doc->editor->sci, sel); gint lines_affected = 0; sci_start_undo_action(doc->editor->sci); - lines_affected = func(doc->editor->sci, sel.start_line, sel.end_line); + lines_affected = func(doc->editor->sci, sel->start_line, sel->end_line); + /* put message in ui_statusbar, and highlight lines that were affected */ user_indicate(doc->editor, lines_affected, sel); + g_free(sel); + sci_end_undo_action(doc->editor->sci); } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 9147b2: Merge pull request #517 from smostertdev/lineoperations_v3
by Frank Lanitz
02 Jul '19
02 Jul '19
Branch: refs/heads/master Author: Frank Lanitz <frank(a)frank.uvena.de> Committer: GitHub <noreply(a)github.com> Date: Tue, 02 Jul 2019 07:30:28 UTC Commit: 9147b2b84090da00383df43eecf7fa78989b4438
https://github.com/geany/geany-plugins/commit/9147b2b84090da00383df43eecf7f…
Log Message: ----------- Merge pull request #517 from smostertdev/lineoperations_v3 lineoperations: fixed -Werror=aggregate-return Modified Paths: -------------- lineoperations/src/lineoperations.c Modified: lineoperations/src/lineoperations.c 59 lines changed, 29 insertions(+), 30 deletions(-) =================================================================== @@ -41,24 +41,23 @@ struct lo_lines { /* selects lines in document (based off of lo_lines struct parameter) */ static void -select_lines(GeanyEditor *editor, struct lo_lines sel) +select_lines(GeanyEditor *editor, struct lo_lines *sel) { /* set the selection to beginning of first line */ sci_set_selection_start(editor->sci, - sci_get_position_from_line(editor->sci, sel.start_line)); + sci_get_position_from_line(editor->sci, sel->start_line)); /* set the selection to end of last line */ sci_set_selection_end(editor->sci, - sci_get_line_end_position(editor->sci, sel.end_line) + + sci_get_line_end_position(editor->sci, sel->end_line) + editor_get_eol_char_len(editor)); } -/* get lo_lines struct based off of document */ -static struct lo_lines -get_current_sel_lines(ScintillaObject *sci) +/* get lo_lines struct 'sel' from document */ +static void +get_current_sel_lines(ScintillaObject *sci, struct lo_lines *sel) { - struct lo_lines sel = { FALSE, 0, 0 }; gint start_posn = 0; /* position of selection start */ gint end_posn = 0; /* position of selection end */ @@ -70,27 +69,25 @@ get_current_sel_lines(ScintillaObject *sci) end_posn = sci_get_selection_end (sci); /* get the *line number* of those positions */ - sel.start_line = scintilla_send_message(sci, + sel->start_line = scintilla_send_message(sci, SCI_LINEFROMPOSITION, start_posn, 0); - sel.end_line = scintilla_send_message(sci, + sel->end_line = scintilla_send_message(sci, SCI_LINEFROMPOSITION, end_posn, 0); - sel.is_selection = TRUE; + sel->is_selection = TRUE; } else { /* if there is no selection, start at first line */ - sel.start_line = 0; + sel->start_line = 0; /* and end at last one */ - sel.end_line = (sci_get_line_count(sci) - 1); + sel->end_line = (sci_get_line_count(sci) - 1); - sel.is_selection = FALSE; + sel->is_selection = FALSE; } - - return sel; } @@ -109,32 +106,32 @@ ensure_final_newline(GeanyEditor *editor, gint *num_lines, struct lo_lines *sel) /* re-adjust the selection */ (*num_lines)++; - (*sel).end_line++; + sel->end_line++; } } /* set statusbar with message and select altered lines */ static void -user_indicate(GeanyEditor *editor, gint lines_affected, struct lo_lines sel) +user_indicate(GeanyEditor *editor, gint lines_affected, struct lo_lines *sel) { if(lines_affected < 0) { ui_set_statusbar(FALSE, _("Operation successful! %d lines removed."), -lines_affected); /* select lines to indicate to user what lines were altered */ - sel.end_line += lines_affected; + sel->end_line += lines_affected; - if(sel.is_selection) + if(sel->is_selection) select_lines(editor, sel); } else if(lines_affected == 0) { ui_set_statusbar(FALSE, _("Operation successful! No lines removed.")); /* select lines to indicate to user what lines were altered */ - if(sel.is_selection) + if(sel->is_selection) select_lines(editor, sel); } else @@ -143,7 +140,7 @@ user_indicate(GeanyEditor *editor, gint lines_affected, struct lo_lines sel) lines_affected); /* select lines to indicate to user what lines were altered */ - if(sel.is_selection) + if(sel->is_selection) select_lines(editor, sel); } } @@ -159,16 +156,16 @@ action_indir_manip_item(GtkMenuItem *menuitem, gpointer gdata) /* function pointer to function to be used */ gint (*func)(gchar **lines, gint num_lines, gchar *new_file) = gdata; GeanyDocument *doc = document_get_current(); - g_return_if_fail(doc != NULL); - struct lo_lines sel = get_current_sel_lines(doc->editor->sci); - gint num_lines = (sel.end_line - sel.start_line) + 1; - + struct lo_lines sel; gint num_chars = 0; gint i = 0; gint lines_affected = 0; + get_current_sel_lines(doc->editor->sci, &sel); + gint num_lines = (sel.end_line - sel.start_line) + 1; + /* if last line within selection ensure that the file ends with newline */ if((sel.end_line + 1) == sci_get_line_count(doc->editor->sci)) @@ -189,17 +186,18 @@ action_indir_manip_item(GtkMenuItem *menuitem, gpointer gdata) new_file[0] = '\0'; /* select lines that will be replaced with array */ - select_lines(doc->editor, sel); + select_lines(doc->editor, &sel); sci_start_undo_action(doc->editor->sci); lines_affected = func(lines, num_lines, new_file); + /* set new document */ sci_replace_sel(doc->editor->sci, new_file); /* select affected lines and set statusbar message */ - user_indicate(doc->editor, lines_affected, sel); + user_indicate(doc->editor, lines_affected, &sel); sci_end_undo_action(doc->editor->sci); @@ -222,18 +220,19 @@ action_sci_manip_item(GtkMenuItem *menuitem, gpointer gdata) /* function pointer to gdata -- function to be used */ gint (*func)(ScintillaObject *, gint, gint) = gdata; GeanyDocument *doc = document_get_current(); - g_return_if_fail(doc != NULL); - struct lo_lines sel = get_current_sel_lines(doc->editor->sci); + struct lo_lines sel; + get_current_sel_lines(doc->editor->sci, &sel); gint lines_affected = 0; sci_start_undo_action(doc->editor->sci); lines_affected = func(doc->editor->sci, sel.start_line, sel.end_line); + /* put message in ui_statusbar, and highlight lines that were affected */ - user_indicate(doc->editor, lines_affected, sel); + user_indicate(doc->editor, lines_affected, &sel); sci_end_undo_action(doc->editor->sci); } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
← Newer
1
2
3
4
Older →
Jump to page:
1
2
3
4
Results per page:
10
25
50
100
200