From: jstebbins Date: Mon, 20 Jun 2011 15:58:36 +0000 (+0000) Subject: LinGui: Add status tray icon support for Ubuntu 11.04 X-Git-Tag: 0.9.6~401 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c75564427bbb893c4444af1d8c7304ce5343dcf;p=handbrake 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 --- diff --git a/gtk/configure.ac b/gtk/configure.ac index e811fe2b7..d2db300c4 100644 --- a/gtk/configure.ac +++ b/gtk/configure.ac @@ -128,6 +128,12 @@ fi AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"]) +PKG_CHECK_MODULES(libappindicator, appindicator-0.1, have_appind=yes, have_appind=no) +if test "x$have_appind" = "xyes" ; then + GHB_PACKAGES="$GHB_PACKAGES appindicator-0.1" + CXXFLAGS="$CXXFLAGS -D_USE_APP_IND" + CFLAGS="$CFLAGS -D_USE_APP_IND" +fi PKG_CHECK_MODULES(GHB, [$GHB_PACKAGES]) AC_PATH_PROG(BUILD_PKG_CONFIG, pkg-config, no) 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 #endif +#if defined(_USE_APP_IND) +#include +#endif + #include "hb.h" #include "callbacks.h" #include "queuehandler.h" @@ -2744,6 +2748,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); @@ -2782,6 +2793,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); @@ -2866,6 +2884,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) diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 939ae155e..a532d0a3c 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -445,6 +445,13 @@ + + + show_hide + _Minimize/Maximize + + + @@ -475,6 +482,12 @@ + + + + + + diff --git a/gtk/src/main.c b/gtk/src/main.c index 2534dc449..6ff84ae89 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -47,6 +47,10 @@ #define pipe(phandles) _pipe (phandles, 4096, _O_BINARY) #endif +#if defined(_USE_APP_IND) +#include +#endif + #include #include #include "hb.h" @@ -944,6 +948,22 @@ main (int argc, char *argv[]) #else gtk_status_icon_set_tooltip(si, "HandBrake"); #endif +#if defined(_USE_APP_IND) + GtkUIManager * uim = GHB_OBJECT(ud->builder, "uimanager1"); + + GtkMenu *ai_menu = gtk_ui_manager_get_widget (uim, "/ui/tray_menu"); + ud->ai = app_indicator_new("HandBrake", "hb-icon", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + app_indicator_set_menu( ud->ai, ai_menu ); + app_indicator_set_label( ud->ai, "", "99.99%"); + 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 // Ugly hack to keep subtitle table from bouncing around as I change // which set of controls are visible diff --git a/gtk/src/settings.h b/gtk/src/settings.h index 2f9640375..d9d92beb1 100644 --- a/gtk/src/settings.h +++ b/gtk/src/settings.h @@ -17,6 +17,9 @@ #define _SETTINGS_H_ #include +#if defined(_USE_APP_IND) +#include +#endif #define GHB_WIDGET(b,n) GTK_WIDGET(gtk_builder_get_object ((b), (n))) //#define GHB_WIDGET(b,n) GTK_WIDGET(debug_get_object((b), (n))) @@ -64,6 +67,9 @@ typedef struct gchar *appcast; gint appcast_len; GdkVisibilityState hb_visibility; +#if defined(_USE_APP_IND) + AppIndicator *ai; +#endif } signal_user_data_t; enum diff --git a/pkg/linux/debian/control.natty b/pkg/linux/debian/control.natty index bda98e106..43df45eee 100644 --- a/pkg/linux/debian/control.natty +++ b/pkg/linux/debian/control.natty @@ -2,7 +2,7 @@ Source: handbrake Section: graphics Priority: optional Maintainer: John Stebbins -Build-Depends: debhelper (>= 6), autotools-dev, libtool, libgudev-1.0-dev, intltool, autoconf, yasm (>= 0.7.0), libbz2-dev, zlib1g-dev, libwebkitgtk-dev, libnotify-dev, libgstreamer0.10-dev, libgstreamer-plugins-base0.10-dev, wget, subversion, python (>= 2.6) +Build-Depends: debhelper (>= 6), autotools-dev, libtool, libgudev-1.0-dev, intltool, autoconf, yasm (>= 0.7.0), libbz2-dev, zlib1g-dev, libwebkitgtk-dev, libnotify-dev, libgstreamer0.10-dev, libgstreamer-plugins-base0.10-dev, wget, subversion, python (>= 2.6), libappindicator-dev Standards-Version: 3.8.4 Homepage: http://www.handbrake.fr/