Changeset 4932
- Timestamp:
- Feb 7, 2008, 1:10:34 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/main.c
r4912 r4932 35 35 #include <glib/gi18n.h> 36 36 #include <glib/gstdio.h> 37 38 #include <gdk/gdk.h> 39 #ifdef GDK_WINDOWING_X11 40 #include <X11/Xatom.h> 41 #include <gdk/gdkx.h> 42 #endif 37 43 38 44 #include "actions.h" … … 99 105 struct cbdata 100 106 { 107 guint idle_hide_mainwindow_tag; 101 108 GtkWindow * wind; 102 109 TrCore * core; 103 GtkWidget *icon;110 gpointer icon; 104 111 GtkWidget * msgwin; 105 112 GtkWidget * prefs; … … 377 384 378 385 /* show the window */ 379 if( minimized ) 386 if( minimized ) { 380 387 gtk_window_iconify( wind ); 388 gtk_window_set_skip_taskbar_hint( cbdata->wind, cbdata->icon != NULL ); 389 } 381 390 gtk_widget_show( GTK_WIDGET( wind ) ); 382 391 } 383 392 384 static void 385 setMainWindowMinimized( struct cbdata * data, gboolean minimized ) 386 { 387 GtkWindow * window = GTK_WINDOW( data->wind ); 388 389 if(( data->minimized = minimized )) 390 gtk_window_iconify( window ); 393 394 /** 395 * hideMainWindow, and the timeout hack in toggleMainWindow, 396 * are loosely cribbed from Colin Walters' tr-shell.c in Rhythmbox 397 */ 398 static gboolean 399 idle_hide_mainwindow( gpointer window ) 400 { 401 gtk_widget_hide( window ); 402 return FALSE; 403 } 404 static void 405 hideMainWindow( struct cbdata * cbdata ) 406 { 407 #if defined(STATUS_ICON_SUPPORTED) && defined(GDK_WINDOWING_X11) 408 GdkRectangle bounds; 409 gulong data[4]; 410 Display *dpy; 411 GdkWindow *gdk_window; 412 413 gtk_status_icon_get_geometry( GTK_STATUS_ICON( cbdata->icon ), NULL, &bounds, NULL ); 414 gdk_window = GTK_WIDGET (cbdata->wind)->window; 415 dpy = gdk_x11_drawable_get_xdisplay (gdk_window); 416 417 data[0] = bounds.x; 418 data[1] = bounds.y; 419 data[2] = bounds.width; 420 data[3] = bounds.height; 421 422 XChangeProperty (dpy, 423 GDK_WINDOW_XID (gdk_window), 424 gdk_x11_get_xatom_by_name_for_display (gdk_drawable_get_display (gdk_window), 425 "_NET_WM_ICON_GEOMETRY"), 426 XA_CARDINAL, 32, PropModeReplace, 427 (guchar*)&data, 4); 428 429 gtk_window_set_skip_taskbar_hint( cbdata->wind, TRUE ); 430 #endif 431 gtk_window_iconify( cbdata->wind ); 432 } 433 434 static void 435 clearTag( guint * tag ) 436 { 437 if( *tag ) 438 g_source_remove( *tag ); 439 *tag = 0; 440 } 441 442 static void 443 toggleMainWindow( struct cbdata * cbdata ) 444 { 445 GtkWindow * window = GTK_WINDOW( cbdata->wind ); 446 const int hide = cbdata->minimized = !cbdata->minimized; 447 448 if( hide ) 449 { 450 clearTag( &cbdata->idle_hide_mainwindow_tag ); 451 hideMainWindow( cbdata ); 452 cbdata->idle_hide_mainwindow_tag = g_timeout_add( 250, idle_hide_mainwindow, window ); 453 } 391 454 else 455 { 456 gtk_window_set_skip_taskbar_hint( window, FALSE ); 457 gtk_widget_show( GTK_WIDGET( window ) ); 392 458 gtk_window_deiconify( window ); 393 } 394 395 static void 396 toggleMainWindow( struct cbdata * data ) 397 { 398 setMainWindowMinimized( data, !data->minimized ); 459 gtk_window_present_with_time( window, gtk_get_current_event_time( ) ); 460 } 399 461 } 400 462 … … 405 467 406 468 if( cbdata->icon != NULL ) 407 setMainWindowMinimized( cbdata, TRUE);469 action_activate ("toggle-main-window"); 408 470 else 409 471 askquit( cbdata->core, cbdata->wind, wannaquit, cbdata );
Note: See TracChangeset
for help on using the changeset viewer.