Added context actions to run custom commands on current selection or the current word below cursor.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1453 ea778897-0a13-0410-b9d1-a72fbfd435f5
master
Enrico Tröger 2007-04-15 18:09:59 +00:00
parent 1b715a59f6
commit 398ddf6d73
42 changed files with 450 additions and 47 deletions

View File

@ -1,3 +1,13 @@
2007-04-15 Enrico Tröger <enrico.troeger@uvena.de>
* geany.glade, data/filetypes.*, doc/geany.docbook, src/callbacks.c,
src/callbacks.h, src/filetypes.c, src/filetypes.h, src/geany.h,
src/interface.c, src/keybindings.c, src/keybindings.h, src/keyfile.c,
src/main.c, src/prefs.c:
Added context actions to run custom commands on current selection or
the current word below cursor.
2007-04-15 Nick Treleaven <nick.treleaven@btinternet.com>
* src/sci_cb.c:

View File

@ -41,6 +41,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -51,6 +51,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -38,6 +38,9 @@ comment_close=*)
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -26,3 +26,6 @@ comment_close=
# command_example();
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -51,6 +51,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -39,3 +39,6 @@ comment_close=*/
# command_example();
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -50,6 +50,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -18,3 +18,6 @@ added=0x34b034;0xffffff;false;false
comment_open=
comment_close=
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -52,3 +52,6 @@ comment_close=-->
# command_example();
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -47,6 +47,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -42,6 +42,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=false
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename

View File

@ -20,6 +20,9 @@ comment_close=-->
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -46,6 +46,9 @@ comment_close=*/
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename

View File

@ -42,6 +42,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -28,6 +28,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -56,6 +56,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -27,3 +27,6 @@ comment_close=
# command_example();
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -33,3 +33,6 @@ comment_close=
# command_example();
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -34,6 +34,9 @@ comment_close=}
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -52,6 +52,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -20,6 +20,9 @@ comment_close=*/
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -37,6 +37,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -56,6 +56,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -33,6 +33,9 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension

View File

@ -37,3 +37,6 @@ comment_close=*/
# command_example();
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -44,6 +44,12 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[build_settings]
# %f will be replaced by the complete filename

View File

@ -43,4 +43,7 @@ comment_close=
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -90,3 +90,5 @@ comment_close=-->
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=

View File

@ -5,7 +5,7 @@
<!ENTITY appversion "0.11">
<!ENTITY appurl "http://geany.uvena.de">
<!ENTITY author_mail "enrico.troeger@uvena.de">
<!ENTITY date "March 08, 2007">
<!ENTITY date "April 15, 2007">
<!ENTITY legal SYSTEM "geany_gpl.docbook">
<!ENTITY scikeybinding SYSTEM "scikeybinding.docbook">
]>
@ -608,6 +608,37 @@
automatically.
</para>
</section>
<section id="editing_context_actions">
<title>Context actions</title>
<para>
You can execute a specified command on the current word near the cursor
position or an available selection and this word is passed as an argument
to this command. It can be used for example to open some API documentation
in a browser window or open any other external program. To do this,
there is an menu entry in the popup menu of the editor widget and also a
keyboard shortcut(see <xref linkend="keybindings"/>).
</para>
<para>
The command can be specified in the preferences dialog and additionally for
each filetype (see "context_action_cmd" in <xref linkend="filetypes_format"/>).
At executing, the filetype specific command is used if available otherwise the
command specified in the preferences dialog is executed.
</para>
<para>
The passed word can be referred with the wildcard "%s" everywhere in the
command, before executing it will be replaced by the current word.
For example, the command to open the PHP API documentation would be:
</para>
<para>
<command>firefox "http://www.php.net/%s"</command>
</para>
<para>
when executing the command, the %s is substituted by the word near the
cursor position or by the current selection. If the cursor is at the word
"echo", a browser window will open(assumed your browser is called firefox)
and it will open the address: http://www.php.net/echo.
</para>
</section>
</section>
<section id="search_replace">
<title>Search, replace and go to</title>
@ -1649,8 +1680,8 @@
</row>
<row>
<entry>Find Usage</entry>
<entry>Finds all occurrences of the current word (near the
keyboard cursor) and displays them in the messages window.
<entry>Finds all occurrences of the current word (near the keyboard
cursor) or selection and displays them in the messages window.
</entry>
</row>
<row>
@ -1669,6 +1700,13 @@
will beep and do nothing. See <xref linkend="search_gototag"/>.
</entry>
</row>
<row>
<entry>Context Action</entry>
<entry>Executes a command and passes the current word (near the
cursor postion) or selection as an argument. See
<xref linkend="editing_context_actions"/>.
</entry>
</row>
</tbody>
</tgroup>
</table>
@ -1803,6 +1841,31 @@
</entry>
<entry>comment_use_indent=true</entry>
</row>
<row>
<entry>context_action_cmd</entry>
<entry><para>
A command which can be executed on a certain word or
the current selection. Example usage: Open the API
documentation for the current function call at the
cursor position. The command can be set for every
filetype or if not set, a global command will be used.
The command itself can be specified without the full
path, then it is searched in $PATH. But for security
reasons, it is recommended to specify the full path
to the command. The wildcard %s will be replaced
by the current word at the cursor position or by
the current selection.
</para>
<para>
Hint: for PHP files the following could be quite
useful:
<emphasis>
context_action_cmd=firefox "http://www.php.net/%s"
</emphasis>
</para>
</entry>
<entry>context_action_cmd=devhelp -s "%s"</entry>
</row>
</tbody>
</tgroup>
</table>

