Mercurial > audlegacy-plugins
comparison src/statusicon/si_ui.c @ 2223:6b34a88b1408
statusicon: more elegant solution, workaround removed
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Fri, 07 Dec 2007 22:51:53 +0300 |
parents | 3e2ff1758809 |
children | e780330f6189 |
comparison
equal
deleted
inserted
replaced
2222:3e2ff1758809 | 2223:6b34a88b1408 |
---|---|
32 #include <glib.h> | 32 #include <glib.h> |
33 #include <gdk/gdk.h> | 33 #include <gdk/gdk.h> |
34 #include <gdk/gdkx.h> | 34 #include <gdk/gdkx.h> |
35 #include <gtk/gtk.h> | 35 #include <gtk/gtk.h> |
36 | 36 |
37 #ifndef MAX | |
38 # define MAX(a,b) ((a) > (b) ? (a) : (b)) | |
39 #endif | |
40 | |
37 static void si_ui_statusicon_popup_timer_start ( GtkWidget * ); | 41 static void si_ui_statusicon_popup_timer_start ( GtkWidget * ); |
38 static void si_ui_statusicon_popup_timer_stop ( GtkWidget * ); | 42 static void si_ui_statusicon_popup_timer_stop ( GtkWidget * ); |
39 static void si_ui_statusicon_smallmenu_show ( gint x, gint y, guint button, guint32 time , gpointer ); | 43 static void si_ui_statusicon_smallmenu_show ( gint x, gint y, guint button, guint32 time , gpointer ); |
40 static void si_ui_statusicon_smallmenu_recreate ( GtkWidget * ); | 44 static void si_ui_statusicon_smallmenu_recreate ( GtkWidget * ); |
41 | 45 |
333 static gchar *wmname = NULL; | 337 static gchar *wmname = NULL; |
334 | 338 |
335 AUDDBG("WM reported proposed icon size: %d\n", size); | 339 AUDDBG("WM reported proposed icon size: %d\n", size); |
336 | 340 |
337 /* sometimes, KDE won't give the correct size-allocation; workaround this */ | 341 /* sometimes, KDE won't give the correct size-allocation; workaround this */ |
338 /* Xfwm4 sometimes too... --eugene */ | |
339 if ( wmname == NULL ) | 342 if ( wmname == NULL ) |
340 { | 343 { |
341 GdkScreen *screen = gdk_screen_get_default(); | 344 GdkScreen *screen = gdk_screen_get_default(); |
342 if ( screen != NULL ) | 345 if ( screen != NULL ) |
343 wmname = (gchar*)gdk_x11_screen_get_window_manager_name( screen ); | 346 wmname = (gchar*)gdk_x11_screen_get_window_manager_name( screen ); |
344 AUDDBG("WM name: %s\n", wmname); | 347 AUDDBG("WM name: %s\n", wmname); |
345 } | 348 } |
346 if ( ( size <= 1 || size > 22 ) && ( wmname != NULL ) && ( !strcmp("KWin",wmname) || !strcmp("Xfwm4",wmname) ) ) | 349 if ( ( size <= 1 || size > 22 ) && ( wmname != NULL ) && !strcmp("KWin",wmname) ) |
347 size = 22; | 350 size = 22; |
348 | 351 |
349 si_pixbuf = gdk_pixbuf_new_from_xpm_data( (const char**)si_xpm ); | 352 si_pixbuf = gdk_pixbuf_new_from_xpm_data( (const char**)si_xpm ); |
350 si_scaled_pixbuf = gdk_pixbuf_scale_simple( si_pixbuf , size , size , GDK_INTERP_BILINEAR ); | 353 si_scaled_pixbuf = gdk_pixbuf_scale_simple( si_pixbuf , size , size , GDK_INTERP_BILINEAR ); |
351 gtk_image_set_from_pixbuf( GTK_IMAGE(image) , si_scaled_pixbuf ); | 354 gtk_image_set_from_pixbuf( GTK_IMAGE(image) , si_scaled_pixbuf ); |
357 | 360 |
358 | 361 |
359 static void | 362 static void |
360 si_ui_statusicon_cb_image_sizalloc ( GtkWidget * image , GtkAllocation * allocation , gpointer si_applet ) | 363 si_ui_statusicon_cb_image_sizalloc ( GtkWidget * image , GtkAllocation * allocation , gpointer si_applet ) |
361 { | 364 { |
362 GtkOrientation orientation; | 365 /*GtkOrientation orientation;*/ |
363 static gint prev_size = 0; | 366 static gint prev_size = 0; |
364 gint size = 0; | 367 gint size = 0; |
365 | 368 |
366 orientation = _aud_gtk_tray_icon_get_orientation( AUD_GTK_TRAY_ICON(si_applet) ); | 369 /*orientation = _aud_gtk_tray_icon_get_orientation( AUD_GTK_TRAY_ICON(si_applet) ); |
367 if ( orientation == GTK_ORIENTATION_HORIZONTAL ) | 370 if ( orientation == GTK_ORIENTATION_HORIZONTAL ) |
368 size = allocation->height; | 371 size = allocation->height; |
369 else | 372 else |
370 size = allocation->width; | 373 size = allocation->width;*/ |
374 | |
375 size = MAX(allocation->height, allocation->width); /* some WMs doesn't report orientation correctly --asphyx */ | |
371 | 376 |
372 if ( prev_size != size ) | 377 if ( prev_size != size ) |
373 { | 378 { |
374 prev_size = size; | 379 prev_size = size; |
375 g_object_set_data( G_OBJECT(image) , "size" , GINT_TO_POINTER(size) ); | 380 g_object_set_data( G_OBJECT(image) , "size" , GINT_TO_POINTER(size) ); |