2007-06-18 03:40:41 +00:00
|
|
|
/*
|
2010-01-04 21:00:47 +00:00
|
|
|
* This file Copyright (C) 2007-2010 Mnemosyne LLC
|
2007-06-18 03:40:41 +00:00
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2007-06-18 03:40:41 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
2008-09-23 19:11:04 +00:00
|
|
|
*
|
2007-08-18 17:19:49 +00:00
|
|
|
* $Id$
|
2007-06-18 03:40:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
2009-11-27 14:55:52 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <gtk/gtk.h>
|
2009-11-27 14:55:52 +00:00
|
|
|
|
2007-07-18 23:04:26 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2009-11-27 14:55:52 +00:00
|
|
|
|
2008-08-11 19:05:02 +00:00
|
|
|
#include "actions.h"
|
2007-12-19 02:46:30 +00:00
|
|
|
#include "conf.h"
|
2008-02-26 19:58:03 +00:00
|
|
|
#include "tr-core.h"
|
|
|
|
#include "tr-prefs.h"
|
2007-10-13 13:51:38 +00:00
|
|
|
#include "lock.h"
|
2009-11-27 14:55:52 +00:00
|
|
|
|
2010-04-29 15:39:29 +00:00
|
|
|
#include "logo-24.h"
|
|
|
|
#include "logo-48.h"
|
2009-11-27 14:55:52 +00:00
|
|
|
#include "ratio-icon.h"
|
2009-04-15 04:28:04 +00:00
|
|
|
#include "options-icon.h"
|
2009-03-28 16:47:01 +00:00
|
|
|
#include "turtles.h"
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-10-23 02:37:21 +00:00
|
|
|
#define UNUSED G_GNUC_UNUSED
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
static TrCore * myCore = NULL;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-08-11 19:05:02 +00:00
|
|
|
static GtkActionGroup * myGroup = NULL;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-12-19 18:42:33 +00:00
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
action_cb( GtkAction * a,
|
|
|
|
gpointer user_data )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
doAction ( gtk_action_get_name( a ), user_data );
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
#if !GTK_CHECK_VERSION( 2, 8, 0 )
|
|
|
|
#define GTK_STOCK_INFO GTK_STOCK_PROPERTIES
|
2007-06-18 03:40:41 +00:00
|
|
|
#endif
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
#if !GTK_CHECK_VERSION( 2, 10, 0 )
|
|
|
|
#define GTK_STOCK_SELECT_ALL NULL
|
2008-03-19 17:14:47 +00:00
|
|
|
#endif
|
|
|
|
|
2007-12-19 02:46:30 +00:00
|
|
|
static GtkRadioActionEntry sort_radio_entries[] =
|
|
|
|
{
|
2009-07-03 20:10:05 +00:00
|
|
|
{ "sort-by-activity", NULL, N_( "Sort by _Activity" ), NULL, NULL, 0 },
|
|
|
|
{ "sort-by-name", NULL, N_( "Sort by _Name" ), NULL, NULL, 1 },
|
|
|
|
{ "sort-by-progress", NULL, N_( "Sort by _Progress" ), NULL, NULL, 2 },
|
|
|
|
{ "sort-by-ratio", NULL, N_( "Sort by Rati_o" ), NULL, NULL, 3 },
|
|
|
|
{ "sort-by-state", NULL, N_( "Sort by Stat_e" ), NULL, NULL, 4 },
|
|
|
|
{ "sort-by-tracker", NULL, N_( "Sort by T_racker" ), NULL, NULL, 5 },
|
|
|
|
{ "sort-by-age", NULL, N_( "Sort by A_ge" ), NULL, NULL, 6 },
|
|
|
|
{ "sort-by-time-left", NULL, N_( "Sort by Time _Left" ), NULL, NULL, 7 },
|
|
|
|
{ "sort-by-size", NULL, N_( "Sort by Si_ze" ), NULL, NULL, 8 }
|
2007-12-19 02:46:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2007-12-19 18:42:33 +00:00
|
|
|
sort_changed_cb( GtkAction * action UNUSED,
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkRadioAction * current,
|
|
|
|
gpointer user_data UNUSED )
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2007-12-19 18:42:33 +00:00
|
|
|
const char * key = PREF_KEY_SORT_MODE;
|
2008-09-23 19:11:04 +00:00
|
|
|
const int i = gtk_radio_action_get_current_value( current );
|
2007-12-19 18:42:33 +00:00
|
|
|
const char * val = sort_radio_entries[i].name;
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-12-19 18:42:33 +00:00
|
|
|
tr_core_set_pref( myCore, key, val );
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
static GtkToggleActionEntry show_toggle_entries[] =
|
2007-09-21 16:29:09 +00:00
|
|
|
{
|
2010-01-14 07:03:29 +00:00
|
|
|
{ "toggle-main-window", NULL, N_( "_Show Transmission" ), NULL, NULL, G_CALLBACK( action_cb ), TRUE },
|
2009-03-28 16:47:01 +00:00
|
|
|
{ "toggle-message-log", NULL, N_( "Message _Log" ), NULL, NULL, G_CALLBACK( action_cb ), FALSE }
|
2007-09-21 16:29:09 +00:00
|
|
|
};
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-12-19 18:42:33 +00:00
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
toggle_pref_cb( GtkToggleAction * action,
|
|
|
|
gpointer user_data UNUSED )
|
2007-12-19 18:42:33 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const char * key = gtk_action_get_name( GTK_ACTION( action ) );
|
2007-12-19 18:42:33 +00:00
|
|
|
const gboolean val = gtk_toggle_action_get_active( action );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-12-19 18:42:33 +00:00
|
|
|
tr_core_set_pref_bool( myCore, key, val );
|
|
|
|
}
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
static GtkToggleActionEntry pref_toggle_entries[] =
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2010-01-14 07:03:29 +00:00
|
|
|
{ "alt-speed-enabled", NULL, N_( "Enable Temporary Speed _Limits" ), NULL, NULL, G_CALLBACK( toggle_pref_cb ), FALSE },
|
2010-03-15 14:42:43 +00:00
|
|
|
{ "compact-view", NULL, N_( "_Compact View" ), "<alt>C", NULL, G_CALLBACK( toggle_pref_cb ), FALSE },
|
2009-07-03 20:10:05 +00:00
|
|
|
{ "sort-reversed", NULL, N_( "Re_verse Sort Order" ), NULL, NULL, G_CALLBACK( toggle_pref_cb ), FALSE },
|
2009-05-16 19:41:41 +00:00
|
|
|
{ "show-filterbar", NULL, N_( "_Filterbar" ), NULL, NULL, G_CALLBACK( toggle_pref_cb ), FALSE },
|
|
|
|
{ "show-statusbar", NULL, N_( "_Statusbar" ), NULL, NULL, G_CALLBACK( toggle_pref_cb ), FALSE },
|
|
|
|
{ "show-toolbar", NULL, N_( "_Toolbar" ), NULL, NULL, G_CALLBACK( toggle_pref_cb ), FALSE }
|
2007-12-19 02:46:30 +00:00
|
|
|
};
|
|
|
|
|
2009-05-13 15:54:04 +00:00
|
|
|
static GtkActionEntry entries[] =
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
2009-11-29 07:41:13 +00:00
|
|
|
{ "file-menu", NULL, N_( "_File" ), NULL, NULL, NULL },
|
2008-12-03 05:15:17 +00:00
|
|
|
{ "torrent-menu", NULL, N_( "_Torrent" ), NULL, NULL, NULL },
|
|
|
|
{ "view-menu", NULL, N_( "_View" ), NULL, NULL, NULL },
|
|
|
|
{ "sort-menu", NULL, N_( "_Sort Torrents By" ), NULL, NULL, NULL },
|
|
|
|
{ "edit-menu", NULL, N_( "_Edit" ), NULL, NULL, NULL },
|
|
|
|
{ "help-menu", NULL, N_( "_Help" ), NULL, NULL, NULL },
|
2009-11-29 18:23:06 +00:00
|
|
|
{ "copy-magnet-link-to-clipboard", GTK_STOCK_COPY, N_("Copy _Magnet Link to Clipboard" ), "<control>M", NULL, G_CALLBACK( action_cb ) },
|
2009-11-24 16:14:59 +00:00
|
|
|
{ "add-torrent-from-url", GTK_STOCK_ADD, N_("Add _URL..." ), NULL, N_( "Add URL..." ), G_CALLBACK( action_cb ) },
|
2008-12-03 05:15:17 +00:00
|
|
|
{ "add-torrent-toolbar", GTK_STOCK_ADD, NULL, NULL, N_( "Add a torrent" ), G_CALLBACK( action_cb ) },
|
2009-11-24 16:14:59 +00:00
|
|
|
{ "add-torrent-menu", GTK_STOCK_ADD, N_( "_Add File..." ), "<control>D", N_( "Add a torrent" ), G_CALLBACK( action_cb ) },
|
2008-12-03 05:15:17 +00:00
|
|
|
{ "start-torrent", GTK_STOCK_MEDIA_PLAY, N_( "_Start" ), "<control>S", N_( "Start torrent" ), G_CALLBACK( action_cb ) },
|
|
|
|
{ "show-stats", NULL, N_( "_Statistics" ), NULL, NULL, G_CALLBACK( action_cb ) },
|
2009-09-10 17:39:44 +00:00
|
|
|
{ "donate", NULL, N_( "_Donate" ), NULL, NULL, G_CALLBACK( action_cb ) },
|
2009-11-29 18:23:06 +00:00
|
|
|
{ "verify-torrent", NULL, N_( "_Verify Local Data" ), "<control>V", NULL, G_CALLBACK( action_cb ) },
|
2008-12-03 05:15:17 +00:00
|
|
|
{ "pause-torrent", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause" ), "<control>P", N_( "Pause torrent" ), G_CALLBACK( action_cb ) },
|
|
|
|
{ "pause-all-torrents", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause All" ), NULL, N_( "Pause all torrents" ), G_CALLBACK( action_cb ) },
|
2009-02-18 18:40:38 +00:00
|
|
|
{ "start-all-torrents", GTK_STOCK_MEDIA_PLAY, N_( "_Start All" ), NULL, N_( "Start all torrents" ), G_CALLBACK( action_cb ) },
|
2010-08-02 03:07:42 +00:00
|
|
|
{ "relocate-torrent", NULL, N_("Set _Location..." ), NULL, NULL, G_CALLBACK( action_cb ) },
|
2008-12-03 05:15:17 +00:00
|
|
|
{ "remove-torrent", GTK_STOCK_REMOVE, NULL, "Delete", N_( "Remove torrent" ), G_CALLBACK( action_cb ) },
|
|
|
|
{ "delete-torrent", GTK_STOCK_DELETE, N_( "_Delete Files and Remove" ), "<shift>Delete", NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "new-torrent", GTK_STOCK_NEW, N_( "_New..." ), NULL, N_( "Create a torrent" ), G_CALLBACK( action_cb ) },
|
|
|
|
{ "quit", GTK_STOCK_QUIT, N_( "_Quit" ), NULL, NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "select-all", GTK_STOCK_SELECT_ALL, N_( "Select _All" ), "<control>A", NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "deselect-all", NULL, N_( "Dese_lect All" ), "<shift><control>A", NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "edit-preferences", GTK_STOCK_PREFERENCES, NULL, NULL, NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "show-torrent-properties", GTK_STOCK_PROPERTIES, NULL, "<alt>Return", N_( "Torrent properties" ), G_CALLBACK( action_cb ) },
|
|
|
|
{ "open-torrent-folder", GTK_STOCK_OPEN, N_( "_Open Folder" ), NULL, NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "show-about-dialog", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "help", GTK_STOCK_HELP, N_( "_Contents" ), "F1", NULL, G_CALLBACK( action_cb ) },
|
|
|
|
{ "update-tracker", GTK_STOCK_NETWORK, N_( "Ask Tracker for _More Peers" ), NULL, NULL, G_CALLBACK( action_cb ) },
|
2007-06-18 03:40:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const guint8* raw;
|
|
|
|
const char * name;
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
BuiltinIconInfo;
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
static const BuiltinIconInfo my_fallback_icons[] =
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
2010-04-29 15:39:29 +00:00
|
|
|
{ tr_icon_logo_48, WINDOW_ICON },
|
|
|
|
{ tr_icon_logo_24, TRAY_ICON },
|
|
|
|
{ tr_icon_logo_48, NOTIFICATION_ICON },
|
|
|
|
{ tr_icon_lock, "transmission-lock" },
|
|
|
|
{ options_icon, "options" },
|
|
|
|
{ blue_turtle, "alt-speed-on" },
|
|
|
|
{ grey_turtle, "alt-speed-off" },
|
|
|
|
{ ratio_icon, "ratio" }
|
2007-06-18 03:40:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
register_my_icons( void )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int i;
|
|
|
|
const int n = G_N_ELEMENTS( my_fallback_icons );
|
2008-02-07 20:27:17 +00:00
|
|
|
GtkIconFactory * factory = gtk_icon_factory_new( );
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkIconTheme * theme = gtk_icon_theme_get_default( );
|
|
|
|
|
2008-02-07 20:27:17 +00:00
|
|
|
gtk_icon_factory_add_default( factory );
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( i = 0; i < n; ++i )
|
2008-02-07 20:27:17 +00:00
|
|
|
{
|
|
|
|
const char * name = my_fallback_icons[i].name;
|
|
|
|
|
|
|
|
if( !gtk_icon_theme_has_icon( theme, name ) )
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int width;
|
|
|
|
GdkPixbuf * p;
|
2008-02-07 20:27:17 +00:00
|
|
|
GtkIconSet * icon_set;
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
p =
|
|
|
|
gdk_pixbuf_new_from_inline( -1, my_fallback_icons[i].raw,
|
|
|
|
FALSE,
|
|
|
|
NULL );
|
2008-02-07 20:27:17 +00:00
|
|
|
width = gdk_pixbuf_get_width( p );
|
|
|
|
icon_set = gtk_icon_set_new_from_pixbuf( p );
|
|
|
|
gtk_icon_theme_add_builtin_icon( name, width, p );
|
|
|
|
gtk_icon_factory_add( factory, name, icon_set );
|
|
|
|
|
|
|
|
g_object_unref( p );
|
|
|
|
gtk_icon_set_unref( icon_set );
|
|
|
|
}
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
g_object_unref ( G_OBJECT ( factory ) );
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkUIManager * myUIManager = NULL;
|
|
|
|
|
2007-12-19 18:42:33 +00:00
|
|
|
void
|
|
|
|
actions_set_core( TrCore * core )
|
|
|
|
{
|
|
|
|
myCore = core;
|
|
|
|
}
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
actions_init( GtkUIManager * ui_manager,
|
|
|
|
gpointer callback_user_data )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int i, n;
|
|
|
|
int active;
|
|
|
|
const char * match;
|
|
|
|
const int n_entries = G_N_ELEMENTS( entries );
|
|
|
|
GtkActionGroup * action_group;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
myUIManager = ui_manager;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
register_my_icons( );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
action_group = myGroup = gtk_action_group_new( "Actions" );
|
|
|
|
gtk_action_group_set_translation_domain( action_group, NULL );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
match = pref_string_get( PREF_KEY_SORT_MODE );
|
|
|
|
for( i = 0, n = G_N_ELEMENTS( sort_radio_entries ), active = -1;
|
|
|
|
active == -1 && i < n; ++i )
|
|
|
|
if( !strcmp( sort_radio_entries[i].name, match ) )
|
|
|
|
active = i;
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_action_group_add_radio_actions( action_group,
|
|
|
|
sort_radio_entries,
|
|
|
|
G_N_ELEMENTS( sort_radio_entries ),
|
|
|
|
active,
|
|
|
|
G_CALLBACK( sort_changed_cb ),
|
|
|
|
NULL );
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_action_group_add_toggle_actions( action_group,
|
|
|
|
show_toggle_entries,
|
|
|
|
G_N_ELEMENTS( show_toggle_entries ),
|
|
|
|
callback_user_data );
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( i = 0, n = G_N_ELEMENTS( pref_toggle_entries ); i < n; ++i )
|
|
|
|
pref_toggle_entries[i].is_active =
|
|
|
|
pref_flag_get( pref_toggle_entries[i].name );
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_action_group_add_toggle_actions( action_group,
|
|
|
|
pref_toggle_entries,
|
|
|
|
G_N_ELEMENTS( pref_toggle_entries ),
|
|
|
|
callback_user_data );
|
2007-09-21 16:29:09 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_action_group_add_actions( action_group,
|
|
|
|
entries, n_entries,
|
|
|
|
callback_user_data );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_ui_manager_insert_action_group( ui_manager, action_group, 0 );
|
|
|
|
g_object_unref ( G_OBJECT( action_group ) );
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****
|
|
|
|
*****
|
|
|
|
****/
|
|
|
|
|
|
|
|
static GHashTable * key_to_action = NULL;
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
ensure_action_map_loaded( GtkUIManager * uim )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
|
|
|
GList * l;
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
if( key_to_action != NULL )
|
2007-06-18 03:40:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
key_to_action =
|
2008-09-23 19:11:04 +00:00
|
|
|
g_hash_table_new_full( g_str_hash, g_str_equal, g_free, NULL );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
for( l = gtk_ui_manager_get_action_groups( uim ); l != NULL;
|
|
|
|
l = l->next )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
|
|
|
GtkActionGroup * action_group = GTK_ACTION_GROUP( l->data );
|
2008-09-23 19:11:04 +00:00
|
|
|
GList * ait, *actions = gtk_action_group_list_actions(
|
|
|
|
action_group );
|
|
|
|
for( ait = actions; ait != NULL; ait = ait->next )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkAction * action = GTK_ACTION( ait->data );
|
2007-06-18 03:40:41 +00:00
|
|
|
const char * name = gtk_action_get_name( action );
|
2008-09-23 19:11:04 +00:00
|
|
|
g_hash_table_insert( key_to_action, g_strdup( name ), action );
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
g_list_free( actions );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkAction*
|
|
|
|
get_action( const char* name )
|
|
|
|
{
|
|
|
|
ensure_action_map_loaded( myUIManager );
|
|
|
|
return ( GtkAction* ) g_hash_table_lookup( key_to_action, name );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
action_activate( const char * name )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
|
|
|
GtkAction * action = get_action( name );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
g_assert( action != NULL );
|
|
|
|
gtk_action_activate( action );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
action_sensitize( const char * name,
|
|
|
|
gboolean b )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
|
|
|
GtkAction * action = get_action( name );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
g_assert( action != NULL );
|
|
|
|
g_object_set( action, "sensitive", b, NULL );
|
|
|
|
}
|
|
|
|
|
2009-08-16 03:09:06 +00:00
|
|
|
void
|
|
|
|
action_set_important( const char * name, gboolean b )
|
|
|
|
{
|
2009-08-16 03:25:58 +00:00
|
|
|
GtkAction * action = get_action( name );
|
|
|
|
|
|
|
|
g_assert( action != NULL );
|
|
|
|
g_object_set( action, "is-important", b, NULL );
|
2009-08-16 03:09:06 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
action_toggle( const char * name,
|
|
|
|
gboolean b )
|
2007-06-18 03:40:41 +00:00
|
|
|
{
|
|
|
|
GtkAction * action = get_action( name );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION( action ), b );
|
2007-06-18 03:40:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
|
|
|
action_get_widget( const char * path )
|
|
|
|
{
|
|
|
|
return gtk_ui_manager_get_widget( myUIManager, path );
|
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|