Revision: 3146 http://geany.svn.sourceforge.net/geany/?rev=3146&view=rev Author: eht16 Date: 2008-10-23 20:55:06 +0000 (Thu, 23 Oct 2008)
Log Message: ----------- Replace Goto line text entry field in the toolbar with a spin button. Remove dialogs_show_goto_line(), use the more generic dialogs_show_input_numeric() instead. Increase limit of the maximum line number from 99999 to 100000000.
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/src/callbacks.c trunk/src/dialogs.c trunk/src/dialogs.h trunk/src/editor.c trunk/src/editor.h trunk/src/interface.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/ChangeLog 2008-10-23 20:55:06 UTC (rev 3146) @@ -2,6 +2,12 @@
* src/filetypes.c: Add simple auto-detection for HTML files without proper extension. + * geany.glade, src/callbacks.c, src/dialogs.c, src/dialogs.h, + src/editor.c, src/editor.h, src/interface.c: + Replace Goto line text entry field in the toolbar with a spin button. + Remove dialogs_show_goto_line(), use the more generic + dialogs_show_input_numeric() instead. + Increase limit of the maximum line number from 99999 to 100000000.
2008-10-22 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/geany.glade 2008-10-23 20:55:06 UTC (rev 3146) @@ -2042,18 +2042,17 @@ <property name="is_important">False</property>
<child> - <widget class="GtkEntry" id="toolbutton_goto_entry"> + <widget class="GtkSpinButton" id="toolbutton_goto_entry"> <property name="visible">True</property> <property name="tooltip" translatable="yes">Enter a line number and jump to it.</property> <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">5</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">*</property> - <property name="activates_default">False</property> - <property name="width_chars">8</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_IF_VALID</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">True</property> + <property name="adjustment">0 1 100000000 1 10 0</property> <signal name="activate" handler="on_toolbutton_goto_entry_activate" last_modification_time="Mon, 01 Sep 2008 16:06:59 GMT"/> </widget> </child>
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/src/callbacks.c 2008-10-23 20:55:06 UTC (rev 3146) @@ -1172,7 +1172,19 @@ on_go_to_line_activate (GtkMenuItem *menuitem, gpointer user_data) { - dialogs_show_goto_line(); + static gdouble val = 1; + + if (dialogs_show_input_numeric(_("Go to Line"), _("Enter the line you want to go to:"), + &val, 1, 100000000, 1)) + { + GeanyDocument *doc = document_get_current(); + + if (doc != NULL) + { + if (! editor_goto_line(doc->editor, val - 1)) + utils_beep(); + } + } }
@@ -1184,22 +1196,15 @@ if (response == GTK_RESPONSE_ACCEPT) { GeanyDocument *doc = document_get_current(); - gint line = strtol(gtk_entry_get_text(GTK_ENTRY(user_data)), NULL, 10); + gint line = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(user_data));
- if (doc != NULL && line > 0 && line <= sci_get_line_count(doc->editor->sci)) + if (doc != NULL) { - gint pos; - - line--; /* the user counts lines from 1, we begin at 0 so bring the user line to our one */ - pos = sci_get_position_from_line(doc->editor->sci, line); - editor_goto_pos(doc->editor, pos, TRUE); + if (! editor_goto_line(doc->editor, line - 1)) + utils_beep(); } - else - { - utils_beep(); - } } - if (dialog) + if (dialog != NULL) gtk_widget_destroy(GTK_WIDGET(dialog)); }
Modified: trunk/src/dialogs.c =================================================================== --- trunk/src/dialogs.c 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/src/dialogs.c 2008-10-23 20:55:06 UTC (rev 3146) @@ -965,32 +965,6 @@ }
-void dialogs_show_goto_line() -{ - GtkWidget *dialog, *label, *entry, *vbox; - - dialog = gtk_dialog_new_with_buttons(_("Go to Line"), GTK_WINDOW(main_widgets.window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); - vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); - gtk_widget_set_name(dialog, "GeanyDialog"); - - label = gtk_label_new(_("Enter the line you want to go to:")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - entry = gtk_entry_new(); - gtk_entry_set_max_length(GTK_ENTRY(entry), 6); - gtk_entry_set_width_chars(GTK_ENTRY(entry), 30); - - g_signal_connect(entry, "activate", G_CALLBACK(on_goto_line_entry_activate), dialog); - g_signal_connect(dialog, "response", G_CALLBACK(on_goto_line_dialog_response), entry); - - gtk_container_add(GTK_CONTAINER(vbox), label); - gtk_container_add(GTK_CONTAINER(vbox), entry); - gtk_widget_show_all(dialog); -} - - void dialogs_show_file_properties(GeanyDocument *doc) { GtkWidget *dialog, *label, *table, *hbox, *image, *perm_table, *check, *vbox;
Modified: trunk/src/dialogs.h =================================================================== --- trunk/src/dialogs.h 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/src/dialogs.h 2008-10-23 20:55:06 UTC (rev 3146) @@ -51,8 +51,6 @@ gboolean dialogs_show_input_numeric(const gchar *title, const gchar *label_text, gdouble *value, gdouble min, gdouble max, gdouble step);
-void dialogs_show_goto_line(void); - void dialogs_show_file_properties(GeanyDocument *doc);
gboolean dialogs_show_question(const gchar *text, ...) G_GNUC_PRINTF (1, 2);
Modified: trunk/src/editor.c =================================================================== --- trunk/src/editor.c 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/src/editor.c 2008-10-23 20:55:06 UTC (rev 3146) @@ -3780,6 +3780,19 @@ }
+/* Convenience function for editor_goto_pos() to pass in a line number. */ +gboolean editor_goto_line(GeanyEditor *editor, gint line) +{ + gint pos; + + g_return_val_if_fail(editor, FALSE); + g_return_val_if_fail(line >= 0 && line <= sci_get_line_count(editor->sci), FALSE); + + pos = sci_get_position_from_line(editor->sci, line); + return editor_goto_pos(editor, pos, TRUE); +} + + /* Move to position @a pos, switching to the document if necessary, * setting a marker if @a mark is set. */ gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark)
Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/src/editor.h 2008-10-23 20:55:06 UTC (rev 3146) @@ -236,6 +236,8 @@
gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark);
+gboolean editor_goto_line(GeanyEditor *editor, gint line_no); + void editor_set_indentation_guides(GeanyEditor *editor);
void editor_apply_update_prefs(GeanyEditor *editor);
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2008-10-23 18:44:05 UTC (rev 3145) +++ trunk/src/interface.c 2008-10-23 20:55:06 UTC (rev 3146) @@ -248,6 +248,7 @@ GtkWidget *toolbutton_search; GtkWidget *separatortoolitem5; GtkWidget *toolbutton_goto_item; + GtkObject *toolbutton_goto_entry_adj; GtkWidget *toolbutton_goto_entry; GtkWidget *toolbutton_goto; GtkWidget *separatortoolitem8; @@ -1218,12 +1219,14 @@ gtk_widget_show (toolbutton_goto_item); gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton_goto_item);
- toolbutton_goto_entry = gtk_entry_new (); + toolbutton_goto_entry_adj = gtk_adjustment_new (0, 1, 100000000, 1, 10, 0); + toolbutton_goto_entry = gtk_spin_button_new (GTK_ADJUSTMENT (toolbutton_goto_entry_adj), 1, 0); gtk_widget_show (toolbutton_goto_entry); gtk_container_add (GTK_CONTAINER (toolbutton_goto_item), toolbutton_goto_entry); gtk_tooltips_set_tip (tooltips, toolbutton_goto_entry, _("Enter a line number and jump to it."), NULL); - gtk_entry_set_max_length (GTK_ENTRY (toolbutton_goto_entry), 5); - gtk_entry_set_width_chars (GTK_ENTRY (toolbutton_goto_entry), 8); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (toolbutton_goto_entry), TRUE); + gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (toolbutton_goto_entry), GTK_UPDATE_IF_VALID); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (toolbutton_goto_entry), TRUE);
toolbutton_goto = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-jump-to"); gtk_widget_show (toolbutton_goto);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.