View File

@ -2569,7 +2569,7 @@
<signal name="activate" handler="on_menu_increase_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:31:38 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1669">
<widget class="GtkImage" id="image1693">
<property name="visible">True</property>
<property name="stock">gtk-indent</property>
<property name="icon_size">1</property>
@ -2590,7 +2590,7 @@
<signal name="activate" handler="on_menu_decrease_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:31:38 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1670">
<widget class="GtkImage" id="image1694">
<property name="visible">True</property>
<property name="stock">gtk-unindent</property>
<property name="icon_size">1</property>
@ -2646,7 +2646,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1671">
<widget class="GtkImage" id="image1695">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -2678,7 +2678,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1672">
<widget class="GtkImage" id="image1696">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -2763,7 +2763,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1673">
<widget class="GtkImage" id="image1697">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -2802,7 +2802,7 @@
<signal name="activate" handler="on_find_usage1_activate" last_modification_time="Fri, 27 May 2005 21:55:12 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1674">
<widget class="GtkImage" id="image1698">
<property name="visible">True</property>
<property name="stock">gtk-find</property>
<property name="icon_size">1</property>
@ -2833,6 +2833,15 @@
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="context_action1">
<property name="visible">True</property>
<property name="label" translatable="yes">Context Action</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_context_action1_activate" last_modification_time="Fri, 13 Apr 2007 18:37:55 GMT"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator15">
<property name="visible">True</property>
@ -2848,7 +2857,7 @@
<signal name="activate" handler="on_go_to_line_activate" last_modification_time="Sat, 16 Jul 2005 11:20:32 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1675">
<widget class="GtkImage" id="image1699">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
@ -3204,6 +3213,110 @@
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame24">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment27">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox8">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label189">
<property name="visible">True</property>
<property name="label" translatable="yes">Context Action command:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_contextaction">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Context action command. The current selected word can be used with %s. It can be everywhere in the given command and will be replaced before execution.</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label188">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Context Action&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>

View File

@ -2084,3 +2084,52 @@ on_remove_markers1_activate (GtkMenuItem *menuitem,
sci_marker_delete_all(doc_list[idx].sci, 1); // delete user markers
}
void
on_context_action1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
gint idx;
gchar *word, *command;
GError *error = NULL;
idx = document_get_cur_idx();
if (! DOC_IDX_VALID(idx)) return;
if (sci_can_copy(doc_list[idx].sci))
{ // take selected text if there is a selection
word = g_malloc(sci_get_selected_text_length(doc_list[idx].sci) + 1);
sci_get_selected_text(doc_list[idx].sci, word);
}
else
{
word = g_strdup(editor_info.current_word);
}
// use the filetype specific command if available, fallback to global command otherwise
if (doc_list[idx].file_type != NULL &&
doc_list[idx].file_type->context_action_cmd != NULL &&
*doc_list[idx].file_type->context_action_cmd != '\0')
{
command = g_strdup(doc_list[idx].file_type->context_action_cmd);
}
else
{
command = g_strdup(app->context_action_cmd);
}
// substitute the wildcard %s and run the command if it is non empty
if (command != NULL && *command != '\0')
{
command = utils_str_replace(command, "%s", word);
if (! g_spawn_command_line_async(command, &error))
{
msgwin_status_add("Context action command failed: %s", error->message);
g_error_free(error);
}
}
g_free(word);
g_free(command);
}

View File

@ -595,3 +595,7 @@ on_menu_open_selected_file1_activate (GtkMenuItem *menuitem,
void
on_remove_markers1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_context_action1_activate (GtkMenuItem *menuitem,
gpointer user_data);

View File

@ -782,6 +782,7 @@ void filetypes_free_types()
g_free(filetypes[i]->extension);
g_free(filetypes[i]->comment_open);
g_free(filetypes[i]->comment_close);
g_free(filetypes[i]->context_action_cmd);
g_free(filetypes[i]->programs->compiler);
g_free(filetypes[i]->programs->linker);
g_free(filetypes[i]->programs->run_cmd);
@ -832,6 +833,14 @@ void filetypes_get_config(GKeyFile *config, GKeyFile *configh, gint ft)
}
else filetypes[ft]->comment_use_indent = tmp;
// read context action
result = g_key_file_get_string(configh, "settings", "context_action_cmd", NULL);
if (result == NULL) result = g_key_file_get_string(config, "settings", "context_action_cmd", NULL);
if (result != NULL)
{
filetypes[ft]->context_action_cmd = result;
}
// read build settings
result = g_key_file_get_string(configh, "build_settings", "compiler", NULL);
if (result == NULL) result = g_key_file_get_string(config, "build_settings", "compiler", NULL);
@ -951,7 +960,7 @@ GtkFileFilter *filetypes_create_file_filter(filetype *ft)
gint i;
g_return_val_if_fail(ft != NULL, NULL);
new_filter = gtk_file_filter_new();
gtk_file_filter_set_name(new_filter, ft->title);

View File

@ -100,6 +100,7 @@ typedef struct filetype
gchar *title; // will be shown in the file open dialog
gchar *extension;
gchar **pattern;
gchar *context_action_cmd;
gchar *comment_open;
gchar *comment_close;
gboolean comment_use_indent;

View File

@ -144,6 +144,7 @@ typedef struct MyApp
gint long_line_type;
gint long_line_column;
gchar *long_line_color;
gchar *context_action_cmd;
gchar *pref_template_developer;
gchar *pref_template_company;
gchar *pref_template_mail;

View File

