diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/callbacks.c | 52 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 13 | ||||
-rw-r--r-- | gtk/src/main.c | 20 | ||||
-rw-r--r-- | gtk/src/settings.h | 6 |
4 files changed, 91 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) 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 @@ <signal handler="guide_activate_cb" name="activate"/> </object> </child> + <child> + <object class="GtkAction" id="show_hide"> + <property name="name">show_hide</property> + <property name="label" translatable="yes">_Minimize/Maximize</property> + <signal handler="show_hide_toggle_cb" name="activate"/> + </object> + </child> </object> </child> <ui> @@ -475,6 +482,12 @@ <menuitem action="guide"/> </menu> </menubar> + <popup name="tray_menu"> + <menuitem action="show_hide"/> + <menuitem action="queue_pause_menu"/> + <menuitem action="quit1"/> + <menuitem action="about"/> + </popup> </ui> </object> <object class="GtkListStore" id="device_list"> 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 <libappindicator/app-indicator.h> +#endif + #include <glib/gstdio.h> #include <gio/gio.h> #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 <gtk/gtk.h> +#if defined(_USE_APP_IND) +#include <libappindicator/app-indicator.h> +#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 |