Author: nick
Date: 2007-10-23 08:57:10 +0000 (Tue, 23 Oct 2007)
New Revision: 26178
Modified:
mousepad/branches/nick_0_3/ChangeLog
mousepad/branches/nick_0_3/configure.in.in
mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c
mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h
mousepad/branches/nick_0_3/mousepad/mousepad-document.c
mousepad/branches/nick_0_3/mousepad/mousepad-document.h
mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c
mousepad/branches/nick_0_3/mousepad/mousepad-util.c
mousepad/branches/nick_0_3/mousepad/mousepad-util.h
mousepad/branches/nick_0_3/mousepad/mousepad-view.c
mousepad/branches/nick_0_3/mousepad/mousepad-view.h
mousepad/branches/nick_0_3/mousepad/mousepad-window-ui.xml
mousepad/branches/nick_0_3/mousepad/mousepad-window.c
mousepad/branches/nick_0_3/po/POTFILES.in
Log:
* 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.
Modified: mousepad/branches/nick_0_3/ChangeLog
===================================================================
--- mousepad/branches/nick_0_3/ChangeLog 2007-10-22 20:20:34 UTC (rev
26177)
+++ mousepad/branches/nick_0_3/ChangeLog 2007-10-23 08:57:10 UTC (rev
26178)
@@ -1,6 +1,17 @@
+2007-10-23 Nick Schermer <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
- * 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 <[EMAIL PROTECTED]>
Modified: mousepad/branches/nick_0_3/configure.in.in
===================================================================
--- mousepad/branches/nick_0_3/configure.in.in 2007-10-22 20:20:34 UTC (rev
26177)
+++ mousepad/branches/nick_0_3/configure.in.in 2007-10-23 08:57:10 UTC (rev
26178)
@@ -21,7 +21,7 @@
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$])
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c 2007-10-22
20:20:34 UTC (rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c 2007-10-23
08:57:10 UTC (rev 26178)
@@ -79,10 +79,47 @@
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;
GtkWidget *label;
@@ -91,7 +128,7 @@
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,
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h 2007-10-22
20:20:34 UTC (rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h 2007-10-23
08:57:10 UTC (rev 26178)
@@ -28,6 +28,7 @@
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 @@
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
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-document.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-document.c 2007-10-22
20:20:34 UTC (rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-document.c 2007-10-23
08:57:10 UTC (rev 26178)
@@ -189,7 +189,7 @@
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 @@
"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_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 @@
{
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 @@
/* 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 @@
void
-mousepad_document_jump_to_line (MousepadDocument *document,
- gint line_number)
+mousepad_document_go_to_line (MousepadDocument *document,
+ gint line_number)
{
GtkTextIter iter;
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-document.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-document.h 2007-10-22
20:20:34 UTC (rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-document.h 2007-10-23
08:57:10 UTC (rev 26178)
@@ -76,7 +76,7 @@
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);
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c 2007-10-22
20:20:34 UTC (rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-preferences.c 2007-10-23
08:57:10 UTC (rev 26178)
@@ -68,6 +68,7 @@
/* 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 @@
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_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",
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-util.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-util.c 2007-10-22 20:20:34 UTC
(rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-util.c 2007-10-23 08:57:10 UTC
(rev 26178)
@@ -151,7 +151,7 @@
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 @@
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++;
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-util.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-util.h 2007-10-22 20:20:34 UTC
(rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-util.h 2007-10-23 08:57:10 UTC
(rev 26178)
@@ -73,7 +73,7 @@
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);
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-view.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-view.c 2007-10-22 20:20:34 UTC
(rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-view.c 2007-10-23 08:57:10 UTC
(rev 26178)
@@ -103,7 +103,7 @@
guint auto_indent : 1;
guint line_numbers : 1;
guint insert_spaces : 1;
- guint tab_width;
+ guint tab_size;
};
@@ -161,7 +161,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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_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 @@
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;
}
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-view.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-view.h 2007-10-22 20:20:34 UTC
(rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-view.h 2007-10-23 08:57:10 UTC
(rev 26178)
@@ -51,8 +51,8 @@
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_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);
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-window-ui.xml
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-window-ui.xml 2007-10-22
20:20:34 UTC (rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-window-ui.xml 2007-10-23
08:57:10 UTC (rev 26178)
@@ -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>
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-window.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-window.c 2007-10-22
20:20:34 UTC (rev 26177)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-window.c 2007-10-23
08:57:10 UTC (rev 26178)
@@ -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_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 @@
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 @@
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 @@
{ "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 @@
/* 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 @@
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 @@
/**
- * 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 @@
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_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 @@
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 @@
/* 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 @@
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_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 @@
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 @@
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 @@
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 @@
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 @@
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)
{
Modified: mousepad/branches/nick_0_3/po/POTFILES.in
===================================================================
--- mousepad/branches/nick_0_3/po/POTFILES.in 2007-10-22 20:20:34 UTC (rev
26177)
+++ mousepad/branches/nick_0_3/po/POTFILES.in 2007-10-23 08:57:10 UTC (rev
26178)
@@ -9,6 +9,7 @@
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
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits