[Xfce4-commits] <mousepad:master> * configure.in.in, po/POTFILES.in: Fix dist-check. Thank to Brian for the hint. * mousepad/mousepad-{dialogs, window}.c: Implement tab size menu. You can set the default tab sizes in the rc file (MiscDefaultTabSizes). * mousepad/mousepad-window{-ui.xml, .c}: Reorder menus a bit. Go menu is now called 'Navigation' and the 'go to line' item is added to this menu. The document menu contains the tab size menu from now on. * Rename some functions and vars to more suitable names.
Nick Schermer
noreply at xfce.org
Sat May 5 21:30:53 CEST 2012
Updating branch refs/heads/master
to 2d4c6469fc7680fe83c02af5ecfd4791f96de79f (commit)
from 0960eed1341ae9789caafcb61500fa2006a12a67 (commit)
commit 2d4c6469fc7680fe83c02af5ecfd4791f96de79f
Author: Nick Schermer <nick at xfce.org>
Date: Tue Oct 23 08:57:10 2007 +0000
* configure.in.in, po/POTFILES.in: Fix dist-check. Thank to Brian
for the hint.
* mousepad/mousepad-{dialogs,window}.c: Implement tab size menu. You
can set the default tab sizes in the rc file (MiscDefaultTabSizes).
* mousepad/mousepad-window{-ui.xml,.c}: Reorder menus a bit. Go menu
is now called 'Navigation' and the 'go to line' item is added to this
menu. The document menu contains the tab size menu from now on.
* Rename some functions and vars to more suitable names.
(Old svn revision: 26178)
ChangeLog | 15 ++-
configure.in.in | 2 +-
mousepad/mousepad-dialogs.c | 45 +++++-
mousepad/mousepad-dialogs.h | 31 ++--
mousepad/mousepad-document.c | 18 +-
mousepad/mousepad-document.h | 2 +-
mousepad/mousepad-preferences.c | 13 ++-
mousepad/mousepad-util.c | 4 +-
mousepad/mousepad-util.h | 2 +-
mousepad/mousepad-view.c | 32 ++--
mousepad/mousepad-view.h | 6 +-
mousepad/mousepad-window-ui.xml | 19 ++-
mousepad/mousepad-window.c | 314 +++++++++++++++++++++++++++++++--------
po/POTFILES.in | 1 +
14 files changed, 384 insertions(+), 120 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8ee2fc6..f06185a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,17 @@
+2007-10-23 Nick Schermer <nick at xfce.org>
+ * configure.in.in, po/POTFILES.in: Fix dist-check. Thank to Brian
+ for the hint.
+ * mousepad/mousepad-{dialogs,window}.c: Implement tab size menu. You
+ can set the default tab sizes in the rc file (MiscDefaultTabSizes).
+ * mousepad/mousepad-window{-ui.xml,.c}: Reorder menus a bit. Go menu
+ is now called 'Navigation' and the 'go to line' item is added to this
+ menu. The document menu contains the tab size menu from now on.
+ * Rename some functions and vars to more suitable names.
+
+
2007-10-22 Nick Schermer <nick at xfce.org>
- * configure.in.in: Make sure __OPTIMIZE__ is enable in normal builds.
- * mousepad/mousepad-private.h: Tune G_LIKELY macros for pure boolean.
+ * configure.in.in: Make sure __OPTIMIZE__ is enabled in normal builds.
+ * mousepad/mousepad-private.h: Tune G_LIKELY macros for pure booleans.
2007-10-22 Nick Schermer <nick at xfce.org>
diff --git a/configure.in.in b/configure.in.in
index 226aa6e..7099a24 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -21,7 +21,7 @@ dnl *** Initialize autoconf ***
dnl ***************************
AC_COPYRIGHT([Copyright (c) 2007
The Xfce development team. All rights reserved.])
-AC_INIT([Mousepad], [mousepad_version()], [http://bugzilla.xfce.org/], [mousepad])
+AC_INIT([Mousepad], [mousepad_version], [http://bugzilla.xfce.org/], [mousepad])
AC_PREREQ([2.50])
AC_CANONICAL_TARGET()
AC_REVISION([$Id$])
diff --git a/mousepad/mousepad-dialogs.c b/mousepad/mousepad-dialogs.c
index cfb4fa6..e404cba 100644
--- a/mousepad/mousepad-dialogs.c
+++ b/mousepad/mousepad-dialogs.c
@@ -79,9 +79,46 @@ mousepad_dialogs_show_error (GtkWindow *parent,
gint
-mousepad_dialogs_jump_to (GtkWindow *parent,
- gint current_line,
- gint last_line)
+mousepad_dialogs_other_tab_size (GtkWindow *parent,
+ gint active_size)
+{
+ GtkWidget *dialog;
+ GtkWidget *scale;
+
+ /* build dialog */
+ dialog = gtk_dialog_new_with_buttons (_("Select Tab Size"),
+ parent,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CANCEL, MOUSEPAD_RESPONSE_CANCEL,
+ GTK_STOCK_OK, MOUSEPAD_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), MOUSEPAD_RESPONSE_OK);
+
+ /* create scale widget */
+ scale = gtk_hscale_new_with_range (1, 32, 1);
+ gtk_range_set_value (GTK_RANGE (scale), active_size);
+ gtk_scale_set_digits (GTK_SCALE (scale), 0);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
+ gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scale, TRUE, TRUE, 0);
+ gtk_widget_show (scale);
+
+ /* run the dialog */
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == MOUSEPAD_RESPONSE_OK)
+ active_size = gtk_range_get_value (GTK_RANGE (scale));
+
+ /* destroy the dialog */
+ gtk_widget_destroy (dialog);
+
+ return active_size;
+}
+
+
+
+gint
+mousepad_dialogs_go_to_line (GtkWindow *parent,
+ gint current_line,
+ gint last_line)
{
GtkWidget *dialog;
GtkWidget *hbox;
@@ -91,7 +128,7 @@ mousepad_dialogs_jump_to (GtkWindow *parent,
gint line_number = 0;
/* build the dialog */
- dialog = gtk_dialog_new_with_buttons (_("Jump To"),
+ dialog = gtk_dialog_new_with_buttons (_("Go To Line"),
parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CANCEL, MOUSEPAD_RESPONSE_CANCEL,
diff --git a/mousepad/mousepad-dialogs.h b/mousepad/mousepad-dialogs.h
index 74a7887..128488c 100644
--- a/mousepad/mousepad-dialogs.h
+++ b/mousepad/mousepad-dialogs.h
@@ -28,6 +28,7 @@ enum {
MOUSEPAD_RESPONSE_DONT_SAVE,
MOUSEPAD_RESPONSE_FIND,
MOUSEPAD_RESPONSE_JUMP_TO,
+ MOUSEPAD_RESPONSE_OK,
MOUSEPAD_RESPONSE_OVERWRITE,
MOUSEPAD_RESPONSE_RELOAD,
MOUSEPAD_RESPONSE_REPLACE,
@@ -36,28 +37,30 @@ enum {
MOUSEPAD_RESPONSE_CHECK_ENTRY
};
-GtkWidget *mousepad_dialogs_image_button (const gchar *stock_id,
- const gchar *label);
+GtkWidget *mousepad_dialogs_image_button (const gchar *stock_id,
+ const gchar *label);
-void mousepad_dialogs_show_about (GtkWindow *parent);
+void mousepad_dialogs_show_about (GtkWindow *parent);
+void mousepad_dialogs_show_error (GtkWindow *parent,
+ const GError *error,
+ const gchar *message);
-void mousepad_dialogs_show_error (GtkWindow *parent,
- const GError *error,
- const gchar *message);
+gint mousepad_dialogs_other_tab_size (GtkWindow *parent,
+ gint active_size);
-gint mousepad_dialogs_jump_to (GtkWindow *parent,
- gint current_line,
- gint last_line);
+gint mousepad_dialogs_go_to_line (GtkWindow *parent,
+ gint current_line,
+ gint last_line);
-gboolean mousepad_dialogs_clear_recent (GtkWindow *parent);
+gboolean mousepad_dialogs_clear_recent (GtkWindow *parent);
-gint mousepad_dialogs_save_changes (GtkWindow *parent);
+gint mousepad_dialogs_save_changes (GtkWindow *parent);
-gint mousepad_dialogs_ask_overwrite (GtkWindow *parent,
- const gchar *filename);
+gint mousepad_dialogs_ask_overwrite (GtkWindow *parent,
+ const gchar *filename);
-gint mousepad_dialogs_ask_reload (GtkWindow *parent);
+gint mousepad_dialogs_ask_reload (GtkWindow *parent);
G_END_DECLS
diff --git a/mousepad/mousepad-document.c b/mousepad/mousepad-document.c
index 6104dda..856e262 100644
--- a/mousepad/mousepad-document.c
+++ b/mousepad/mousepad-document.c
@@ -189,7 +189,7 @@ mousepad_document_init (MousepadDocument *document)
GtkTargetList *target_list;
gboolean word_wrap, auto_indent, line_numbers, insert_spaces;
gchar *font_name;
- gint tab_width;
+ gint tab_size;
MousepadPreferences *preferences;
/* private structure */
@@ -238,7 +238,7 @@ mousepad_document_init (MousepadDocument *document)
"view-line-numbers", &line_numbers,
"view-auto-indent", &auto_indent,
"view-font-name", &font_name,
- "view-tab-width", &tab_width,
+ "view-tab-size", &tab_size,
"view-insert-spaces", &insert_spaces,
NULL);
@@ -250,7 +250,7 @@ mousepad_document_init (MousepadDocument *document)
mousepad_document_set_font (document, font_name);
mousepad_view_set_line_numbers (document->textview, line_numbers);
mousepad_view_set_auto_indent (document->textview, auto_indent);
- mousepad_view_set_tab_width (document->textview, tab_width);
+ mousepad_view_set_tab_size (document->textview, tab_size);
mousepad_view_set_insert_spaces (document->textview, insert_spaces);
/* cleanup */
@@ -314,7 +314,7 @@ mousepad_document_notify_cursor_position (GtkTextBuffer *buffer,
{
GtkTextIter iter;
guint line, column = 0;
- gint tab_width;
+ gint tab_size;
_mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
_mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document));
@@ -325,11 +325,11 @@ mousepad_document_notify_cursor_position (GtkTextBuffer *buffer,
/* get the current line number */
line = gtk_text_iter_get_line (&iter) + 1;
- /* get the tab width */
- tab_width = mousepad_view_get_tab_width (document->textview);
+ /* get the tab size */
+ tab_size = mousepad_view_get_tab_size (document->textview);
/* get the column */
- column = mousepad_util_get_real_line_offset (&iter, tab_width) + 1;
+ column = mousepad_util_get_real_line_offset (&iter, tab_size) + 1;
/* emit the signal */
g_signal_emit (G_OBJECT (document), document_signals[CURSOR_CHANGED], 0, line, column);
@@ -472,8 +472,8 @@ mousepad_document_focus_textview (MousepadDocument *document)
void
-mousepad_document_jump_to_line (MousepadDocument *document,
- gint line_number)
+mousepad_document_go_to_line (MousepadDocument *document,
+ gint line_number)
{
GtkTextIter iter;
diff --git a/mousepad/mousepad-document.h b/mousepad/mousepad-document.h
index 550cab1..0906563 100644
--- a/mousepad/mousepad-document.h
+++ b/mousepad/mousepad-document.h
@@ -76,7 +76,7 @@ void mousepad_document_set_word_wrap (MousepadDocument
void mousepad_document_focus_textview (MousepadDocument *document);
-void mousepad_document_jump_to_line (MousepadDocument *document,
+void mousepad_document_go_to_line (MousepadDocument *document,
gint line_number);
void mousepad_document_send_statusbar_signals (MousepadDocument *document);
diff --git a/mousepad/mousepad-preferences.c b/mousepad/mousepad-preferences.c
index 5cb2fdc..69ff461 100644
--- a/mousepad/mousepad-preferences.c
+++ b/mousepad/mousepad-preferences.c
@@ -68,6 +68,7 @@ enum
/* hidden settings */
PROP_MISC_ALWAYS_SHOW_TABS,
PROP_MISC_CYCLE_TABS,
+ PROP_MISC_DEFAULT_TAB_SIZES,
PROP_MISC_PATH_IN_TITLE,
PROP_MISC_RECENT_MENU_ITEMS,
PROP_MISC_REMEMBER_GEOMETRY,
@@ -255,8 +256,8 @@ mousepad_preferences_class_init (MousepadPreferencesClass *klass)
g_object_class_install_property (gobject_class,
PROP_VIEW_TAB_WIDTH,
- g_param_spec_int ("view-tab-width",
- "ViewTabWidth",
+ g_param_spec_int ("view-tab-size",
+ "ViewTabSize",
NULL,
1, 32, 8,
MOUSEPAD_PARAM_READWRITE));
@@ -326,6 +327,14 @@ mousepad_preferences_class_init (MousepadPreferencesClass *klass)
MOUSEPAD_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
+ PROP_MISC_DEFAULT_TAB_SIZES,
+ g_param_spec_string ("misc-default-tab-sizes",
+ "MiscDefaultTabSizes",
+ NULL,
+ "2,3,4,8",
+ MOUSEPAD_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
PROP_MISC_PATH_IN_TITLE,
g_param_spec_boolean ("misc-path-in-title",
"MiscPathInTitle",
diff --git a/mousepad/mousepad-util.c b/mousepad/mousepad-util.c
index 61808e8..4e5a2f8 100644
--- a/mousepad/mousepad-util.c
+++ b/mousepad/mousepad-util.c
@@ -151,7 +151,7 @@ mousepad_util_set_tooltip (GtkWidget *widget,
gint
mousepad_util_get_real_line_offset (const GtkTextIter *iter,
- gint tab_width)
+ gint tab_size)
{
gint offset = 0;
GtkTextIter needle = *iter;
@@ -161,7 +161,7 @@ mousepad_util_get_real_line_offset (const GtkTextIter *iter,
while (!gtk_text_iter_equal (&needle, iter))
{
if (gtk_text_iter_get_char (&needle) == '\t')
- offset += (tab_width - (offset % tab_width));
+ offset += (tab_size - (offset % tab_size));
else
offset++;
diff --git a/mousepad/mousepad-util.h b/mousepad/mousepad-util.h
index cbb686e..7af6066 100644
--- a/mousepad/mousepad-util.h
+++ b/mousepad/mousepad-util.h
@@ -73,7 +73,7 @@ void mousepad_util_set_tooltip (GtkWidget *widget,
const gchar *string);
gint mousepad_util_get_real_line_offset (const GtkTextIter *iter,
- gint tab_width);
+ gint tab_size);
gboolean mousepad_util_forward_iter_to_text (GtkTextIter *iter,
const GtkTextIter *limit);
diff --git a/mousepad/mousepad-view.c b/mousepad/mousepad-view.c
index 42d64da..b979690 100644
--- a/mousepad/mousepad-view.c
+++ b/mousepad/mousepad-view.c
@@ -103,7 +103,7 @@ struct _MousepadView
guint auto_indent : 1;
guint line_numbers : 1;
guint insert_spaces : 1;
- guint tab_width;
+ guint tab_size;
};
@@ -161,7 +161,7 @@ mousepad_view_init (MousepadView *view)
view->auto_indent = FALSE;
view->line_numbers = FALSE;
view->insert_spaces = FALSE;
- view->tab_width = 8;
+ view->tab_size = 8;
/* initialize vertical selection */
view->marks = NULL;
@@ -326,7 +326,7 @@ mousepad_view_style_set (GtkWidget *widget,
NULL);
/* update the tab stops */
- mousepad_view_set_tab_width (view, view->tab_width);
+ mousepad_view_set_tab_size (view, view->tab_size);
}
}
@@ -791,15 +791,15 @@ mousepad_view_increase_indent_iter (MousepadView *view,
if (view->insert_spaces && tab)
{
/* get the offset */
- offset = mousepad_util_get_real_line_offset (iter, view->tab_width);
+ offset = mousepad_util_get_real_line_offset (iter, view->tab_size);
/* calculate the length to inline with a tab */
- inline_len = offset % view->tab_width;
+ inline_len = offset % view->tab_size;
if (inline_len == 0)
- length = view->tab_width;
+ length = view->tab_size;
else
- length = view->tab_width - inline_len;
+ length = view->tab_size - inline_len;
/* create spaces string */
string = g_strnfill (length, ' ');
@@ -835,7 +835,7 @@ mousepad_view_decrease_indent_iter (MousepadView *view,
if (gtk_text_iter_starts_line (iter))
{
/* set number of columns */
- columns = tab ? view->tab_width : 1;
+ columns = tab ? view->tab_size : 1;
/* walk until we've removed enough columns */
while (columns > 0)
@@ -844,7 +844,7 @@ mousepad_view_decrease_indent_iter (MousepadView *view,
c = gtk_text_iter_get_char (&end);
if (c == '\t')
- columns -= view->tab_width;
+ columns -= view->tab_size;
else if (c == ' ')
columns--;
else
@@ -865,7 +865,7 @@ mousepad_view_decrease_indent_iter (MousepadView *view,
c = gtk_text_iter_get_char (iter);
if (c == '\t')
- columns -= view->tab_width;
+ columns -= view->tab_size;
else if (c == ' ')
columns--;
else
@@ -1377,8 +1377,8 @@ mousepad_view_set_auto_indent (MousepadView *view,
void
-mousepad_view_set_tab_width (MousepadView *view,
- gint tab_width)
+mousepad_view_set_tab_size (MousepadView *view,
+ gint tab_size)
{
PangoTabArray *tab_array;
gint layout_width;
@@ -1387,10 +1387,10 @@ mousepad_view_set_tab_width (MousepadView *view,
_mousepad_return_if_fail (GTK_IS_TEXT_VIEW (view));
/* set the value */
- view->tab_width = tab_width;
+ view->tab_size = tab_size;
/* get the pixel width of the tab size */
- layout_width = mousepad_view_calculate_layout_width (GTK_WIDGET (view), view->tab_width, ' ');
+ layout_width = mousepad_view_calculate_layout_width (GTK_WIDGET (view), view->tab_size, ' ');
if (G_LIKELY (layout_width != -1))
{
@@ -1461,11 +1461,11 @@ mousepad_view_get_auto_indent (MousepadView *view)
gint
-mousepad_view_get_tab_width (MousepadView *view)
+mousepad_view_get_tab_size (MousepadView *view)
{
_mousepad_return_val_if_fail (MOUSEPAD_IS_VIEW (view), -1);
- return view->tab_width;
+ return view->tab_size;
}
diff --git a/mousepad/mousepad-view.h b/mousepad/mousepad-view.h
index eef1d5a..8ddff04 100644
--- a/mousepad/mousepad-view.h
+++ b/mousepad/mousepad-view.h
@@ -51,8 +51,8 @@ void mousepad_view_set_line_numbers (MousepadView *view
void mousepad_view_set_auto_indent (MousepadView *view,
gboolean auto_indent);
-void mousepad_view_set_tab_width (MousepadView *view,
- gint tab_width);
+void mousepad_view_set_tab_size (MousepadView *view,
+ gint tab_size);
void mousepad_view_set_insert_spaces (MousepadView *view,
gboolean insert_spaces);
@@ -63,7 +63,7 @@ gboolean mousepad_view_get_line_numbers (MousepadView *view
gboolean mousepad_view_get_auto_indent (MousepadView *view);
-gint mousepad_view_get_tab_width (MousepadView *view);
+gint mousepad_view_get_tab_size (MousepadView *view);
gboolean mousepad_view_get_insert_spaces (MousepadView *view);
diff --git a/mousepad/mousepad-window-ui.xml b/mousepad/mousepad-window-ui.xml
index 4304bab..6c4e6b8 100644
--- a/mousepad/mousepad-window-ui.xml
+++ b/mousepad/mousepad-window-ui.xml
@@ -63,8 +63,6 @@
<menuitem action="find-next" />
<menuitem action="find-previous" />
<menuitem action="replace" />
- <separator />
- <menuitem action="jump-to" />
</menu>
<menu action="view-menu">
@@ -74,20 +72,29 @@
</menu>
<menu action="document-menu">
- <menuitem action="word-wrap" />
<menuitem action="line-numbers" />
+ <separator />
<menuitem action="auto-indent" />
- <menuitem action="insert-spaces" />
+ <menuitem action="word-wrap" />
+ <separator />
+ <menu action="tab-size-menu">
+ <placeholder name="placeholder-tab-sizes" />
+ <separator />
+ <menuitem action="insert-spaces" />
+ </menu>
</menu>
- <menu action="go-menu">
+ <menu action="navigation-menu">
<menuitem action="back" />
<menuitem action="forward" />
<separator />
- <placeholder name="placeholder-go-items" />
+ <placeholder name="placeholder-documents" />
+ <separator />
+ <menuitem action="go-to-line" />
</menu>
<menu action="help-menu">
+ <menuitem action="contents" />
<menuitem action="about" />
</menu>
</menubar>
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 2b2b90b..88d985c 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -28,6 +28,9 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#include <glib/gstdio.h>
@@ -150,7 +153,9 @@ static void mousepad_window_can_undo (MousepadW
static void mousepad_window_can_redo (MousepadWindow *window,
gboolean can_redo);
-/* menu updaters */
+/* menu functions */
+static void mousepad_window_menu_tab_sizes (MousepadWindow *window);
+static void mousepad_window_menu_tab_sizes_update (MousepadWindow *window);
static void mousepad_window_update_actions (MousepadWindow *window);
static gboolean mousepad_window_update_gomenu_idle (gpointer user_data);
static void mousepad_window_update_gomenu_idle_destroy (gpointer user_data);
@@ -230,18 +235,18 @@ static void mousepad_window_action_find_previous (GtkAction
MousepadWindow *window);
static void mousepad_window_action_replace (GtkAction *action,
MousepadWindow *window);
-static void mousepad_window_action_jump_to (GtkAction *action,
- MousepadWindow *window);
static void mousepad_window_action_select_font (GtkAction *action,
MousepadWindow *window);
static void mousepad_window_action_statusbar (GtkToggleAction *action,
MousepadWindow *window);
-static void mousepad_window_action_word_wrap (GtkToggleAction *action,
- MousepadWindow *window);
static void mousepad_window_action_line_numbers (GtkToggleAction *action,
MousepadWindow *window);
static void mousepad_window_action_auto_indent (GtkToggleAction *action,
MousepadWindow *window);
+static void mousepad_window_action_word_wrap (GtkToggleAction *action,
+ MousepadWindow *window);
+static void mousepad_window_action_tab_size (GtkToggleAction *action,
+ MousepadWindow *window);
static void mousepad_window_action_insert_spaces (GtkToggleAction *action,
MousepadWindow *window);
static void mousepad_window_action_prev_tab (GtkAction *action,
@@ -250,6 +255,10 @@ static void mousepad_window_action_next_tab (GtkAction
MousepadWindow *window);
static void mousepad_window_action_goto (GtkRadioAction *action,
GtkNotebook *notebook);
+static void mousepad_window_action_go_to_line (GtkAction *action,
+ MousepadWindow *window);
+static void mousepad_window_action_contents (GtkAction *action,
+ MousepadWindow *window);
static void mousepad_window_action_about (GtkAction *action,
MousepadWindow *window);
@@ -342,27 +351,29 @@ static const GtkActionEntry action_entries[] =
{ "find-next", NULL, N_("Find _Next"), NULL, N_("Search forwards for the same text"), G_CALLBACK (mousepad_window_action_find_next), },
{ "find-previous", NULL, N_("Find _Previous"), NULL, N_("Search backwards for the same text"), G_CALLBACK (mousepad_window_action_find_previous), },
{ "replace", GTK_STOCK_FIND_AND_REPLACE, NULL, NULL, N_("Search for and replace text"), G_CALLBACK (mousepad_window_action_replace), },
- { "jump-to", GTK_STOCK_JUMP_TO, NULL, NULL, N_("Go to a specific line"), G_CALLBACK (mousepad_window_action_jump_to), },
{ "view-menu", NULL, N_("_View"), NULL, NULL, NULL, },
{ "font", GTK_STOCK_SELECT_FONT, NULL, NULL, N_("Change the editor font"), G_CALLBACK (mousepad_window_action_select_font), },
{ "document-menu", NULL, N_("_Document"), NULL, NULL, NULL, },
+ { "tab-size-menu", NULL, N_("_Tab Size"), NULL, NULL, NULL, },
- { "go-menu", NULL, N_("_Go"), NULL, },
+ { "navigation-menu", NULL, N_("_Navigation"), NULL, },
{ "back", GTK_STOCK_GO_BACK, NULL, NULL, N_("Select the previous tab"), G_CALLBACK (mousepad_window_action_prev_tab), },
{ "forward", GTK_STOCK_GO_FORWARD, NULL, NULL, N_("Select the next tab"), G_CALLBACK (mousepad_window_action_next_tab), },
+ { "go-to-line", GTK_STOCK_JUMP_TO, N_("_Go to line..."), NULL, N_("Go to a specific line"), G_CALLBACK (mousepad_window_action_go_to_line), },
{ "help-menu", NULL, N_("_Help"), NULL, },
+ { "contents", GTK_STOCK_HELP, N_ ("_Contents"), "F1", N_("Display the Mousepad user manual"), G_CALLBACK (mousepad_window_action_contents), },
{ "about", GTK_STOCK_ABOUT, NULL, NULL, N_("About this application"), G_CALLBACK (mousepad_window_action_about), },
};
static const GtkToggleActionEntry toggle_action_entries[] =
{
{ "statusbar", NULL, N_("_Statusbar"), NULL, N_("Change the visibility of the statusbar"), G_CALLBACK (mousepad_window_action_statusbar), FALSE, },
- { "word-wrap", NULL, N_("_Word Wrap"), NULL, N_("Toggle breaking lines in between words"), G_CALLBACK (mousepad_window_action_word_wrap), FALSE, },
{ "line-numbers", NULL, N_("_Line Numbers"), NULL, N_("Show line numbers"), G_CALLBACK (mousepad_window_action_line_numbers), FALSE, },
{ "auto-indent", NULL, N_("_Auto Indent"), NULL, N_("Auto indent a new line"), G_CALLBACK (mousepad_window_action_auto_indent), FALSE, },
+ { "word-wrap", NULL, N_("_Word Wrap"), NULL, N_("Toggle breaking lines in between words"), G_CALLBACK (mousepad_window_action_word_wrap), FALSE, },
{ "insert-spaces", NULL, N_("_Insert Spaces"), NULL, N_("Insert spaces when the tab button is pressed"), G_CALLBACK (mousepad_window_action_insert_spaces), FALSE, },
};
@@ -514,6 +525,9 @@ mousepad_window_init (MousepadWindow *window)
/* create the recent menu (idle) */
mousepad_window_recent_menu (window);
+ /* add tab size menu */
+ mousepad_window_menu_tab_sizes (window);
+
/* set accel group for the window */
accel_group = gtk_ui_manager_get_accel_group (window->ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
@@ -1259,7 +1273,7 @@ mousepad_window_notebook_removed (GtkNotebook *notebook,
g_signal_handlers_disconnect_by_func (G_OBJECT (document->buffer), mousepad_window_modified_changed, window);
/* unset the go menu item (part of the old window) */
- g_object_set_data (G_OBJECT (page), I_("go-menu-action"), NULL);
+ g_object_set_data (G_OBJECT (page), I_("navigation-menu-action"), NULL);
/* get the number of pages in this notebook */
npages = gtk_notebook_get_n_pages (notebook);
@@ -1495,9 +1509,141 @@ mousepad_window_can_redo (MousepadWindow *window,
/**
- * Menu Update Functions
+ * Menu Functions
**/
static void
+mousepad_window_menu_tab_sizes (MousepadWindow *window)
+{
+ GtkRadioAction *action;
+ GSList *group = NULL;
+ gint i, size, merge_id;
+ gchar *name, *tmp;
+ gchar **tab_sizes;
+
+ /* lock menu updates */
+ lock_menu_updates++;
+
+ /* get the default tab sizes and active tab size */
+ g_object_get (G_OBJECT (window->preferences),
+ "misc-default-tab-sizes", &tmp,
+ NULL);
+
+ /* get sizes array and free the temp string */
+ tab_sizes = g_strsplit (tmp, ",", -1);
+ g_free (tmp);
+
+ /* create merge id */
+ merge_id = gtk_ui_manager_new_merge_id (window->ui_manager);
+
+ /* add the default sizes to the menu */
+ for (i = 0; tab_sizes[i] != NULL; i++)
+ {
+ /* convert the string to a number */
+ size = strtol (tab_sizes[i], NULL, 10);
+
+ /* keep this in sync with the property limits */
+ if (G_LIKELY (size > 0))
+ {
+ /* keep this in sync with the properties */
+ size = CLAMP (size, 1, 32);
+
+ /* create action name */
+ name = g_strdup_printf ("tab-size-%d", size);
+
+ action = gtk_radio_action_new (name, name + 9, NULL, NULL, size);
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+ g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (mousepad_window_action_tab_size), window);
+ gtk_action_group_add_action_with_accel (window->action_group, GTK_ACTION (action), "");
+
+ /* release the action */
+ g_object_unref (G_OBJECT (action));
+
+ /* add the action to the go menu */
+ gtk_ui_manager_add_ui (window->ui_manager, merge_id,
+ "/main-menu/document-menu/tab-size-menu/placeholder-tab-sizes",
+ name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ /* cleanup */
+ g_free (name);
+ }
+ }
+
+ /* cleanup the array */
+ g_strfreev (tab_sizes);
+
+ /* create other action */
+ action = gtk_radio_action_new ("tab-size-other", "", _("Set custom tab size"), NULL, 0);
+ gtk_radio_action_set_group (action, group);
+ g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (mousepad_window_action_tab_size), window);
+ gtk_action_group_add_action_with_accel (window->action_group, GTK_ACTION (action), "");
+
+ /* release the action */
+ g_object_unref (G_OBJECT (action));
+
+ /* add the action to the go menu */
+ gtk_ui_manager_add_ui (window->ui_manager, merge_id,
+ "/main-menu/document-menu/tab-size-menu/placeholder-tab-sizes",
+ "tab-size-other", "tab-size-other", GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ /* unlock */
+ lock_menu_updates--;
+}
+
+
+
+static void
+mousepad_window_menu_tab_sizes_update (MousepadWindow *window)
+{
+ gint tab_size;
+ gchar *name, *label = NULL;
+ GtkAction *action;
+
+ _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (window->active));
+
+ /* avoid menu actions */
+ lock_menu_updates++;
+
+ /* get tab size of active document */
+ tab_size = mousepad_view_get_tab_size (window->active->textview);
+
+ /* check if there is a default item with this number */
+ name = g_strdup_printf ("tab-size-%d", tab_size);
+ action = gtk_action_group_get_action (window->action_group, name);
+ g_free (name);
+
+ if (action)
+ {
+ /* toggle the default action */
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ }
+ else
+ {
+ /* create suitable label */
+ label = g_strdup_printf (_("Other (%d)..."), tab_size);
+ }
+
+ /* get other action */
+ action = gtk_action_group_get_action (window->action_group, "tab-size-other");
+
+ /* toggle other action if needed */
+ if (label)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+
+ /* set action label */
+ g_object_set (G_OBJECT (action), "label", label ? label : _("Other..."), NULL);
+
+ /* cleanup */
+ g_free (label);
+
+ /* allow menu actions again */
+ lock_menu_updates--;
+}
+
+
+
+
+static void
mousepad_window_update_actions (MousepadWindow *window)
{
GtkAction *action;
@@ -1557,6 +1703,8 @@ mousepad_window_update_actions (MousepadWindow *window)
action = gtk_action_group_get_action (window->action_group, "auto-indent");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
+ mousepad_window_menu_tab_sizes_update (window);
+
active = mousepad_view_get_insert_spaces (document->textview);
action = gtk_action_group_get_action (window->action_group, "insert-spaces");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
@@ -1570,7 +1718,7 @@ mousepad_window_update_actions (MousepadWindow *window)
mousepad_window_selection_changed (document, has_selection, window);
/* active this tab in the go menu */
- action = g_object_get_data (G_OBJECT (document), I_("go-menu-action"));
+ action = g_object_get_data (G_OBJECT (document), I_("navigation-menu-action"));
if (G_LIKELY (action != NULL))
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
@@ -1643,7 +1791,7 @@ mousepad_window_update_gomenu_idle (gpointer user_data)
g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (mousepad_window_action_goto), window->notebook);
/* connect the action to the document to we can easily active it when the user switched from tab */
- g_object_set_data (G_OBJECT (document), I_("go-menu-action"), action);
+ g_object_set_data (G_OBJECT (document), I_("navigation-menu-action"), action);
if (G_LIKELY (n < 9))
{
@@ -1664,7 +1812,7 @@ mousepad_window_update_gomenu_idle (gpointer user_data)
/* add the action to the go menu */
gtk_ui_manager_add_ui (window->ui_manager, window->gomenu_merge_id,
- "/main-menu/go-menu/placeholder-go-items",
+ "/main-menu/navigation-menu/placeholder-documents",
name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
/* cleanup */
@@ -2808,28 +2956,6 @@ mousepad_window_action_replace (GtkAction *action,
static void
-mousepad_window_action_jump_to (GtkAction *action,
- MousepadWindow *window)
-{
- MousepadDocument *document = window->active;
- gint current_line, last_line, line;
-
- if (G_LIKELY (document))
- {
- /* get the current and last line number */
- mousepad_document_line_numbers (document, ¤t_line, &last_line);
-
- /* run the jump to dialog and wait for the response */
- line = mousepad_dialogs_jump_to (GTK_WINDOW (window), current_line, last_line);
-
- if (G_LIKELY (line > 0))
- mousepad_document_jump_to_line (document, line);
- }
-}
-
-
-
-static void
mousepad_window_action_select_font (GtkAction *action,
MousepadWindow *window)
{
@@ -2871,7 +2997,7 @@ mousepad_window_action_select_font (GtkAction *action,
mousepad_document_set_font (document, font_name);
/* update the tab array */
- mousepad_view_set_tab_width (document->textview, mousepad_view_get_tab_width (document->textview));
+ mousepad_view_set_tab_size (document->textview, mousepad_view_get_tab_size (document->textview));
}
/* cleanup */
@@ -2926,10 +3052,10 @@ mousepad_window_action_statusbar (GtkToggleAction *action,
static void
-mousepad_window_action_word_wrap (GtkToggleAction *action,
- MousepadWindow *window)
+mousepad_window_action_line_numbers (GtkToggleAction *action,
+ MousepadWindow *window)
{
- gboolean word_wrap;
+ gboolean line_numbers;
_mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (window->active));
@@ -2938,22 +3064,22 @@ mousepad_window_action_word_wrap (GtkToggleAction *action,
return;
/* get the current state */
- word_wrap = gtk_toggle_action_get_active (action);
+ line_numbers = gtk_toggle_action_get_active (action);
- /* store this as the last used wrap mode */
- g_object_set (G_OBJECT (window->preferences), "view-word-wrap", word_wrap, NULL);
+ /* save as the last used line number setting */
+ g_object_set (G_OBJECT (window->preferences), "view-line-numbers", line_numbers, NULL);
- /* set the wrapping mode of the current document */
- mousepad_document_set_word_wrap (window->active, word_wrap);
+ /* update the active document */
+ mousepad_view_set_line_numbers (window->active->textview, line_numbers);
}
static void
-mousepad_window_action_line_numbers (GtkToggleAction *action,
- MousepadWindow *window)
+mousepad_window_action_auto_indent (GtkToggleAction *action,
+ MousepadWindow *window)
{
- gboolean line_numbers;
+ gboolean auto_indent;
_mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (window->active));
@@ -2962,22 +3088,22 @@ mousepad_window_action_line_numbers (GtkToggleAction *action,
return;
/* get the current state */
- line_numbers = gtk_toggle_action_get_active (action);
+ auto_indent = gtk_toggle_action_get_active (action);
- /* save as the last used line number setting */
- g_object_set (G_OBJECT (window->preferences), "view-line-numbers", line_numbers, NULL);
+ /* save as the last auto indent mode */
+ g_object_set (G_OBJECT (window->preferences), "view-auto-indent", auto_indent, NULL);
/* update the active document */
- mousepad_view_set_line_numbers (window->active->textview, line_numbers);
+ mousepad_view_set_auto_indent (window->active->textview, auto_indent);
}
static void
-mousepad_window_action_auto_indent (GtkToggleAction *action,
- MousepadWindow *window)
+mousepad_window_action_word_wrap (GtkToggleAction *action,
+ MousepadWindow *window)
{
- gboolean auto_indent;
+ gboolean word_wrap;
_mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (window->active));
@@ -2986,18 +3112,57 @@ mousepad_window_action_auto_indent (GtkToggleAction *action,
return;
/* get the current state */
- auto_indent = gtk_toggle_action_get_active (action);
+ word_wrap = gtk_toggle_action_get_active (action);
- /* save as the last auto indent mode */
- g_object_set (G_OBJECT (window->preferences), "view-auto-indent", auto_indent, NULL);
+ /* store this as the last used wrap mode */
+ g_object_set (G_OBJECT (window->preferences), "view-word-wrap", word_wrap, NULL);
- /* update the active document */
- mousepad_view_set_auto_indent (window->active->textview, auto_indent);
+ /* set the wrapping mode of the current document */
+ mousepad_document_set_word_wrap (window->active, word_wrap);
}
static void
+mousepad_window_action_tab_size (GtkToggleAction *action,
+ MousepadWindow *window)
+{
+ gboolean tab_size;
+
+ /* leave when menu updates are locked */
+ if (lock_menu_updates)
+ return;
+
+ _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (window->active));
+
+ if (gtk_toggle_action_get_active (action))
+ {
+ /* get the tab size */
+ tab_size = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+
+ /* other... item clicked */
+ if (tab_size == 0)
+ {
+ /* get tab size from document */
+ tab_size = mousepad_view_get_tab_size (window->active->textview);
+
+ /* select other size in dialog */
+ tab_size = mousepad_dialogs_other_tab_size (GTK_WINDOW (window), tab_size);
+ }
+
+ /* store as last used value */
+ g_object_set (G_OBJECT (window->preferences), "view-tab-size", tab_size, NULL);
+
+ /* set the value */
+ mousepad_view_set_tab_size (window->active->textview, tab_size);
+
+ /* update menu */
+ mousepad_window_menu_tab_sizes_update (window);
+ }
+}
+
+
+static void
mousepad_window_action_insert_spaces (GtkToggleAction *action,
MousepadWindow *window)
{
@@ -3077,6 +3242,37 @@ mousepad_window_action_goto (GtkRadioAction *action,
static void
+mousepad_window_action_go_to_line (GtkAction *action,
+ MousepadWindow *window)
+{
+ MousepadDocument *document = window->active;
+ gint current_line, last_line, line;
+
+ if (G_LIKELY (document))
+ {
+ /* get the current and last line number */
+ mousepad_document_line_numbers (document, ¤t_line, &last_line);
+
+ /* run the jump to dialog and wait for the response */
+ line = mousepad_dialogs_go_to_line (GTK_WINDOW (window), current_line, last_line);
+
+ if (G_LIKELY (line > 0))
+ mousepad_document_go_to_line (document, line);
+ }
+}
+
+
+
+static void
+mousepad_window_action_contents (GtkAction *action,
+ MousepadWindow *window)
+{
+
+}
+
+
+
+static void
mousepad_window_action_about (GtkAction *action,
MousepadWindow *window)
{
diff --git a/po/POTFILES.in b/po/POTFILES.in
index db1522a..022d836 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -9,6 +9,7 @@ mousepad/mousepad-document.c
mousepad/mousepad-encoding-dialog.c
mousepad/mousepad-file.c
mousepad/mousepad-preferences.c
+mousepad/mousepad-print.c
mousepad/mousepad-replace-dialog.c
mousepad/mousepad-search-bar.c
mousepad/mousepad-statusbar.c
More information about the Xfce4-commits
mailing list