diff options
author | jstebbins <[email protected]> | 2011-06-20 15:58:36 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-06-20 15:58:36 +0000 |
commit | 5c75564427bbb893c4444af1d8c7304ce5343dcf (patch) | |
tree | d615017f668919154355ed469f0b6a8205b106a4 /gtk/src/callbacks.c | |
parent | 2625067e6983ff27d139352178662926020d37d3 (diff) |
LinGui: Add status tray icon support for Ubuntu 11.04
Ubuntu disables GtkStatusIcon support in Unity and instead uses a new
API called AppIndicator. So this adds support for appindicator when
it is detected by configure.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4067 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/callbacks.c')
-rw-r--r-- | gtk/src/callbacks.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 7c1bde5ad..4dc685802 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -55,6 +55,10 @@ #include <dbt.h> #endif +#if defined(_USE_APP_IND) +#include <libappindicator/app-indicator.h> +#endif + #include "hb.h" #include "callbacks.h" #include "queuehandler.h" @@ -2745,6 +2749,13 @@ ghb_backend_events(signal_user_data_t *ud) si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_tooltip(si, status_str); #endif +#if defined(_USE_APP_IND) + char * ai_status_str= g_strdup_printf( + "%.2f%%", + 100.0 * status.queue.progress); + app_indicator_set_label( ud->ai, ai_status_str, "99.99%"); + g_free(ai_status_str); +#endif gtk_label_set_text (work_status, status_str); gtk_progress_bar_set_fraction (progress, status.queue.progress); g_free(status_str); @@ -2783,6 +2794,13 @@ ghb_backend_events(signal_user_data_t *ud) si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_tooltip(si, status_str); #endif +#if defined(_USE_APP_IND) + char * ai_status_str= g_strdup_printf( + "%.2f%%", + 100.0 * status.queue.progress); + app_indicator_set_label( ud->ai, ai_status_str, "99.99%"); + g_free(ai_status_str); +#endif gtk_label_set_text (work_status, status_str); gtk_progress_bar_set_fraction (progress, status.queue.progress); g_free(status_str); @@ -2867,6 +2885,9 @@ ghb_backend_events(signal_user_data_t *ud) si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_tooltip(si, "HandBrake"); #endif +#if defined(_USE_APP_IND) + app_indicator_set_label( ud->ai, "", "99.99%"); +#endif } else if (status.queue.state & GHB_STATE_MUXING) { @@ -3613,6 +3634,16 @@ show_status_cb(GtkWidget *widget, signal_user_data_t *ud) si = GTK_STATUS_ICON(GHB_OBJECT (ud->builder, "hb_status")); gtk_status_icon_set_visible(si, ghb_settings_get_boolean(ud->settings, "show_status")); +#if defined(_USE_APP_IND) + if (ghb_settings_get_boolean(ud->settings, "show_status")) + { + app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_ACTIVE ); + } + else + { + app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_PASSIVE ); + } +#endif } G_MODULE_EXPORT void @@ -4850,6 +4881,27 @@ status_activate_cb(GtkStatusIcon *si, signal_user_data_t *ud) } } +G_MODULE_EXPORT void +show_hide_toggle_cb(GtkWidget *xwidget, signal_user_data_t *ud) +{ + GtkWindow *window; + GdkWindowState state; + + window = GTK_WINDOW(GHB_WIDGET(ud->builder, "hb_window")); + state = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(window))); + if ((state & GDK_WINDOW_STATE_ICONIFIED) || + (ud->hb_visibility != GDK_VISIBILITY_UNOBSCURED)) + { + gtk_window_present(window); + gtk_window_set_skip_taskbar_hint(window, FALSE); + } + else + { + gtk_window_set_skip_taskbar_hint(window, TRUE); + gtk_window_iconify(window); + } +} + #if !defined(_WIN32) G_MODULE_EXPORT void notify_closed_cb(NotifyNotification *notification, signal_user_data_t *ud) |