diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2014-11-06 08:52:25 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2014-11-06 08:52:25 +0000 |
commit | 1117e765db2eff0f3c0a37571540ac7c0301c075 (patch) | |
tree | 385c34dffa7619d34e0bacd853f8ddf37e38cf70 /src | |
parent | 74c037633fea44650154911e5128b1bd6661e115 (diff) |
made the size of progress dialog and notificartion window DPI-aware.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3433 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r-- | src/gtkutils.c | 20 | ||||
-rw-r--r-- | src/gtkutils.h | 3 | ||||
-rw-r--r-- | src/notificationwindow.c | 22 | ||||
-rw-r--r-- | src/progressdialog.c | 13 |
4 files changed, 43 insertions, 15 deletions
diff --git a/src/gtkutils.c b/src/gtkutils.c index 3675439a..de014305 100644 --- a/src/gtkutils.c +++ b/src/gtkutils.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2011 Hiroyuki Yamamoto + * Copyright (C) 1999-2014 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -159,6 +159,24 @@ gdouble gtkut_get_dpi(void) return dpi; } +gdouble gtkut_get_dpi_multiplier(void) +{ + gdouble dpi; + gdouble mul; + + dpi = gtkut_get_dpi(); + + /* 96 / 120 / 144 dpi */ + if (dpi > 142) + mul = 1.5; + else if (dpi > 118) + mul = 1.25; + else + mul = 1.0; + + return mul; +} + void gtkut_convert_int_to_gdk_color(gint rgbvalue, GdkColor *color) { g_return_if_fail(color != NULL); diff --git a/src/gtkutils.h b/src/gtkutils.h index c3809a81..3d51132d 100644 --- a/src/gtkutils.h +++ b/src/gtkutils.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2008 Hiroyuki Yamamoto + * Copyright (C) 1999-2014 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,6 +97,7 @@ void gtkut_widget_set_small_font_size (GtkWidget *widget); gboolean gtkut_font_can_load (const gchar *str); gdouble gtkut_get_dpi (void); +gdouble gtkut_get_dpi_multiplier (void); void gtkut_convert_int_to_gdk_color (gint rgbvalue, GdkColor *color); diff --git a/src/notificationwindow.c b/src/notificationwindow.c index 0b445168..73d2fffa 100644 --- a/src/notificationwindow.c +++ b/src/notificationwindow.c @@ -32,10 +32,11 @@ #include "notificationwindow.h" #include "mainwindow.h" #include "utils.h" +#include "gtkutils.h" #define NOTIFICATIONWINDOW_NOTIFY_PERIOD 10000 -#define NOTIFICATIONWINDOW_WIDTH 300 -#define NOTIFICATIONWINDOW_HEIGHT 64 +#define NOTIFICATIONWINDOW_WIDTH 400 +#define NOTIFICATIONWINDOW_HEIGHT 80 #define FADE_REFRESH_RATE 50 /* ms */ #define FADE_SPEED 5 /* pixels */ #define FADE_IN_LENGTH 10 /* counts */ @@ -111,6 +112,11 @@ gint notification_window_open(const gchar *message, const gchar *submessage, GdkRectangle rect; gint x, y; GtkRequisition requisition; + gint window_width; + gint window_height; + + window_width = NOTIFICATIONWINDOW_WIDTH * gtkut_get_dpi_multiplier(); + window_height = NOTIFICATIONWINDOW_HEIGHT * gtkut_get_dpi_multiplier(); if (notify_window.window) { notification_window_destroy(); @@ -123,7 +129,7 @@ gint notification_window_open(const gchar *message, const gchar *submessage, gtk_widget_set_events(window, GDK_EXPOSURE_MASK|GDK_BUTTON_MOTION_MASK|GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE); gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_SOUTH_EAST); - gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, -1); + gtk_widget_set_size_request(window, window_width, -1); #if GTK_CHECK_VERSION(2, 12, 0) gtk_window_set_opacity(GTK_WINDOW(window), 0.0); #endif @@ -132,9 +138,9 @@ gint notification_window_open(const gchar *message, const gchar *submessage, /* move window bottom-right */ get_work_area(&rect); - x = rect.x + rect.width - NOTIFICATIONWINDOW_WIDTH - 2; + x = rect.x + rect.width - window_width - 2; if (x < 0) x = 0; - y = rect.y + rect.height - NOTIFICATIONWINDOW_HEIGHT - 2; + y = rect.y + rect.height - window_height - 2; if (y < 0) y = 0; gtk_window_move(GTK_WINDOW(window), x, y); @@ -164,9 +170,9 @@ gint notification_window_open(const gchar *message, const gchar *submessage, /* adjust window size and position */ gtk_widget_get_child_requisition(window, &requisition); - notify_window.width = NOTIFICATIONWINDOW_WIDTH; - notify_window.height = MAX(requisition.height, NOTIFICATIONWINDOW_HEIGHT); - gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, notify_window.height); + notify_window.width = window_width; + notify_window.height = MAX(requisition.height, window_height); + gtk_widget_set_size_request(window, window_width, notify_window.height); y = rect.y + rect.height - notify_window.height - 2; if (y < 0) y = 0; gtk_window_move(GTK_WINDOW(window), x, y); diff --git a/src/progressdialog.c b/src/progressdialog.c index 58cc1713..2107da45 100644 --- a/src/progressdialog.c +++ b/src/progressdialog.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2012 Hiroyuki Yamamoto + * Copyright (C) 1999-2014 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,9 @@ #include "gtkutils.h" #include "utils.h" +#define PROGRESS_DIALOG_WIDTH 460 +#define PROGRESS_TREE_VIEW_HEIGHT 120 + ProgressDialog *progress_dialog_create(void) { ProgressDialog *progress; @@ -72,7 +75,7 @@ ProgressDialog *progress_dialog_create(void) gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); gtk_widget_show(treeview); gtk_container_add(GTK_CONTAINER(scrolledwin), treeview); - gtk_widget_set_size_request(treeview, -1, 120); + gtk_widget_set_size_request(treeview, -1, PROGRESS_TREE_VIEW_HEIGHT * gtkut_get_dpi_multiplier()); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); @@ -91,7 +94,7 @@ ProgressDialog *progress_dialog_create(void) (_("Account"), renderer, "text", PROG_COL_NAME, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); - gtk_tree_view_column_set_fixed_width(column, 120); + gtk_tree_view_column_set_fixed_width(column, 120 * gtkut_get_dpi_multiplier()); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); renderer = gtk_cell_renderer_text_new(); @@ -99,7 +102,7 @@ ProgressDialog *progress_dialog_create(void) (_("Status"), renderer, "text", PROG_COL_STATUS, NULL); gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); - gtk_tree_view_column_set_fixed_width(column, 100); + gtk_tree_view_column_set_fixed_width(column, 100 * gtkut_get_dpi_multiplier()); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); renderer = gtk_cell_renderer_text_new(); @@ -128,7 +131,7 @@ ProgressDialog *progress_dialog_simple_create(void) progress = g_new0(ProgressDialog, 1); dialog = gtk_dialog_new(); - gtk_widget_set_size_request(dialog, 460, -1); + gtk_widget_set_size_request(dialog, PROGRESS_DIALOG_WIDTH * gtkut_get_dpi_multiplier(), -1); gtk_container_set_border_width(GTK_CONTAINER(dialog), 8); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, TRUE); |