@ -1893,20 +1893,20 @@ create_edit_menu1 (void)
GtkWidget *menu_duplicate_line2;
GtkWidget *separator31;
GtkWidget *menu_increase_indent2;
GtkWidget *image1669;
GtkWidget *image1693;
GtkWidget *menu_decrease_indent2;
GtkWidget *image1670;
GtkWidget *image1694;
GtkWidget *separator38;
GtkWidget *send_selection_to1;
GtkWidget *send_selection_to1_menu;
GtkWidget *invisible12;
GtkWidget *separator17;
GtkWidget *insert_include1;
GtkWidget *image1671;
GtkWidget *image1695;
GtkWidget *insert_include1_menu;
GtkWidget *invisible3;
GtkWidget *comments;
GtkWidget *image1672;
GtkWidget *image1696;
GtkWidget *comments_menu;
GtkWidget *add_changelog_entry2;
GtkWidget *insert_file_header2;
@ -1915,17 +1915,18 @@ create_edit_menu1 (void)
GtkWidget *insert_gpl_notice1;
GtkWidget *insert_bsd_license_notice1;
GtkWidget *insert_date2;
GtkWidget *image1673;
GtkWidget *image1697;
GtkWidget *insert_date2_menu;
GtkWidget *invisible10;
GtkWidget *separator7;
GtkWidget *find_usage1;
GtkWidget *image1674;
GtkWidget *image1698;
GtkWidget *goto_tag_definition1;
GtkWidget *goto_tag_declaration1;
GtkWidget *context_action1;
GtkWidget *separator15;
GtkWidget *go_to_line;
GtkWidget *image1675;
GtkWidget *image1699;
GtkAccelGroup *accel_group;
GtkTooltips *tooltips;
@ -2032,17 +2033,17 @@ create_edit_menu1 (void)
gtk_widget_show (menu_increase_indent2);
gtk_container_add (GTK_CONTAINER (menu_format2_menu), menu_increase_indent2);
image1669 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1669);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent2), image1669);
image1693 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1693);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent2), image1693);
menu_decrease_indent2 = gtk_image_menu_item_new_with_mnemonic (_("_Decrease Indent"));
gtk_widget_show (menu_decrease_indent2);
gtk_container_add (GTK_CONTAINER (menu_format2_menu), menu_decrease_indent2);
image1670 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1670);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent2), image1670);
image1694 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1694);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent2), image1694);
separator38 = gtk_separator_menu_item_new ();
gtk_widget_show (separator38);
@ -2068,9 +2069,9 @@ create_edit_menu1 (void)
gtk_widget_show (insert_include1);
gtk_container_add (GTK_CONTAINER (edit_menu1), insert_include1);
image1671 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1671);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include1), image1671);
image1695 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1695);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include1), image1695);
insert_include1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_include1), insert_include1_menu);
@ -2082,9 +2083,9 @@ create_edit_menu1 (void)
gtk_widget_show (comments);
gtk_container_add (GTK_CONTAINER (edit_menu1), comments);
image1672 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1672);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (comments), image1672);
image1696 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1696);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (comments), image1696);
comments_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (comments), comments_menu);
@ -2123,9 +2124,9 @@ create_edit_menu1 (void)
gtk_widget_show (insert_date2);
gtk_container_add (GTK_CONTAINER (edit_menu1), insert_date2);
image1673 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1673);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date2), image1673);
image1697 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1697);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date2), image1697);
insert_date2_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_date2), insert_date2_menu);
@ -2142,9 +2143,9 @@ create_edit_menu1 (void)
gtk_widget_show (find_usage1);
gtk_container_add (GTK_CONTAINER (edit_menu1), find_usage1);
image1674 = gtk_image_new_from_stock ("gtk-find", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1674);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (find_usage1), image1674);
image1698 = gtk_image_new_from_stock ("gtk-find", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1698);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (find_usage1), image1698);
goto_tag_definition1 = gtk_menu_item_new_with_mnemonic (_("Go to Tag Definition"));
gtk_widget_show (goto_tag_definition1);
@ -2154,6 +2155,10 @@ create_edit_menu1 (void)
gtk_widget_show (goto_tag_declaration1);
gtk_container_add (GTK_CONTAINER (edit_menu1), goto_tag_declaration1);
context_action1 = gtk_menu_item_new_with_mnemonic (_("Context Action"));
gtk_widget_show (context_action1);
gtk_container_add (GTK_CONTAINER (edit_menu1), context_action1);
separator15 = gtk_separator_menu_item_new ();
gtk_widget_show (separator15);
gtk_container_add (GTK_CONTAINER (edit_menu1), separator15);
@ -2164,9 +2169,9 @@ create_edit_menu1 (void)
gtk_container_add (GTK_CONTAINER (edit_menu1), go_to_line);
gtk_tooltips_set_tip (tooltips, go_to_line, _("Goto to the entered line"), NULL);
image1675 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1675);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line), image1675);
image1699 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU);
gtk_widget_show (image1699);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line), image1699);
g_signal_connect ((gpointer) undo1, "activate",
G_CALLBACK (on_undo1_activate),
@ -2243,6 +2248,9 @@ create_edit_menu1 (void)
g_signal_connect ((gpointer) goto_tag_declaration1, "activate",
G_CALLBACK (on_goto_tag_activate),
NULL);
g_signal_connect ((gpointer) context_action1, "activate",
G_CALLBACK (on_context_action1_activate),
NULL);
g_signal_connect ((gpointer) go_to_line, "activate",
G_CALLBACK (on_go_to_line_activate),
NULL);
@ -2272,20 +2280,20 @@ create_edit_menu1 (void)
GLADE_HOOKUP_OBJECT (edit_menu1, menu_duplicate_line2, "menu_duplicate_line2");
GLADE_HOOKUP_OBJECT (edit_menu1, separator31, "separator31");
GLADE_HOOKUP_OBJECT (edit_menu1, menu_increase_indent2, "menu_increase_indent2");
GLADE_HOOKUP_OBJECT (edit_menu1, image1669, "image1669");
GLADE_HOOKUP_OBJECT (edit_menu1, image1693, "image1693");
GLADE_HOOKUP_OBJECT (edit_menu1, menu_decrease_indent2, "menu_decrease_indent2");
GLADE_HOOKUP_OBJECT (edit_menu1, image1670, "image1670");
GLADE_HOOKUP_OBJECT (edit_menu1, image1694, "image1694");
GLADE_HOOKUP_OBJECT (edit_menu1, separator38, "separator38");
GLADE_HOOKUP_OBJECT (edit_menu1, send_selection_to1, "send_selection_to1");
GLADE_HOOKUP_OBJECT (edit_menu1, send_selection_to1_menu, "send_selection_to1_menu");
GLADE_HOOKUP_OBJECT (edit_menu1, invisible12, "invisible12");
GLADE_HOOKUP_OBJECT (edit_menu1, separator17, "separator17");
GLADE_HOOKUP_OBJECT (edit_menu1, insert_include1, "insert_include1");
GLADE_HOOKUP_OBJECT (edit_menu1, image1671, "image1671");
GLADE_HOOKUP_OBJECT (edit_menu1, image1695, "image1695");
GLADE_HOOKUP_OBJECT (edit_menu1, insert_include1_menu, "insert_include1_menu");
GLADE_HOOKUP_OBJECT (edit_menu1, invisible3, "invisible3");
GLADE_HOOKUP_OBJECT (edit_menu1, comments, "comments");
GLADE_HOOKUP_OBJECT (edit_menu1, image1672, "image1672");
GLADE_HOOKUP_OBJECT (edit_menu1, image1696, "image1696");
GLADE_HOOKUP_OBJECT (edit_menu1, comments_menu, "comments_menu");
GLADE_HOOKUP_OBJECT (edit_menu1, add_changelog_entry2, "add_changelog_entry2");
GLADE_HOOKUP_OBJECT (edit_menu1, insert_file_header2, "insert_file_header2");
@ -2294,17 +2302,18 @@ create_edit_menu1 (void)
GLADE_HOOKUP_OBJECT (edit_menu1, insert_gpl_notice1, "insert_gpl_notice1");
GLADE_HOOKUP_OBJECT (edit_menu1, insert_bsd_license_notice1, "insert_bsd_license_notice1");
GLADE_HOOKUP_OBJECT (edit_menu1, insert_date2, "insert_date2");
GLADE_HOOKUP_OBJECT (edit_menu1, image1673, "image1673");
GLADE_HOOKUP_OBJECT (edit_menu1, image1697, "image1697");
GLADE_HOOKUP_OBJECT (edit_menu1, insert_date2_menu, "insert_date2_menu");
GLADE_HOOKUP_OBJECT (edit_menu1, invisible10, "invisible10");
GLADE_HOOKUP_OBJECT (edit_menu1, separator7, "separator7");
GLADE_HOOKUP_OBJECT (edit_menu1, find_usage1, "find_usage1");
GLADE_HOOKUP_OBJECT (edit_menu1, image1674, "image1674");
GLADE_HOOKUP_OBJECT (edit_menu1, image1698, "image1698");
GLADE_HOOKUP_OBJECT (edit_menu1, goto_tag_definition1, "goto_tag_definition1");
GLADE_HOOKUP_OBJECT (edit_menu1, goto_tag_declaration1, "goto_tag_declaration1");
GLADE_HOOKUP_OBJECT (edit_menu1, context_action1, "context_action1");
GLADE_HOOKUP_OBJECT (edit_menu1, separator15, "separator15");
GLADE_HOOKUP_OBJECT (edit_menu1, go_to_line, "go_to_line");
GLADE_HOOKUP_OBJECT (edit_menu1, image1675, "image1675");
GLADE_HOOKUP_OBJECT (edit_menu1, image1699, "image1699");
GLADE_HOOKUP_OBJECT_NO_REF (edit_menu1, tooltips, "tooltips");
gtk_menu_set_accel_group (GTK_MENU (edit_menu1), accel_group);
@ -2334,6 +2343,12 @@ create_prefs_dialog (void)
GtkWidget *check_switch_pages;
GtkWidget *check_ask_suppress_search_dialogs;
GtkWidget *label178;
GtkWidget *frame24;
GtkWidget *alignment27;
GtkWidget *hbox8;
GtkWidget *label189;
GtkWidget *entry_contextaction;
GtkWidget *label188;
GtkWidget *label94;
GtkWidget *vbox14;
GtkWidget *frame7;
@ -2649,6 +2664,35 @@ create_prefs_dialog (void)
gtk_frame_set_label_widget (GTK_FRAME (frame19), label178);
gtk_label_set_use_markup (GTK_LABEL (label178), TRUE);
frame24 = gtk_frame_new (NULL);
gtk_widget_show (frame24);
gtk_box_pack_start (GTK_BOX (vbox20), frame24, FALSE, TRUE, 0);
gtk_frame_set_shadow_type (GTK_FRAME (frame24), GTK_SHADOW_NONE);
alignment27 = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (alignment27);
gtk_container_add (GTK_CONTAINER (frame24), alignment27);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment27), 0, 0, 12, 0);
hbox8 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox8);
gtk_container_add (GTK_CONTAINER (alignment27), hbox8);
label189 = gtk_label_new (_("Context Action command:"));
gtk_widget_show (label189);
gtk_box_pack_start (GTK_BOX (hbox8), label189, FALSE, FALSE, 0);
entry_contextaction = gtk_entry_new ();
gtk_widget_show (entry_contextaction);
gtk_box_pack_start (GTK_BOX (hbox8), entry_contextaction, TRUE, TRUE, 0);
gtk_tooltips_set_tip (tooltips, entry_contextaction, _("Context action command. The current selected word can be used with %s. It can be everywhere in the given command and will be replaced before execution."), NULL);
gtk_entry_set_invisible_char (GTK_ENTRY (entry_contextaction), 9679);
label188 = gtk_label_new (_("<b>Context Action</b>"));
gtk_widget_show (label188);
gtk_frame_set_label_widget (GTK_FRAME (frame24), label188);
gtk_label_set_use_markup (GTK_LABEL (label188), TRUE);
label94 = gtk_label_new (_("General"));
gtk_widget_show (label94);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 0), label94);
@ -3836,6 +3880,12 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, check_switch_pages, "check_switch_pages");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_ask_suppress_search_dialogs, "check_ask_suppress_search_dialogs");
GLADE_HOOKUP_OBJECT (prefs_dialog, label178, "label178");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame24, "frame24");
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment27, "alignment27");
GLADE_HOOKUP_OBJECT (prefs_dialog, hbox8, "hbox8");
GLADE_HOOKUP_OBJECT (prefs_dialog, label189, "label189");
GLADE_HOOKUP_OBJECT (prefs_dialog, entry_contextaction, "entry_contextaction");
GLADE_HOOKUP_OBJECT (prefs_dialog, label188, "label188");
GLADE_HOOKUP_OBJECT (prefs_dialog, label94, "label94");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox14, "vbox14");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame7, "frame7");

