Revision: 1053 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1053&view=re... Author: eht16 Date: 2009-11-04 19:01:51 +0000 (Wed, 04 Nov 2009)
Log Message: ----------- Add 'Mark Word' addon.
Modified Paths: -------------- trunk/geany-plugins/addons/ChangeLog trunk/geany-plugins/addons/README trunk/geany-plugins/addons/src/Makefile.am trunk/geany-plugins/addons/src/addons.c trunk/geany-plugins/po/POTFILES.in
Added Paths: ----------- trunk/geany-plugins/addons/src/ao_markword.c trunk/geany-plugins/addons/src/ao_markword.h
Modified: trunk/geany-plugins/addons/ChangeLog =================================================================== --- trunk/geany-plugins/addons/ChangeLog 2009-11-04 18:53:38 UTC (rev 1052) +++ trunk/geany-plugins/addons/ChangeLog 2009-11-04 19:01:51 UTC (rev 1053) @@ -2,6 +2,8 @@
* src/ao_bookmarklist.c: Prevent updating the bookmark list if it is disabled. + * src/Makefile.am, src/ao_markword.c, src/ao_markword.h, src/addons.c: + Add 'Mark Word' addon.
2009-11-01 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/geany-plugins/addons/README =================================================================== --- trunk/geany-plugins/addons/README 2009-11-04 18:53:38 UTC (rev 1052) +++ trunk/geany-plugins/addons/README 2009-11-04 19:01:51 UTC (rev 1053) @@ -32,7 +32,18 @@ a simple popup menu with some basic actions. It can also be used to quickly show and hide the Geany main window.
+Bookmark List +^^^^^^^^^^^^^ +Add a list of defined bookmarks (line markers) to the sidebar. +This list contains all bookmarks defined in the current file +for faster overview and access.
+Mark Word +^^^^^^^^^ +When double-clicking a word, all occurences of this word are searched +and then highlighted (similar to Geany's 'Mark All' Find option). + + Downloads ---------
Modified: trunk/geany-plugins/addons/src/Makefile.am =================================================================== --- trunk/geany-plugins/addons/src/Makefile.am 2009-11-04 18:53:38 UTC (rev 1052) +++ trunk/geany-plugins/addons/src/Makefile.am 2009-11-04 19:01:51 UTC (rev 1053) @@ -9,12 +9,14 @@ ao_openuri.h \ ao_systray.h \ ao_bookmarklist.h \ + ao_markword.h \ tasks.h \ addons.c \ ao_doclist.c \ ao_openuri.c \ ao_systray.c \ ao_bookmarklist.c \ + ao_markword.c \ tasks.c
addons_la_LIBADD = $(COMMONLIBS)
Modified: trunk/geany-plugins/addons/src/addons.c =================================================================== --- trunk/geany-plugins/addons/src/addons.c 2009-11-04 18:53:38 UTC (rev 1052) +++ trunk/geany-plugins/addons/src/addons.c 2009-11-04 19:01:51 UTC (rev 1053) @@ -28,6 +28,7 @@ #include "ao_openuri.h" #include "ao_systray.h" #include "ao_bookmarklist.h" +#include "ao_markword.h" #include "tasks.h"
@@ -60,12 +61,14 @@ gboolean enable_tasks; gboolean enable_systray; gboolean enable_bookmarklist; + gboolean enable_markword;
/* instances and variables of components */ AoDocList *doclist; AoOpenUri *openuri; AoSystray *systray; AoBookmarkList *bookmarklist; + AoMarkWord *markword; } AddonsInfo; static AddonsInfo *ao_info = NULL;
@@ -103,6 +106,7 @@ gboolean ret = FALSE;
ao_bookmark_list_update_marker(ao_info->bookmarklist, editor, nt); + ao_mark_word_check(ao_info->markword, editor, nt);
ret = tasks_on_editor_notify(object, editor, nt, data);
@@ -160,6 +164,8 @@ "addons", "enable_systray", FALSE); ao_info->enable_bookmarklist = utils_get_setting_boolean(config, "addons", "enable_bookmarklist", FALSE); + ao_info->enable_markword = utils_get_setting_boolean(config, + "addons", "enable_markword", FALSE);
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); plugin_module_make_resident(geany_plugin); @@ -168,6 +174,7 @@ ao_info->openuri = ao_open_uri_new(ao_info->enable_openuri); ao_info->systray = ao_systray_new(ao_info->enable_systray); ao_info->bookmarklist = ao_bookmark_list_new(ao_info->enable_bookmarklist); + ao_info->markword = ao_mark_word_new(ao_info->enable_markword);
tasks_set_enable(ao_info->enable_tasks);
@@ -196,6 +203,8 @@ g_object_get_data(G_OBJECT(dialog), "check_systray")))); ao_info->enable_bookmarklist = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( g_object_get_data(G_OBJECT(dialog), "check_bookmarklist")))); + ao_info->enable_markword = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + g_object_get_data(G_OBJECT(dialog), "check_markword"))));
g_key_file_load_from_file(config, ao_info->config_file, G_KEY_FILE_NONE, NULL); g_key_file_set_boolean(config, "addons", @@ -205,12 +214,14 @@ g_key_file_set_boolean(config, "addons", "enable_systray", ao_info->enable_systray); g_key_file_set_boolean(config, "addons", "enable_bookmarklist", ao_info->enable_bookmarklist); + g_key_file_set_boolean(config, "addons", "enable_markword", ao_info->enable_markword);
g_object_set(ao_info->doclist, "enable-doclist", ao_info->show_toolbar_doclist_item, NULL); g_object_set(ao_info->openuri, "enable-openuri", ao_info->enable_openuri, NULL); g_object_set(ao_info->systray, "enable-systray", ao_info->enable_systray, NULL); g_object_set(ao_info->bookmarklist, "enable-bookmarklist", ao_info->enable_bookmarklist, NULL); + g_object_set(ao_info->markword, "enable-markword", ao_info->enable_markword, NULL); tasks_set_enable(ao_info->enable_tasks);
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0) @@ -234,7 +245,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog) { GtkWidget *vbox, *check_doclist, *check_openuri, *check_tasks, *check_systray; - GtkWidget *check_bookmarklist; + GtkWidget *check_bookmarklist, *check_markword;
vbox = gtk_vbox_new(FALSE, 6);
@@ -269,11 +280,18 @@ ao_info->enable_bookmarklist); gtk_box_pack_start(GTK_BOX(vbox), check_bookmarklist, FALSE, FALSE, 3);
+ check_markword = gtk_check_button_new_with_label( + _("Mark all occurrences of a word when double-clicking it")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_markword), + ao_info->enable_markword); + gtk_box_pack_start(GTK_BOX(vbox), check_markword, FALSE, FALSE, 3); + g_object_set_data(G_OBJECT(dialog), "check_doclist", check_doclist); g_object_set_data(G_OBJECT(dialog), "check_openuri", check_openuri); g_object_set_data(G_OBJECT(dialog), "check_tasks", check_tasks); g_object_set_data(G_OBJECT(dialog), "check_systray", check_systray); g_object_set_data(G_OBJECT(dialog), "check_bookmarklist", check_bookmarklist); + g_object_set_data(G_OBJECT(dialog), "check_markword", check_markword); g_signal_connect(dialog, "response", G_CALLBACK(ao_configure_response_cb), NULL);
gtk_widget_show_all(vbox); @@ -292,6 +310,7 @@ g_object_unref(ao_info->openuri); g_object_unref(ao_info->systray); g_object_unref(ao_info->bookmarklist); + g_object_unref(ao_info->markword);
tasks_set_enable(FALSE);
Added: trunk/geany-plugins/addons/src/ao_markword.c =================================================================== --- trunk/geany-plugins/addons/src/ao_markword.c (rev 0) +++ trunk/geany-plugins/addons/src/ao_markword.c 2009-11-04 19:01:51 UTC (rev 1053) @@ -0,0 +1,135 @@ +/* + * ao_markword.c - this file is part of Addons, a Geany plugin + * + * Copyright 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ + + +#include <gtk/gtk.h> +#include <glib-object.h> + +#include "geanyplugin.h" + +#include "addons.h" +#include "ao_markword.h" + + +typedef struct _AoMarkWordPrivate AoMarkWordPrivate; + +#define AO_MARKWORD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj),\ + AO_MARKWORD_TYPE, AoMarkWordPrivate)) + +struct _AoMarkWord +{ + GObject parent; +}; + +struct _AoMarkWordClass +{ + GObjectClass parent_class; +}; + +struct _AoMarkWordPrivate +{ + gboolean enable_markword; +}; + +enum +{ + PROP_0, + PROP_ENABLE_MARKWORD +}; + + +static void ao_mark_word_finalize (GObject *object); + +G_DEFINE_TYPE(AoMarkWord, ao_mark_word, G_TYPE_OBJECT); + + +static void ao_mark_word_set_property(GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + AoMarkWordPrivate *priv = AO_MARKWORD_GET_PRIVATE(object); + + switch (prop_id) + { + case PROP_ENABLE_MARKWORD: + priv->enable_markword = g_value_get_boolean(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void ao_mark_word_class_init(AoMarkWordClass *klass) +{ + GObjectClass *g_object_class; + + g_object_class = G_OBJECT_CLASS(klass); + g_object_class->finalize = ao_mark_word_finalize; + g_object_class->set_property = ao_mark_word_set_property; + g_type_class_add_private(klass, sizeof(AoMarkWordPrivate)); + + g_object_class_install_property(g_object_class, + PROP_ENABLE_MARKWORD, + g_param_spec_boolean( + "enable-markword", + "enable-markword", + "Whether to mark all occurrences of a word when double-clicking it", + TRUE, + G_PARAM_WRITABLE)); +} + + +static void ao_mark_word_finalize(GObject *object) +{ + g_return_if_fail(object != NULL); + g_return_if_fail(IS_AO_MARKWORD(object)); + + G_OBJECT_CLASS(ao_mark_word_parent_class)->finalize(object); +} + + +void ao_mark_word_check(AoMarkWord *bm, GeanyEditor *editor, SCNotification *nt) +{ + AoMarkWordPrivate *priv = AO_MARKWORD_GET_PRIVATE(bm); + + if (priv->enable_markword) + { + switch (nt->nmhdr.code) + { + case SCN_DOUBLECLICK: + keybindings_send_command(GEANY_KEY_GROUP_SEARCH, GEANY_KEYS_SEARCH_MARKALL); + break; + } + } +} + + +static void ao_mark_word_init(AoMarkWord *self) +{ +} + + +AoMarkWord *ao_mark_word_new(gboolean enable) +{ + return g_object_new(AO_MARKWORD_TYPE, "enable-markword", enable, NULL); +}
Property changes on: trunk/geany-plugins/addons/src/ao_markword.c ___________________________________________________________________ Added: svn:mime-type + text/x-csrc Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
Added: trunk/geany-plugins/addons/src/ao_markword.h =================================================================== --- trunk/geany-plugins/addons/src/ao_markword.h (rev 0) +++ trunk/geany-plugins/addons/src/ao_markword.h 2009-11-04 19:01:51 UTC (rev 1053) @@ -0,0 +1,49 @@ +/* + * ao_markword.h - this file is part of Addons, a Geany plugin + * + * Copyright 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ + + +#ifndef __AO_MARKWORD_H__ +#define __AO_MARKWORD_H__ + +G_BEGIN_DECLS + +#define AO_MARKWORD_TYPE (ao_mark_word_get_type()) +#define AO_MARKWORD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\ + AO_MARKWORD_TYPE, AoMarkWord)) +#define AO_MARKWORD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\ + AO_MARKWORD_TYPE, AoMarkWordClass)) +#define IS_AO_MARKWORD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\ + AO_MARKWORD_TYPE)) +#define IS_AO_MARKWORD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\ + AO_MARKWORD_TYPE)) + +typedef struct _AoMarkWord AoMarkWord; +typedef struct _AoMarkWordClass AoMarkWordClass; + +GType ao_mark_word_get_type (void); +AoMarkWord* ao_mark_word_new (gboolean enable); +void ao_mark_word_check (AoMarkWord *bm, GeanyEditor *editor, + SCNotification *nt); + +G_END_DECLS + +#endif /* __AO_MARKWORD_H__ */
Property changes on: trunk/geany-plugins/addons/src/ao_markword.h ___________________________________________________________________ Added: svn:mime-type + text/x-chdr Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
Modified: trunk/geany-plugins/po/POTFILES.in =================================================================== --- trunk/geany-plugins/po/POTFILES.in 2009-11-04 18:53:38 UTC (rev 1052) +++ trunk/geany-plugins/po/POTFILES.in 2009-11-04 19:01:51 UTC (rev 1053) @@ -7,6 +7,7 @@ addons/src/addons.c addons/src/ao_doclist.c addons/src/ao_bookmarklist.c +addons/src/ao_markword.c
#codenav codenav/src/codenavigation.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.