aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2014-10-30 09:12:32 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2014-10-30 09:12:32 +0000
commit95ac4907de609f33f0da8e03b44a14f94613f03e (patch)
tree04d74147eff1c4ae9a73070a9b38cdaf7dbb2d26
parent64e7e1880f5350fe6ddebd81612f4d219608dfd9 (diff)
fixed 'Minimize to tray icon' option notworking on Windows.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3428 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog11
-rw-r--r--src/gtkutils.c16
-rw-r--r--src/gtkutils.h2
-rw-r--r--src/main.c2
-rw-r--r--src/mainwindow.c24
5 files changed, 48 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ac0d1f52..6b02002d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-10-30
+
+ * src/mainwindow.c
+ src/gtkutils.c: win32: fixed 'Minimize to tray icon' option not
+ working on Windows.
+
+2014-10-30
+
+ * src/gtkutils.[ch]
+ src/main.c: added gtkut_get_dpi().
+
2014-09-22
* libsylph/recv.c: recv_bytes_write(): fixed a bug that wrote the
diff --git a/src/gtkutils.c b/src/gtkutils.c
index f57d1bd4..3675439a 100644
--- a/src/gtkutils.c
+++ b/src/gtkutils.c
@@ -144,6 +144,21 @@ gboolean gtkut_font_can_load(const gchar *str)
#endif
}
+gdouble gtkut_get_dpi(void)
+{
+ gdouble dpi;
+ gdouble dp, di;
+
+ //dpi = gdk_screen_get_resolution(gdk_screen_get_default());
+
+ dp = gdk_screen_get_height(gdk_screen_get_default());
+ di = gdk_screen_get_height_mm(gdk_screen_get_default()) / 25.4;
+ dpi = dp / di;
+
+ debug_print("gtkut_get_dpi: dpi: %f\n", dpi);
+ return dpi;
+}
+
void gtkut_convert_int_to_gdk_color(gint rgbvalue, GdkColor *color)
{
g_return_if_fail(color != NULL);
@@ -969,6 +984,7 @@ void gtkut_window_popup(GtkWidget *window)
gdk_window_move(window->window, new_x, new_y);
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), FALSE);
+ gtk_widget_show(window);
gtk_window_present(GTK_WINDOW(window));
#ifdef G_OS_WIN32
/* ensure that the window is displayed at the top */
diff --git a/src/gtkutils.h b/src/gtkutils.h
index 3434bd2b..c3809a81 100644
--- a/src/gtkutils.h
+++ b/src/gtkutils.h
@@ -96,6 +96,8 @@ void gtkut_widget_set_small_font_size (GtkWidget *widget);
gboolean gtkut_font_can_load (const gchar *str);
+gdouble gtkut_get_dpi (void);
+
void gtkut_convert_int_to_gdk_color (gint rgbvalue,
GdkColor *color);
diff --git a/src/main.c b/src/main.c
index 790febfa..033d4f6a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -297,6 +297,8 @@ int main(int argc, char *argv[])
gtkut_widget_init();
+ gtkut_get_dpi();
+
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "icons", NULL);
if (is_dir_exist(path)) {
debug_print("icon theme dir: %s\n", path);
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 3995c322..53284edd 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -3236,6 +3236,7 @@ static gboolean main_window_window_state_cb(GtkWidget *widget,
gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
+ gboolean minimized = FALSE;
if ((event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
if ((event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
@@ -3244,23 +3245,32 @@ static gboolean main_window_window_state_cb(GtkWidget *widget,
prefs_common.mainwin_maximized = FALSE;
}
if ((event->changed_mask & GDK_WINDOW_STATE_ICONIFIED) != 0) {
- if ((event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) != 0)
+ if ((event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) != 0) {
+ debug_print("main_window_window_state_cb: iconified\n");
+ minimized = TRUE;
mainwin->window_hidden = TRUE;
- else
+ } else {
+ debug_print("main_window_window_state_cb: deiconified\n");
mainwin->window_hidden = FALSE;
+ }
}
if ((event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN) != 0) {
- if ((event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) != 0)
+ if ((event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) != 0) {
+ debug_print("main_window_window_state_cb: withdrawn\n");
mainwin->window_hidden = TRUE;
- else
+ } else {
+ debug_print("main_window_window_state_cb: unwithdrawn\n");
mainwin->window_hidden = FALSE;
+ }
}
- if (mainwin->window_hidden &&
- prefs_common.show_trayicon && prefs_common.minimize_to_tray)
+ if (minimized &&
+ prefs_common.show_trayicon && prefs_common.minimize_to_tray) {
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), TRUE);
- else if (!mainwin->window_hidden)
+ gtk_widget_hide(widget);
+ } else if (!mainwin->window_hidden) {
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
+ }
return FALSE;
}