Applied patch from Dave Moore to add simple code navigation (thank you).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1590 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2007-06-02 16:14:07 +00:00
parent 06cae45432
commit 3f30a4cc96
12 changed files with 404 additions and 37 deletions

View File

@ -1448,7 +1448,7 @@
<widget class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
<property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
<property name="tooltips">True</property>
<property name="show_arrow">True</property>
@ -1620,6 +1620,53 @@
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_back">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="tooltip" translatable="yes">Navigate back a location</property>
<property name="stock_id">gtk-go-back</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
<signal name="clicked" handler="on_back_activate" last_modification_time="Fri, 25 May 2007 03:53:11 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton_forward">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="tooltip" translatable="yes">Navigate forward a location</property>
<property name="stock_id">gtk-go-forward</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
<signal name="clicked" handler="on_forward_activate" last_modification_time="Fri, 25 May 2007 03:53:16 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="separatortoolitem10">
<property name="visible">True</property>
<property name="draw">True</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton13">
<property name="visible">True</property>
@ -1861,6 +1908,19 @@
</packing>
</child>
<child>
<widget class="GtkSeparatorToolItem" id="separatortoolitem1">
<property name="visible">True</property>
<property name="draw">False</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="toolbutton19">
<property name="visible">True</property>
@ -4367,11 +4427,49 @@ Bottom
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_toolbar_undo">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Display the Redo and Undo buttons in the toolbar</property>
<property name="label" translatable="yes">Show Redo and Undo buttons</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_toolbar_navigation">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Display the Back and Forward buttons in the toolbar used for code navigation</property>
<property name="label" translatable="yes">Show Back and Forward buttons</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_toolbar_compile">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Display the Compile and Run buttons in the toolbar</property>
<property name="label" translatable="yes">Show Compile and Run</property>
<property name="label" translatable="yes">Show Compile and Run buttons</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
@ -4409,26 +4507,7 @@ Bottom
<widget class="GtkCheckButton" id="check_toolbar_zoom">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Display the Zoom In and Zoom Out buttons in the toolbar</property>
<property name="label" translatable="yes">Show Zoom In and Zoom Out</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_toolbar_undo">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Display the Redo and Undo buttons in the toolbar</property>
<property name="label" translatable="yes">Show Redo and Undo buttons</property>
<property name="label" translatable="yes">Show Zoom In and Zoom Out buttons</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>

View File

@ -20,6 +20,7 @@ SRCS = \
keyfile.c keyfile.h \
main.c main.h geany.h \
msgwindow.c msgwindow.h \
navqueue.c navqueue.h \
notebook.c notebook.h \
prefs.c prefs.h \
project.c project.h \

View File

@ -58,6 +58,7 @@
#include "symbols.h"
#include "tools.h"
#include "project.h"
#include "navqueue.h"
#ifdef HAVE_VTE
# include "vte.h"
@ -77,7 +78,6 @@ static gboolean ignore_toolbar_toggle = FALSE;
// flag to indicate that an insert callback was triggered from the file menu,
// so we need to store the current cursor position in editor_info.click_pos.
/// TODO rename me
static gboolean insert_callback_from_menu = FALSE;
// represents the state at switching a notebook page(in the left treeviews widget), to not emit
@ -1216,10 +1216,20 @@ on_goto_tag_activate (GtkMenuItem *menuitem,
tmtag = symbols_find_in_workspace(editor_info.current_word, type);
if (tmtag != NULL)
{
gint old_idx = document_get_cur_idx(); // get idx before switching the file
if (utils_goto_file_line(
tmtag->atts.entry.file->work_object.file_name,
TRUE, tmtag->atts.entry.line))
{
// first add old file as old position
navqueue_new_position(doc_list[old_idx].tm_file->file_name,
sci_get_line_from_position(doc_list[old_idx].sci, editor_info.click_pos) + 1);
navqueue_new_position(tmtag->atts.entry.file->work_object.file_name,
tmtag->atts.entry.line);
return;
}
}
// if we are here, there was no match and we are beeping ;-)
utils_beep();
@ -2226,3 +2236,18 @@ on_menu_toggle_all_additional_widgets1_activate
}
void
on_forward_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
navqueue_go_forward();
}
void
on_back_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
navqueue_go_back();
}

View File

@ -608,6 +608,13 @@ void
on_menu_toggle_all_additional_widgets1_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_back_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_forward_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_file1_activate (GtkMenuItem *menuitem,

View File

@ -110,6 +110,7 @@ typedef struct MyApp
gboolean pref_toolbar_show_search;
gboolean pref_toolbar_show_goto;
gboolean pref_toolbar_show_undo;
gboolean pref_toolbar_show_navigation;
gboolean pref_toolbar_show_compile;
gboolean pref_toolbar_show_zoom;
gboolean pref_toolbar_show_colour;
@ -167,6 +168,7 @@ typedef struct MyApp
GtkWidget *undo_items[3];
GtkWidget *save_buttons[4];
GtkWidget *sensitive_buttons[39];
GtkWidget *navigation_buttons[2];
GtkWidget *open_colorsel;
GtkWidget *open_fontsel;
GtkWidget *open_filesel;

View File

@ -213,6 +213,9 @@ create_window1 (void)
GtkWidget *toolbutton_undo;
GtkWidget *toolbutton_redo;
GtkWidget *separatortoolitem9;
GtkWidget *toolbutton_back;
GtkWidget *toolbutton_forward;
GtkWidget *separatortoolitem10;
GtkWidget *tmp_image;
GtkWidget *toolbutton13;
GtkWidget *toolbutton26;
@ -230,6 +233,7 @@ create_window1 (void)
GtkWidget *entry_goto_line;
GtkWidget *toolbutton25;
GtkWidget *separatortoolitem8;
GtkWidget *separatortoolitem1;
GtkWidget *toolbutton19;
GtkWidget *vpaned1;
GtkWidget *hpaned1;
@ -983,7 +987,7 @@ create_window1 (void)
toolbar1 = gtk_toolbar_new ();
gtk_widget_show (toolbar1);
gtk_box_pack_start (GTK_BOX (vbox1), toolbar1, FALSE, FALSE, 0);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_ICONS);
tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1));
menutoolbutton1 = (GtkWidget*) gtk_menu_tool_button_new_from_stock ("gtk-new");
@ -1040,6 +1044,22 @@ create_window1 (void)
gtk_widget_show (separatortoolitem9);
gtk_container_add (GTK_CONTAINER (toolbar1), separatortoolitem9);
toolbutton_back = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-go-back");
gtk_widget_show (toolbutton_back);
gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton_back);
gtk_widget_set_sensitive (toolbutton_back, FALSE);
gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_back), tooltips, _("Navigate back a location"), NULL);
toolbutton_forward = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-go-forward");
gtk_widget_show (toolbutton_forward);
gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton_forward);
gtk_widget_set_sensitive (toolbutton_forward, FALSE);
gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_forward), tooltips, _("Navigate forward a location"), NULL);
separatortoolitem10 = (GtkWidget*) gtk_separator_tool_item_new ();
gtk_widget_show (separatortoolitem10);
gtk_container_add (GTK_CONTAINER (toolbar1), separatortoolitem10);
tmp_image = gtk_image_new_from_stock ("gtk-convert", tmp_toolbar_icon_size);
gtk_widget_show (tmp_image);
toolbutton13 = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Compile"));
@ -1120,6 +1140,11 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (toolbar1), separatortoolitem8);
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (separatortoolitem8), FALSE);
separatortoolitem1 = (GtkWidget*) gtk_separator_tool_item_new ();
gtk_widget_show (separatortoolitem1);
gtk_container_add (GTK_CONTAINER (toolbar1), separatortoolitem1);
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (separatortoolitem1), FALSE);
toolbutton19 = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-quit");
gtk_widget_show (toolbutton19);
gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton19);
@ -1519,6 +1544,12 @@ create_window1 (void)
g_signal_connect ((gpointer) toolbutton_redo, "clicked",
G_CALLBACK (on_redo1_activate),
NULL);
g_signal_connect ((gpointer) toolbutton_back, "clicked",
G_CALLBACK (on_back_activate),
NULL);
g_signal_connect ((gpointer) toolbutton_forward, "clicked",
G_CALLBACK (on_forward_activate),
NULL);
g_signal_connect ((gpointer) toolbutton13, "clicked",
G_CALLBACK (on_compile_button_clicked),
NULL);
@ -1748,6 +1779,9 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, toolbutton_undo, "toolbutton_undo");
GLADE_HOOKUP_OBJECT (window1, toolbutton_redo, "toolbutton_redo");
GLADE_HOOKUP_OBJECT (window1, separatortoolitem9, "separatortoolitem9");
GLADE_HOOKUP_OBJECT (window1, toolbutton_back, "toolbutton_back");
GLADE_HOOKUP_OBJECT (window1, toolbutton_forward, "toolbutton_forward");
GLADE_HOOKUP_OBJECT (window1, separatortoolitem10, "separatortoolitem10");
GLADE_HOOKUP_OBJECT (window1, toolbutton13, "toolbutton13");
GLADE_HOOKUP_OBJECT (window1, toolbutton26, "toolbutton26");
GLADE_HOOKUP_OBJECT (window1, separatortoolitem6, "separatortoolitem6");
@ -1764,6 +1798,7 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, entry_goto_line, "entry_goto_line");
GLADE_HOOKUP_OBJECT (window1, toolbutton25, "toolbutton25");
GLADE_HOOKUP_OBJECT (window1, separatortoolitem8, "separatortoolitem8");
GLADE_HOOKUP_OBJECT (window1, separatortoolitem1, "separatortoolitem1");
GLADE_HOOKUP_OBJECT (window1, toolbutton19, "toolbutton19");
GLADE_HOOKUP_OBJECT (window1, vpaned1, "vpaned1");
GLADE_HOOKUP_OBJECT (window1, hpaned1, "hpaned1");
@ -2436,10 +2471,11 @@ create_prefs_dialog (void)
GtkWidget *alignment14;
GtkWidget *vbox16;
GtkWidget *check_toolbar_fileops;
GtkWidget *check_toolbar_undo;
GtkWidget *check_toolbar_navigation;
GtkWidget *check_toolbar_compile;
GtkWidget *check_toolbar_colour;
GtkWidget *check_toolbar_zoom;
GtkWidget *check_toolbar_undo;
GtkWidget *check_toolbar_search;
GtkWidget *check_toolbar_goto;
GtkWidget *check_toolbar_quit;
@ -3065,7 +3101,21 @@ create_prefs_dialog (void)
gtk_tooltips_set_tip (tooltips, check_toolbar_fileops, _("Display the New, Open, Close, Save and Reload buttons in the toolbar"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_fileops), FALSE);
check_toolbar_compile = gtk_check_button_new_with_mnemonic (_("Show Compile and Run"));
check_toolbar_undo = gtk_check_button_new_with_mnemonic (_("Show Redo and Undo buttons"));
gtk_widget_show (check_toolbar_undo);
gtk_box_pack_start (GTK_BOX (vbox16), check_toolbar_undo, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (check_toolbar_undo, GTK_CAN_FOCUS);
gtk_tooltips_set_tip (tooltips, check_toolbar_undo, _("Display the Redo and Undo buttons in the toolbar"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_undo), FALSE);
check_toolbar_navigation = gtk_check_button_new_with_mnemonic (_("Show Back and Forward buttons"));
gtk_widget_show (check_toolbar_navigation);
gtk_box_pack_start (GTK_BOX (vbox16), check_toolbar_navigation, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (check_toolbar_navigation, GTK_CAN_FOCUS);
gtk_tooltips_set_tip (tooltips, check_toolbar_navigation, _("Display the Back and Forward buttons in the toolbar used for code navigation"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_navigation), FALSE);
check_toolbar_compile = gtk_check_button_new_with_mnemonic (_("Show Compile and Run buttons"));
gtk_widget_show (check_toolbar_compile);
gtk_box_pack_start (GTK_BOX (vbox16), check_toolbar_compile, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (check_toolbar_compile, GTK_CAN_FOCUS);
@ -3079,20 +3129,13 @@ create_prefs_dialog (void)
gtk_tooltips_set_tip (tooltips, check_toolbar_colour, _("Display the Colour Chooser button in the toolbar"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_colour), FALSE);
check_toolbar_zoom = gtk_check_button_new_with_mnemonic (_("Show Zoom In and Zoom Out"));
check_toolbar_zoom = gtk_check_button_new_with_mnemonic (_("Show Zoom In and Zoom Out buttons"));
gtk_widget_show (check_toolbar_zoom);
gtk_box_pack_start (GTK_BOX (vbox16), check_toolbar_zoom, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (check_toolbar_zoom, GTK_CAN_FOCUS);
gtk_tooltips_set_tip (tooltips, check_toolbar_zoom, _("Display the Zoom In and Zoom Out buttons in the toolbar"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_zoom), FALSE);
check_toolbar_undo = gtk_check_button_new_with_mnemonic (_("Show Redo and Undo buttons"));
gtk_widget_show (check_toolbar_undo);
gtk_box_pack_start (GTK_BOX (vbox16), check_toolbar_undo, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (check_toolbar_undo, GTK_CAN_FOCUS);
gtk_tooltips_set_tip (tooltips, check_toolbar_undo, _("Display the Redo and Undo buttons in the toolbar"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_undo), FALSE);
check_toolbar_search = gtk_check_button_new_with_mnemonic (_("Show Search field"));
gtk_widget_show (check_toolbar_search);
gtk_box_pack_start (GTK_BOX (vbox16), check_toolbar_search, FALSE, FALSE, 0);
@ -4057,10 +4100,11 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment14, "alignment14");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox16, "vbox16");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_fileops, "check_toolbar_fileops");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_undo, "check_toolbar_undo");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_navigation, "check_toolbar_navigation");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_compile, "check_toolbar_compile");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_colour, "check_toolbar_colour");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_zoom, "check_toolbar_zoom");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_undo, "check_toolbar_undo");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_search, "check_toolbar_search");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_goto, "check_toolbar_goto");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_quit, "check_toolbar_quit");

