From 21f91ae5bec23d17e5fb0c07178b4240a990c383 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 3 Feb 2008 01:43:47 +0000 Subject: [PATCH] (gtk) #611: don't hide in the systray without letting the user know --- gtk/actions.c | 2 +- gtk/main.c | 47 ++++++++++++++++++++++++----------------------- gtk/ui.h | 6 +++--- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/gtk/actions.c b/gtk/actions.c index 10c98c3b2..755c5e476 100644 --- a/gtk/actions.c +++ b/gtk/actions.c @@ -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"), "S", NULL, G_CALLBACK(action_cb) }, diff --git a/gtk/main.c b/gtk/main.c index 2c9cbf6d2..e95a6ab8e 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -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,8 +376,26 @@ appsetup( TrWindow * wind, GList * args, updatemodel( cbdata ); /* show the window */ - if( !minimized ) - gtk_widget_show( GTK_WIDGET(wind) ); + 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 @@ -384,7 +404,7 @@ 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 ); } diff --git a/gtk/ui.h b/gtk/ui.h index 05954927c..52a7afcea 100644 --- a/gtk/ui.h +++ b/gtk/ui.h @@ -2,7 +2,7 @@ const char * fallback_ui_file = "\n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" @@ -43,7 +43,7 @@ const char * fallback_ui_file = " \n" "\n" " \n" -" \n" +" \n" " \n" " \n" " \n" @@ -63,7 +63,7 @@ const char * fallback_ui_file = " \n" "\n" " \n" -" \n" +" \n" " \n" " \n" " \n"