View File

@ -274,6 +274,8 @@ void keybindings_init(void)
0, 0, "popup_gototagdefinition", _("Go to tag definition"));
keys[GEANY_KEYS_POPUP_GOTOTAGDECLARATION] = fill(cb_func_current_word,
0, 0, "popup_gototagdeclaration", _("Go to tag declaration"));
keys[GEANY_KEYS_POPUP_CONTEXTACTION] = fill(cb_func_current_word,
0, 0, "popup_contextaction", _("Context Action"));
// now load user defined keys
if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
@ -363,6 +365,7 @@ static void keybindings_add_accels()
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_POPUP_FINDUSAGE, find_usage1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_POPUP_GOTOTAGDEFINITION, goto_tag_definition1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_POPUP_GOTOTAGDECLARATION, goto_tag_declaration1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_POPUP_CONTEXTACTION, context_action1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_MENU_GOTOLINE, go_to_line);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_EDIT_TOLOWERCASE, to_lower_case1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_EDIT_TOUPPERCASE, to_upper_case1);
@ -746,7 +749,6 @@ static void cb_func_menu_findnextsel(G_GNUC_UNUSED guint key_id)
on_find_nextsel1_activate(NULL, NULL);
}
static void cb_func_menu_replace(G_GNUC_UNUSED guint key_id)
{
on_replace1_activate(NULL, NULL);
@ -905,6 +907,10 @@ static void cb_func_current_word(guint key_id)
on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
"goto_tag_declaration1")), NULL);
break;
case GEANY_KEYS_POPUP_CONTEXTACTION:
on_context_action1_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
"context_action1")), NULL);
break;
}
}

View File

@ -72,6 +72,7 @@ enum
GEANY_KEYS_POPUP_FINDUSAGE,
GEANY_KEYS_POPUP_GOTOTAGDEFINITION,
GEANY_KEYS_POPUP_GOTOTAGDECLARATION,
GEANY_KEYS_POPUP_CONTEXTACTION,
GEANY_KEYS_MENU_FULLSCREEN,
GEANY_KEYS_MENU_MESSAGEWINDOW,

View File

@ -153,6 +153,7 @@ void configuration_save()
}
#endif
g_key_file_set_string(config, PACKAGE, "custom_date_format", app->custom_date_format);
g_key_file_set_string(config, PACKAGE, "context_action_cmd", app->context_action_cmd);
if (app->custom_commands != NULL)
{
g_key_file_set_string_list(config, PACKAGE, "custom_commands",
@ -348,6 +349,7 @@ gboolean configuration_load()
app->brace_match_ltgt = utils_get_setting_boolean(config, PACKAGE, "brace_match_ltgt", FALSE);
app->switch_msgwin_pages = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE);
app->custom_date_format = utils_get_setting_string(config, PACKAGE, "custom_date_format", "");
app->context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
app->custom_commands = g_key_file_get_string_list(config, PACKAGE, "custom_commands", NULL, NULL);
app->editor_font = utils_get_setting_string(config, PACKAGE, "editor_font", GEANY_DEFAULT_FONT_EDITOR);
app->tagbar_font = utils_get_setting_string(config, PACKAGE, "tagbar_font", GEANY_DEFAULT_FONT_SYMBOL_LIST);

View File

@ -755,6 +755,7 @@ void main_quit()
g_free(app->tagbar_font);
g_free(app->msgwin_font);
g_free(app->long_line_color);
g_free(app->context_action_cmd);
g_free(app->pref_template_developer);
g_free(app->pref_template_company);
g_free(app->pref_template_mail);

View File

@ -112,6 +112,9 @@ void prefs_init_dialog(void)
widget = lookup_widget(app->prefs_dialog, "radio_tab_left");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
widget = lookup_widget(app->prefs_dialog, "entry_contextaction");
gtk_entry_set_text(GTK_ENTRY(widget), app->context_action_cmd);
// Interface settings
widget = lookup_widget(app->prefs_dialog, "check_list_symbol");
@ -439,6 +442,10 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
widget = lookup_widget(app->prefs_dialog, "check_show_notebook_tabs");
app->show_notebook_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "entry_contextaction");
g_free(app->context_action_cmd);
app->context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
// Interface settings
widget = lookup_widget(app->prefs_dialog, "check_list_symbol");