View File

@ -145,7 +145,7 @@ void configuration_save()
GtkTextBuffer *buffer;
GtkTextIter start, end;
g_key_file_load_from_file(config, configfile, 0, NULL);
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
// gets the text from the scribble textview
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble")));
@ -251,6 +251,7 @@ void configuration_save()
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_goto", app->pref_toolbar_show_goto);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_zoom", app->pref_toolbar_show_zoom);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_undo", app->pref_toolbar_show_undo);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_navigation", app->pref_toolbar_show_navigation);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_compile", app->pref_toolbar_show_compile);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_colour", app->pref_toolbar_show_colour);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_fileops", app->pref_toolbar_show_fileops);
@ -358,7 +359,7 @@ gboolean configuration_load()
setptr(configfile, g_strconcat(app->datadir, G_DIR_SEPARATOR_S "geany.conf", NULL));
}
g_key_file_load_from_file(config, configfile, 0, NULL);
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
app->toolbar_visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE);
{
@ -458,6 +459,7 @@ gboolean configuration_load()
app->pref_toolbar_show_zoom = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_zoom", FALSE);
app->pref_toolbar_show_compile = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_compile", TRUE);
app->pref_toolbar_show_undo = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_undo", FALSE);
app->pref_toolbar_show_navigation = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_navigation", TRUE);
app->pref_toolbar_show_colour = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_colour", TRUE);
app->pref_toolbar_show_fileops = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_fileops", TRUE);
app->pref_toolbar_show_quit = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_quit", TRUE);

View File

@ -59,6 +59,7 @@
#include "symbols.h"
#include "project.h"
#include "tools.h"
#include "navqueue.h"
#ifdef HAVE_SOCKET
# include "socket.h"
@ -332,6 +333,8 @@ static void main_init(void)
app->sensitive_buttons[36] = lookup_widget(app->window, "menu_format1");
app->sensitive_buttons[37] = lookup_widget(app->window, "menu_open_selected_file1");
app->sensitive_buttons[38] = lookup_widget(app->window, "menu_insert_special_chars1");
app->navigation_buttons[0] = lookup_widget(app->window, "toolbutton_back");
app->navigation_buttons[1] = lookup_widget(app->window, "toolbutton_forward");
app->redo_items[0] = lookup_widget(app->popup_menu, "redo1");
app->redo_items[1] = lookup_widget(app->window, "menu_redo2");
app->redo_items[2] = lookup_widget(app->window, "toolbutton_redo");
@ -721,6 +724,7 @@ gint main(gint argc, gchar **argv)
gtk_tree_model_foreach(GTK_TREE_MODEL(tv.store_openfiles), treeviews_find_node, GINT_TO_POINTER(idx));
build_menu_update(idx);
treeviews_update_tag_list(idx, FALSE);
navqueue_init();
#ifdef G_OS_WIN32
// hide "Build" menu item, at least until it is available for Windows
@ -763,6 +767,7 @@ void main_quit()
socket_finalize();
#endif
navqueue_free();
keybindings_free();
filetypes_save_commands();
filetypes_free_types();

154
src/navqueue.c Normal file
View File

@ -0,0 +1,154 @@
/*
* navqueue.c - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2007 Dave Moore <wrex006@gmail.com>
*
* 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.
*
*/
#include "geany.h"
#include "navqueue.h"
#include "sciwrappers.h"
#include "document.h"
#include "utils.h"
// for the navigation history queue
typedef struct
{
gchar *file;
/// TODO maybe it is better to work on positions than on lines to be more accurate when
/// switching back or forward, sci_get_position_from_line() could be used for tm_tag lines
gint line;
} filepos;
GQueue *navigation_queue;
guint nav_queue_pos;
void navqueue_init()
{
navigation_queue = g_queue_new();
nav_queue_pos = 0;
}
void navqueue_free()
{
while (! g_queue_is_empty(navigation_queue))
{
g_free(g_queue_pop_tail(navigation_queue));
}
g_queue_free(navigation_queue);
}
static void adjust_buttons()
{
if (g_queue_get_length(navigation_queue) < 2)
{
gtk_widget_set_sensitive(app->navigation_buttons[0], FALSE);
gtk_widget_set_sensitive(app->navigation_buttons[1], FALSE);
return;
}
if (nav_queue_pos == 0)
{
gtk_widget_set_sensitive(app->navigation_buttons[0], TRUE);
gtk_widget_set_sensitive(app->navigation_buttons[1], FALSE);
return;
}
// forward should be sensitive since where not at the start
gtk_widget_set_sensitive(app->navigation_buttons[1], TRUE);
// back should be sensitive if there's a place to go back to
(nav_queue_pos < g_queue_get_length(navigation_queue) - 1) ?
gtk_widget_set_sensitive(app->navigation_buttons[0], TRUE) :
gtk_widget_set_sensitive(app->navigation_buttons[0], FALSE);
}
void navqueue_new_position(gchar *file, gint line)
{
filepos *npos;
guint i;
npos = g_new0(filepos, 1);
npos->file = file;
npos->line = line;
// if we've jumped to a new position from
// inside the queue rather than going forward
if (nav_queue_pos > 0)
{
for (i = 0; i < nav_queue_pos; i++)
{
g_free(g_queue_pop_head(navigation_queue));
}
nav_queue_pos = 0;
}
/// TODO add check to not add an entry if "Go To Defintion" on a definition is used
g_queue_push_head(navigation_queue, npos);
adjust_buttons();
}
void navqueue_go_back()
{
filepos *fprev;
// return if theres no place to go back to
if (g_queue_is_empty(navigation_queue) ||
nav_queue_pos >= g_queue_get_length(navigation_queue) - 1)
return;
// jump back
fprev = g_queue_peek_nth(navigation_queue, nav_queue_pos + 1);
if (utils_goto_file_line(fprev->file, TRUE, fprev->line))
{
nav_queue_pos++;
}
else
{
/// TODO: add option to re open the file
g_queue_pop_nth(navigation_queue, nav_queue_pos + 1);
}
adjust_buttons();
}
void navqueue_go_forward()
{
filepos *fnext;
if (nav_queue_pos < 1 || g_queue_get_length(navigation_queue) < 2)
return;
// jump forward
fnext = g_queue_peek_nth(navigation_queue, nav_queue_pos - 1);
if (utils_goto_file_line(fnext->file, TRUE, fnext->line))
{
nav_queue_pos--;
}
else
{
/// TODO: add option to re open the file
g_queue_pop_nth(navigation_queue, nav_queue_pos - 1);
}
adjust_buttons();
}

38
src/navqueue.h Normal file
View File

@ -0,0 +1,38 @@
/*
* navqueue.h - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2007 Dave Moore <wrex006@gmail.com>
*
* 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.
*
*/
#ifndef GEANY_NAVQUEUE_H
#define GEANY_NAVQUEUE_H 1
void navqueue_init();
void navqueue_free();
void navqueue_new_position(gchar *file, gint line);
void navqueue_go_back();
void navqueue_go_forward();
#endif

View File

@ -182,6 +182,9 @@ void prefs_init_dialog(void)
widget = lookup_widget(app->prefs_dialog, "check_toolbar_undo");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_toolbar_show_undo);
widget = lookup_widget(app->prefs_dialog, "check_toolbar_navigation");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_toolbar_show_navigation);
widget = lookup_widget(app->prefs_dialog, "check_toolbar_colour");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_toolbar_show_colour);
@ -508,6 +511,9 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
widget = lookup_widget(app->prefs_dialog, "check_toolbar_undo");
app->pref_toolbar_show_undo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_toolbar_navigation");
app->pref_toolbar_show_navigation = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_toolbar_compile");
app->pref_toolbar_show_compile = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

View File

@ -673,6 +673,10 @@ void ui_update_toolbar_items()
ui_widget_show_hide(lookup_widget(app->window, "toolbutton_undo"), app->pref_toolbar_show_undo);
ui_widget_show_hide(lookup_widget(app->window, "toolbutton_redo"), app->pref_toolbar_show_undo);
ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem9"), app->pref_toolbar_show_undo);
// navigation
ui_widget_show_hide(lookup_widget(app->window, "toolbutton_back"), app->pref_toolbar_show_navigation);
ui_widget_show_hide(lookup_widget(app->window, "toolbutton_forward"), app->pref_toolbar_show_navigation);
ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem10"), app->pref_toolbar_show_navigation);
// quit
ui_widget_show_hide(lookup_widget(app->window, "toolbutton19"), app->pref_toolbar_show_quit);
ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem8"), app->pref_toolbar_show_quit);