1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 08:43:27 +00:00

(gtk) #611: don't hide in the systray without letting the user know

This commit is contained in:
Charles Kerr 2008-02-03 01:43:47 +00:00
parent c09df07801
commit 21f91ae5be
3 changed files with 28 additions and 27 deletions

View file

@ -101,7 +101,7 @@ static GtkActionEntry entries[] =
{ "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 },
{ "add-torrent", GTK_STOCK_OPEN,
{ "open-torrent", GTK_STOCK_OPEN,
NULL, NULL, N_("Open Torrent"), G_CALLBACK(action_cb) },
{ "start-torrent", GTK_STOCK_MEDIA_PLAY,
N_("_Start"), "<control>S", NULL, G_CALLBACK(action_cb) },

View file

@ -108,6 +108,7 @@ struct cbdata
GList * errqueue;
GHashTable * tor2details;
GHashTable * details2tor;
gboolean minimized;
};
#define CBDATA_PTR "callback-data-pointer"
@ -333,6 +334,7 @@ appsetup( TrWindow * wind, GList * args,
cbdata->timer = 0;
cbdata->closing = FALSE;
cbdata->errqueue = NULL;
cbdata->minimized = minimized;
actions_set_core( cbdata->core );
@ -374,17 +376,35 @@ appsetup( TrWindow * wind, GList * args,
updatemodel( cbdata );
/* show the window */
if( !minimized )
if( minimized )
gtk_window_iconify( wind );
gtk_widget_show( GTK_WIDGET( wind ) );
}
static void
setMainWindowMinimized( struct cbdata * data, gboolean minimized )
{
GtkWindow * window = GTK_WINDOW( data->wind );
if(( data->minimized = minimized ))
gtk_window_iconify( window );
else
gtk_window_deiconify( window );
}
static void
toggleMainWindow( struct cbdata * data )
{
setMainWindowMinimized( data, !data->minimized );
}
static gboolean
winclose( GtkWidget * w UNUSED, GdkEvent * event UNUSED, gpointer gdata )
{
struct cbdata * cbdata = gdata;
if( cbdata->icon != NULL )
gtk_widget_hide( GTK_WIDGET( cbdata->wind ) );
setMainWindowMinimized( cbdata, TRUE );
else
askquit( cbdata->core, cbdata->wind, wannaquit, cbdata );
@ -914,32 +934,13 @@ msgwinclosed()
return FALSE;
}
static void
toggleMainWindow( struct cbdata * data )
{
static int x=0, y=0;
GtkWidget * w = GTK_WIDGET( data->wind );
GtkWindow * window = GTK_WINDOW( w );
if( GTK_WIDGET_VISIBLE( w ) )
{
gtk_window_get_position( window, &x, &y );
gtk_widget_hide( w );
}
else
{
gtk_window_move( window, x, y );
gtk_window_present( window );
}
}
void
doAction ( const char * action_name, gpointer user_data )
{
struct cbdata * data = user_data;
gboolean changed = FALSE;
if (!strcmp (action_name, "add-torrent"))
if (!strcmp (action_name, "open-torrent"))
{
makeaddwind( data->wind, data->core );
}

View file

@ -2,7 +2,7 @@ const char * fallback_ui_file =
"<ui>\n"
" <menubar name='main-window-menu'>\n"
" <menu action='torrent-menu'>\n"
" <menuitem action='add-torrent'/>\n"
" <menuitem action='open-torrent'/>\n"
" <menuitem action='start-torrent'/>\n"
" <menuitem action='update-tracker'/>\n"
" <menuitem action='pause-torrent'/>\n"
@ -43,7 +43,7 @@ const char * fallback_ui_file =
" </menubar>\n"
"\n"
" <toolbar name='main-window-toolbar'>\n"
" <toolitem action='add-torrent'/>\n"
" <toolitem action='open-torrent'/>\n"
" <toolitem action='start-torrent'/>\n"
" <toolitem action='pause-torrent'/>\n"
" <toolitem action='remove-torrent'/>\n"
@ -63,7 +63,7 @@ const char * fallback_ui_file =
" </popup>\n"
"\n"
" <popup name='icon-popup'>\n"
" <menuitem action='add-torrent'/>\n"
" <menuitem action='open-torrent'/>\n"
" <separator/>\n"
" <menuitem action='toggle-main-window'/>\n"
" <menuitem action='toggle-message-log'/>\n"