summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-06-26 04:31:01 +0000
committerjstebbins <[email protected]>2009-06-26 04:31:01 +0000
commitfaa2f3c603eeb6dca2e8f286ba0541ebb22873a0 (patch)
tree877e4f1ca3c8805ec648d331037e1255c967dc3e
parent2c2b1157d6910159a40546f22602c80bd8d9f1b6 (diff)
LinGui: modify behavior of system tray icon
- clicking raises hb if iconified or obscured, iconifies if hb unobscured - when hb is iconified via the system tray icon, remove it from taskbar - preference option now enables/disables system tray icon git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2624 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--gtk/src/callbacks.c37
-rw-r--r--gtk/src/ghb.ui9
-rw-r--r--gtk/src/internal_defaults.xml4
-rw-r--r--gtk/src/main.c8
-rw-r--r--gtk/src/settings.h1
5 files changed, 42 insertions, 17 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 4d2ad0926..ae30c9ab0 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -2932,18 +2932,19 @@ use_m4v_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
}
G_MODULE_EXPORT void
-skip_taskbar_cb(GtkWidget *widget, signal_user_data_t *ud)
+show_status_cb(GtkWidget *widget, signal_user_data_t *ud)
{
- g_debug("pref_changed_cb");
+ g_debug("show_status_cb");
ghb_widget_to_setting (ud->settings, widget);
ghb_check_dependency(ud, widget);
const gchar *name = gtk_widget_get_name(widget);
ghb_pref_save(ud->settings, name);
- GtkWindow *window;
- window = GTK_WINDOW(GHB_WIDGET (ud->builder, "hb_window"));
- gtk_window_set_skip_taskbar_hint(window,
- ghb_settings_get_boolean(ud->settings, "skip_taskbar"));
+ GtkStatusIcon *si;
+
+ si = GTK_STATUS_ICON(GHB_OBJECT (ud->builder, "hb_status"));
+ gtk_status_icon_set_visible(si,
+ ghb_settings_get_boolean(ud->settings, "show_status"));
}
G_MODULE_EXPORT void
@@ -3801,13 +3802,35 @@ ghb_check_update(signal_user_data_t *ud)
return NULL;
}
+G_MODULE_EXPORT gboolean
+hb_visibility_event_cb(
+ GtkWidget *widget,
+ GdkEventVisibility *vs,
+ signal_user_data_t *ud)
+{
+ ud->hb_visibility = vs->state;
+ return FALSE;
+}
+
G_MODULE_EXPORT void
status_activate_cb(GtkStatusIcon *si, signal_user_data_t *ud)
{
GtkWindow *window;
+ GdkWindowState state;
window = GTK_WINDOW(GHB_WIDGET(ud->builder, "hb_window"));
- gtk_window_present(window);
+ state = gdk_window_get_state(GTK_WIDGET(window)->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)
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index 520db9556..2faec4d7d 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -457,6 +457,8 @@
<property name="default_width">500</property>
<property name="default_height">400</property>
<property name="icon_name">hb-icon</property>
+ <property name="events">GDK_VISIBILITY_NOTIFY_MASK</property>
+ <signal handler="hb_visibility_event_cb" name="visibility_notify_event"/>
<signal handler="window_destroy_event_cb" name="destroy_event"/>
<signal handler="window_delete_event_cb" name="delete_event"/>
<child>
@@ -3608,13 +3610,13 @@ no-dct-decimate=0:cabac=1</property>
<property name="bottom_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkCheckButton" id="skip_taskbar">
- <property name="label" translatable="yes">Minimize to System Tray</property>
+ <object class="GtkCheckButton" id="show_status">
+ <property name="label" translatable="yes">Show system tray icon</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="skip_taskbar_cb"/>
+ <signal name="toggled" handler="show_status_cb"/>
</object>
</child>
</object>
@@ -5969,6 +5971,7 @@ libx264 authors:
</child>
</object>
<object class="GtkStatusIcon" id="hb_status">
+ <property name="visible">False</property>
<property name="icon_name">hb-icon</property>
<signal handler="status_activate_cb" name="activate"/>
</object>
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index 27017ef04..6f1cde11b 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -103,8 +103,8 @@
<dict>
<key>EncodeLogLocation</key>
<false />
- <key>skip_taskbar</key>
- <false />
+ <key>show_status</key>
+ <true />
<key>allow_tweaks</key>
<false />
<key>title_no_in_destination</key>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index 9058bd43c..34d3c149d 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -800,6 +800,9 @@ main (int argc, char *argv[])
GtkStatusIcon *si;
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 GTK_CHECK_VERSION(2, 16, 0)
gtk_status_icon_set_has_tooltip(si, TRUE);
g_signal_connect(si, "query-tooltip",
@@ -808,11 +811,6 @@ main (int argc, char *argv[])
gtk_status_icon_set_tooltip(si, "HandBrake");
#endif
- GtkWindow *window;
- window = GTK_WINDOW(GHB_WIDGET (ud->builder, "hb_window"));
- gtk_window_set_skip_taskbar_hint(window,
- ghb_settings_get_boolean(ud->settings, "skip_taskbar"));
-
// Everything should be go-to-go. Lets rock!
gtk_main ();
diff --git a/gtk/src/settings.h b/gtk/src/settings.h
index 072baf07a..e974c0941 100644
--- a/gtk/src/settings.h
+++ b/gtk/src/settings.h
@@ -53,6 +53,7 @@ typedef struct
preview_t *preview;
gchar *appcast;
gint appcast_len;
+ GdkVisibilityState hb_visibility;
} signal_user_data_t;
enum