Added moo_stock_label() and moo_stock_name(); added stock-label, stock-tooltip, stock-display-name Action properties
parent
ed26de434f
commit
404aa637c6
|
@ -33,6 +33,7 @@
|
|||
#include "mooutils/moostock.h"
|
||||
#include "mooutils/mooutils-fs.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
#include "mooutils/mooi18n.h"
|
||||
#include "mooutils/xdgmime/xdgmime.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1226,32 +1227,29 @@ install_actions (MooApp *app,
|
|||
GType type)
|
||||
{
|
||||
MooWindowClass *klass = g_type_class_ref (type);
|
||||
char *about, *_about;
|
||||
char *_about;
|
||||
|
||||
g_return_if_fail (klass != NULL);
|
||||
|
||||
about = g_strdup_printf ("About %s", app->priv->info->full_name);
|
||||
_about = g_strdup_printf ("_About %s", app->priv->info->full_name);
|
||||
_about = g_strdup_printf (Q_("Menu item label|_About %s"), app->priv->info->full_name);
|
||||
|
||||
moo_window_class_new_action (klass, "Preferences",
|
||||
"display-name", "Preferences",
|
||||
"label", "Pre_ferences",
|
||||
"tooltip", "Preferences",
|
||||
"stock-display-name", GTK_STOCK_PREFERENCES,
|
||||
"stock-label", GTK_STOCK_PREFERENCES,
|
||||
"stock-tooltip", GTK_STOCK_PREFERENCES,
|
||||
"stock-id", GTK_STOCK_PREFERENCES,
|
||||
"closure-callback", moo_app_prefs_dialog,
|
||||
NULL);
|
||||
|
||||
moo_window_class_new_action (klass, "About",
|
||||
"display-name", "About",
|
||||
"stock-display-name", GTK_STOCK_ABOUT,
|
||||
"label", _about,
|
||||
"no-accel", TRUE,
|
||||
"tooltip", about,
|
||||
"stock-id", GTK_STOCK_ABOUT,
|
||||
"closure-callback", moo_app_about_dialog,
|
||||
NULL);
|
||||
|
||||
g_type_class_unref (klass);
|
||||
g_free (about);
|
||||
g_free (_about);
|
||||
}
|
||||
|
||||
|
@ -1265,9 +1263,9 @@ install_editor_actions (MooApp *app)
|
|||
g_return_if_fail (klass != NULL);
|
||||
|
||||
moo_window_class_new_action (klass, "Quit",
|
||||
"display-name", "Quit",
|
||||
"label", "_Quit",
|
||||
"tooltip", "Quit",
|
||||
"stock-display-name", GTK_STOCK_QUIT,
|
||||
"stock-label", GTK_STOCK_QUIT,
|
||||
"stock-tooltip", GTK_STOCK_QUIT,
|
||||
"stock-id", GTK_STOCK_QUIT,
|
||||
"accel", "<ctrl>Q",
|
||||
"closure-callback", moo_app_quit,
|
||||
|
|
|
@ -386,9 +386,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Save",
|
||||
"display-name", "Save",
|
||||
"label", "_Save",
|
||||
"tooltip", "Save document",
|
||||
"stock-display-name", GTK_STOCK_SAVE,
|
||||
"stock-label", GTK_STOCK_SAVE,
|
||||
"stock-tooltip", GTK_STOCK_SAVE,
|
||||
"stock-id", GTK_STOCK_SAVE,
|
||||
"accel", "<ctrl>S",
|
||||
"closure-callback", action_save,
|
||||
|
@ -396,7 +396,7 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "SaveAs",
|
||||
"display-name", "Save As",
|
||||
"stock-display-name", GTK_STOCK_SAVE_AS,
|
||||
"label", "Save _As...",
|
||||
"tooltip", "Save as...",
|
||||
"stock-id", GTK_STOCK_SAVE_AS,
|
||||
|
@ -406,8 +406,8 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Close",
|
||||
"display-name", "Close",
|
||||
"label", "_Close",
|
||||
"stock-display-name", GTK_STOCK_CLOSE,
|
||||
"stock-label", GTK_STOCK_CLOSE,
|
||||
"tooltip", "Close document",
|
||||
"stock-id", GTK_STOCK_CLOSE,
|
||||
"accel", "<ctrl>W",
|
||||
|
@ -425,9 +425,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Undo",
|
||||
"display-name", "Undo",
|
||||
"label", "_Undo",
|
||||
"tooltip", "Undo",
|
||||
"stock-display-name", GTK_STOCK_UNDO,
|
||||
"stock-label", GTK_STOCK_UNDO,
|
||||
"stock-tooltip", GTK_STOCK_UNDO,
|
||||
"stock-id", GTK_STOCK_UNDO,
|
||||
"accel", "<ctrl>Z",
|
||||
"closure-signal", "undo",
|
||||
|
@ -436,9 +436,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Redo",
|
||||
"display-name", "Redo",
|
||||
"label", "_Redo",
|
||||
"tooltip", "Redo",
|
||||
"stock-display-name", GTK_STOCK_REDO,
|
||||
"stock-label", GTK_STOCK_REDO,
|
||||
"stock-tooltip", GTK_STOCK_REDO,
|
||||
"stock-id", GTK_STOCK_REDO,
|
||||
"accel", "<shift><ctrl>Z",
|
||||
"closure-signal", "redo",
|
||||
|
@ -447,9 +447,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Cut",
|
||||
"display-name", "Cut",
|
||||
"label", "Cu_t",
|
||||
"tooltip", "Cut",
|
||||
"stock-display-name", GTK_STOCK_CUT,
|
||||
"stock-label", GTK_STOCK_CUT,
|
||||
"stock-tooltip", GTK_STOCK_CUT,
|
||||
"stock-id", GTK_STOCK_CUT,
|
||||
"accel", "<ctrl>X",
|
||||
"closure-signal", "cut-clipboard",
|
||||
|
@ -458,9 +458,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Copy",
|
||||
"display-name", "Copy",
|
||||
"label", "_Copy",
|
||||
"tooltip", "Copy",
|
||||
"stock-display-name", GTK_STOCK_COPY,
|
||||
"stock-label", GTK_STOCK_COPY,
|
||||
"stock-tooltip", GTK_STOCK_COPY,
|
||||
"stock-id", GTK_STOCK_COPY,
|
||||
"accel", "<ctrl>C",
|
||||
"closure-signal", "copy-clipboard",
|
||||
|
@ -469,9 +469,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Paste",
|
||||
"display-name", "Paste",
|
||||
"label", "_Paste",
|
||||
"tooltip", "Paste",
|
||||
"stock-display-name", GTK_STOCK_PASTE,
|
||||
"stock-label", GTK_STOCK_PASTE,
|
||||
"stock-tooltip", GTK_STOCK_PASTE,
|
||||
"stock-id", GTK_STOCK_PASTE,
|
||||
"accel", "<ctrl>V",
|
||||
"closure-signal", "paste-clipboard",
|
||||
|
@ -480,9 +480,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Delete",
|
||||
"display-name", "Delete",
|
||||
"label", "_Delete",
|
||||
"tooltip", "Delete",
|
||||
"stock-display-name", GTK_STOCK_DELETE,
|
||||
"stock-label", GTK_STOCK_DELETE,
|
||||
"stock-tooltip", GTK_STOCK_DELETE,
|
||||
"stock-id", GTK_STOCK_DELETE,
|
||||
"closure-signal", "delete-selection",
|
||||
"closure-proxy-func", moo_edit_window_get_active_doc,
|
||||
|
@ -520,9 +520,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Find",
|
||||
"display-name", "Find",
|
||||
"label", "_Find",
|
||||
"tooltip", "Find",
|
||||
"stock-display-name", GTK_STOCK_FIND,
|
||||
"stock-label", GTK_STOCK_FIND,
|
||||
"stock-tooltip", GTK_STOCK_FIND,
|
||||
"stock-id", GTK_STOCK_FIND,
|
||||
"accel", "<ctrl>F",
|
||||
"closure-signal", "find-interactive",
|
||||
|
@ -553,9 +553,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Replace",
|
||||
"display-name", "Replace",
|
||||
"label", "_Replace",
|
||||
"tooltip", "Replace",
|
||||
"stock-display-name", GTK_STOCK_FIND_AND_REPLACE,
|
||||
"stock-label", GTK_STOCK_FIND_AND_REPLACE,
|
||||
"stock-tooltip", GTK_STOCK_FIND_AND_REPLACE,
|
||||
"stock-id", GTK_STOCK_FIND_AND_REPLACE,
|
||||
"accel", "<ctrl>R",
|
||||
"closure-signal", "replace-interactive",
|
||||
|
@ -618,9 +618,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, STOP_ACTION_ID,
|
||||
"display-name", "Stop",
|
||||
"label", "Stop",
|
||||
"tooltip", "Stop",
|
||||
"stock-display-name", GTK_STOCK_STOP,
|
||||
"stock-label", GTK_STOCK_STOP,
|
||||
"stock-tooltip", GTK_STOCK_STOP,
|
||||
"stock-id", GTK_STOCK_STOP,
|
||||
"accel", "Escape",
|
||||
"closure-callback", action_abort_jobs,
|
||||
|
@ -706,9 +706,10 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Indent",
|
||||
"display-name", "Indent",
|
||||
"label", "Indent",
|
||||
"tooltip", "Indent",
|
||||
"stock-display-name", GTK_STOCK_INDENT,
|
||||
"stock-label", GTK_STOCK_INDENT,
|
||||
"stock-tooltip", GTK_STOCK_INDENT,
|
||||
"stock-id", GTK_STOCK_INDENT,
|
||||
"accel", "<ctrl>i",
|
||||
"closure-callback", moo_text_view_indent,
|
||||
"closure-proxy-func", moo_edit_window_get_active_doc,
|
||||
|
@ -716,9 +717,10 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Unindent",
|
||||
"display-name", "Unindent",
|
||||
"label", "Unindent",
|
||||
"tooltip", "Unindent",
|
||||
"stock-display-name", GTK_STOCK_UNINDENT,
|
||||
"stock-label", GTK_STOCK_UNINDENT,
|
||||
"stock-tooltip", GTK_STOCK_UNINDENT,
|
||||
"stock-id", GTK_STOCK_UNINDENT,
|
||||
"accel", "<shift><ctrl>i",
|
||||
"closure-callback", moo_text_view_unindent,
|
||||
"closure-proxy-func", moo_edit_window_get_active_doc,
|
||||
|
@ -726,7 +728,6 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "NoDocuments",
|
||||
"display-name", "No Documents",
|
||||
"label", "No Documents",
|
||||
"no-accel", TRUE,
|
||||
NULL);
|
||||
|
@ -741,9 +742,9 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Print",
|
||||
"display-name", "Print",
|
||||
"label", "Print",
|
||||
"tooltip", "Print",
|
||||
"stock-display-name", GTK_STOCK_PRINT,
|
||||
"stock-label", GTK_STOCK_PRINT,
|
||||
"stock-tooltip", GTK_STOCK_PRINT,
|
||||
"accel", "<ctrl>P",
|
||||
"stock-id", GTK_STOCK_PRINT,
|
||||
"closure-callback", action_print,
|
||||
|
|
|
@ -52,9 +52,9 @@ static void moo_term_window_class_init (MooTermWindowClass *klass)
|
|||
moo_window_class_set_id (window_class, "Terminal", "Terminal");
|
||||
|
||||
moo_window_class_new_action (window_class, "Copy",
|
||||
"display-name", "Copy",
|
||||
"label", "_Copy",
|
||||
"tooltip", "Copy",
|
||||
"stock-display-name", GTK_STOCK_COPY,
|
||||
"stock-label", GTK_STOCK_COPY,
|
||||
"stock-tooltip", GTK_STOCK_COPY,
|
||||
"stock-id", GTK_STOCK_COPY,
|
||||
"accel", "<alt>C",
|
||||
"closure-callback", copy_clipboard,
|
||||
|
@ -62,9 +62,9 @@ static void moo_term_window_class_init (MooTermWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Paste",
|
||||
"display-name", "Paste",
|
||||
"label", "_Paste",
|
||||
"tooltip", "Paste",
|
||||
"stock-display-name", GTK_STOCK_PASTE,
|
||||
"stock-label", GTK_STOCK_PASTE,
|
||||
"stock-tooltip", GTK_STOCK_PASTE,
|
||||
"stock-id", GTK_STOCK_PASTE,
|
||||
"accel", "<alt>V",
|
||||
"closure-callback", paste_clipboard,
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "mooutils/mooaction.h"
|
||||
#include "mooutils/mooclosure.h"
|
||||
#include "mooutils/mooutils-gobject.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
#include <gtk/gtktoggleaction.h>
|
||||
#include <gobject/gvaluecollector.h>
|
||||
#include <string.h>
|
||||
|
@ -25,6 +26,9 @@ G_DEFINE_TYPE(MooActionFactory, moo_action_factory, G_TYPE_OBJECT)
|
|||
|
||||
enum {
|
||||
PROP_DISPLAY_NAME,
|
||||
PROP_STOCK_LABEL,
|
||||
PROP_STOCK_DISPLAY_NAME,
|
||||
PROP_STOCK_TOOLTIP,
|
||||
PROP_ACCEL,
|
||||
PROP_NO_ACCEL,
|
||||
PROP_FORCE_ACCEL_LABEL,
|
||||
|
@ -79,6 +83,10 @@ action_init_props (void)
|
|||
return;
|
||||
|
||||
pspecs[PROP_DISPLAY_NAME] = g_param_spec_string ("display-name", "display-name", "display-name", NULL, G_PARAM_READWRITE);
|
||||
pspecs[PROP_STOCK_LABEL] = g_param_spec_string ("stock-label", "stock-label", "stock-label", NULL, G_PARAM_READWRITE);
|
||||
pspecs[PROP_STOCK_DISPLAY_NAME] = g_param_spec_string ("stock-display-name", "stock-display-name", "stock-display-name", NULL, G_PARAM_READWRITE);
|
||||
pspecs[PROP_STOCK_TOOLTIP] = g_param_spec_string ("stock-tooltip", "stock-tooltip", "stock-tooltip", NULL, G_PARAM_READWRITE);
|
||||
|
||||
pspecs[PROP_ACCEL] = g_param_spec_string ("accel", "accel", "accel", NULL, G_PARAM_READWRITE);
|
||||
pspecs[PROP_NO_ACCEL] = g_param_spec_boolean ("no-accel", "no-accel", "no-accel", FALSE, G_PARAM_READWRITE);
|
||||
pspecs[PROP_FORCE_ACCEL_LABEL] = g_param_spec_boolean ("force-accel-label", "force-accel-label", "force-accel-label", FALSE, G_PARAM_READWRITE);
|
||||
|
@ -358,6 +366,12 @@ moo_action_set_fake_properties (gpointer action,
|
|||
_moo_action_set_dead (action, g_value_get_boolean (value));
|
||||
else if (!strcmp (name, "has-submenu"))
|
||||
_moo_action_set_has_submenu (action, g_value_get_boolean (value));
|
||||
else if (!strcmp (name, "stock-label"))
|
||||
g_object_set (action, "label", moo_stock_label (g_value_get_string (value)), NULL);
|
||||
else if (!strcmp (name, "stock-display-name"))
|
||||
moo_action_set_display_name (action, moo_stock_name (g_value_get_string (value)));
|
||||
else if (!strcmp (name, "stock-tooltip"))
|
||||
g_object_set (action, "tooltip", moo_stock_name (g_value_get_string (value)), NULL);
|
||||
else if (!strcmp (name, "closure"))
|
||||
closure = g_value_get_boxed (value);
|
||||
else if (!strcmp (name, "closure-object"))
|
||||
|
|
|
@ -1558,3 +1558,55 @@ _moo_enable_win32_error_message (void)
|
|||
SetErrorMode (saved_win32_error_mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
moo_stock_label (const char *stock_id)
|
||||
{
|
||||
GtkStockItem item;
|
||||
|
||||
g_return_val_if_fail (stock_id != NULL, NULL);
|
||||
|
||||
if (!gtk_stock_lookup (stock_id, &item))
|
||||
{
|
||||
g_warning ("could not find stock item '%s'", stock_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item.label;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
moo_stock_name (const char *stock_id)
|
||||
{
|
||||
const char *label;
|
||||
static GString *string;
|
||||
char *p;
|
||||
|
||||
g_return_val_if_fail (stock_id != NULL, NULL);
|
||||
|
||||
label = moo_stock_label (stock_id);
|
||||
g_return_val_if_fail (label != NULL, NULL);
|
||||
|
||||
if (!string)
|
||||
string = g_string_new (NULL);
|
||||
else
|
||||
g_string_truncate (string, 0);
|
||||
|
||||
p = strchr (label, '_');
|
||||
|
||||
if (!p)
|
||||
{
|
||||
g_string_append (string, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p > label)
|
||||
g_string_append_len (string, label, p - label);
|
||||
|
||||
g_string_append (string, p + 1);
|
||||
}
|
||||
|
||||
return string->str;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ GtkWindow *moo_get_toplevel_window (void);
|
|||
gboolean moo_window_set_icon_from_stock (GtkWindow *window,
|
||||
const char *stock_id);
|
||||
|
||||
const char *moo_stock_label (const char *stock_id);
|
||||
const char *moo_stock_name (const char *stock_id);
|
||||
|
||||
void moo_log_window_show (void);
|
||||
void moo_log_window_hide (void);
|
||||
|
|
|
@ -25,5 +25,7 @@ moo/mooutils/eggregex.c
|
|||
moo/mooutils/glade/accelprefs.glade
|
||||
moo/mooutils/glade/moologwindow.glade
|
||||
moo/mooutils/moofontsel.c
|
||||
moo/mooutils/moostock.c
|
||||
moo/mooapp/mooappabout.c
|
||||
moo/mooapp/mooapp.c
|
||||
tests/medit-ui.xml
|
||||
|
|
Loading…
Reference in New Issue