[Xfce4-commits] [apps/xfce4-terminal] 01/01: Fix dropdown window animation
noreply at xfce.org
noreply at xfce.org
Thu Aug 4 13:04:18 CEST 2016
This is an automated email from the git hooks/post-receive script.
f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.
commit b9bf0e1f6efb60cb4a9922fa01a026648feb9e26
Author: Igor <f2404 at yandex.ru>
Date: Thu Aug 4 14:04:13 2016 +0300
Fix dropdown window animation
---
terminal/terminal-window-dropdown.c | 81 ++++++++++++++++++-------------------
terminal/terminal-window.c | 9 ++---
2 files changed, 44 insertions(+), 46 deletions(-)
diff --git a/terminal/terminal-window-dropdown.c b/terminal/terminal-window-dropdown.c
index 236eefb..975b7b3 100644
--- a/terminal/terminal-window-dropdown.c
+++ b/terminal/terminal-window-dropdown.c
@@ -562,28 +562,36 @@ terminal_window_dropdown_animate_down (gpointer data)
{
TerminalWindowDropdown *dropdown = TERMINAL_WINDOW_DROPDOWN (data);
TerminalWindow *window = TERMINAL_WINDOW (data);
- GtkRequisition req1, req2;
- gint step_size;
- gint viewport_h;
+ GtkRequisition req1;
+ GdkRectangle rect;
+ gint step_size, viewport_h;
+
+ /* get window size */
+ gdk_screen_get_monitor_geometry (dropdown->screen, dropdown->monitor_num, &rect);
+ if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (window->action_fullscreen)))
+ {
+ /* calculate width/height if not fullscreen */
+ rect.width *= dropdown->rel_width;
+ rect.height *= dropdown->rel_height;
+ }
/* decrease each interval */
- gtk_widget_get_preferred_size (window->vbox, &req1, NULL);
- step_size = req1.height * ANIMATION_FPS / dropdown->animation_time;
+ step_size = rect.height * ANIMATION_FPS / dropdown->animation_time;
if (step_size < 1)
step_size = 1;
/* new viewport size */
- gtk_widget_get_preferred_size (dropdown->viewport, &req2, NULL);
- viewport_h = req2.height + step_size;
- if (viewport_h > req1.height)
- viewport_h = req1.height;
+ gtk_widget_get_preferred_size (dropdown->viewport, &req1, NULL);
+ viewport_h = req1.height + step_size;
+ if (viewport_h > rect.height)
+ viewport_h = rect.height;
/* resize */
- gtk_widget_set_size_request (dropdown->viewport, req2.width, viewport_h);
- gtk_window_resize (GTK_WINDOW (dropdown), req2.width, viewport_h);
+ gtk_widget_set_size_request (dropdown->viewport, req1.width, viewport_h);
+ gtk_window_resize (GTK_WINDOW (window), req1.width, viewport_h);
/* continue the animation */
- if (viewport_h < req1.height)
+ if (viewport_h < rect.height)
return TRUE;
/* restore the fullscreen state */
@@ -601,46 +609,42 @@ terminal_window_dropdown_animate_up (gpointer data)
{
TerminalWindowDropdown *dropdown = TERMINAL_WINDOW_DROPDOWN (data);
TerminalWindow *window = TERMINAL_WINDOW (data);
- GtkRequisition req1, req2;
- gint step_size, viewport_h, min_size;
+ GtkRequisition req1;
GdkRectangle rect;
+ gint step_size, viewport_h, min_size;
/* get window size */
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (window->action_fullscreen)))
+ gdk_screen_get_monitor_geometry (dropdown->screen, dropdown->monitor_num, &rect);
+ if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (window->action_fullscreen)))
{
- /* use the monitor size for the animation */
- gdk_screen_get_monitor_geometry (dropdown->screen, dropdown->monitor_num, &rect);
- req1.width = rect.width;
- req1.height = rect.height;
- }
- else
- {
- gtk_widget_get_preferred_size (window->vbox, &req1, NULL);
+ /* calculate width/height if not fullscreen */
+ rect.width *= dropdown->rel_width;
+ rect.height *= dropdown->rel_height;
}
/* decrease each interval */
- step_size = req1.height * ANIMATION_FPS / dropdown->animation_time;
+ step_size = rect.height * ANIMATION_FPS / dropdown->animation_time;
if (step_size < 1)
step_size = 1;
/* new viewport size */
- gtk_widget_get_preferred_size (dropdown->viewport, &req2, NULL);
- viewport_h = req2.height - step_size;
+ gtk_widget_get_preferred_size (dropdown->viewport, &req1, NULL);
+ viewport_h = req1.height - step_size;
/* sizes of the widgets that cannot be shrunk */
- gtk_widget_get_preferred_size (window->notebook, &req2, NULL);
- min_size = req2.height;
+ gtk_widget_get_preferred_size (window->notebook, &req1, NULL);
+ min_size = req1.height;
if (window->menubar != NULL
&& gtk_widget_get_visible (window->menubar))
{
- gtk_widget_get_preferred_size (window->menubar, &req2, NULL);
- min_size += req2.height;
+ gtk_widget_get_preferred_size (window->menubar, &req1, NULL);
+ min_size += req1.height;
}
if (window->toolbar != NULL
&& gtk_widget_get_visible (window->toolbar))
{
- gtk_widget_get_preferred_size (window->toolbar, &req2, NULL);
- min_size += req2.height;
+ gtk_widget_get_preferred_size (window->toolbar, &req1, NULL);
+ min_size += req1.height;
}
if (viewport_h < min_size)
@@ -651,9 +655,9 @@ terminal_window_dropdown_animate_up (gpointer data)
}
/* resize window */
- gtk_widget_set_size_request (dropdown->viewport, req1.width, viewport_h);
- gtk_widget_set_size_request (window->vbox, req1.width, viewport_h);
- gtk_window_resize (GTK_WINDOW (dropdown), req1.width, viewport_h);
+ gtk_widget_set_size_request (dropdown->viewport, rect.width, viewport_h);
+ gtk_window_resize (GTK_WINDOW (window), rect.width, viewport_h);
+
return TRUE;
}
@@ -698,7 +702,6 @@ terminal_window_dropdown_show (TerminalWindowDropdown *dropdown,
gint w, h;
GdkRectangle monitor_geo;
gint x_dest, y_dest;
- glong char_width, char_height;
GtkRequisition req1;
gboolean move_to_active;
gboolean visible;
@@ -729,9 +732,6 @@ terminal_window_dropdown_show (TerminalWindowDropdown *dropdown,
/* move window to correct screen */
gtk_window_set_screen (GTK_WINDOW (dropdown), dropdown->screen);
- /* get terminal size */
- terminal_screen_get_geometry (window->active, &char_width, &char_height, NULL, NULL);
-
/* correct padding with notebook size */
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (window->action_fullscreen)))
{
@@ -769,8 +769,7 @@ terminal_window_dropdown_show (TerminalWindowDropdown *dropdown,
}
}
- /* resize the widgets */
- gtk_widget_set_size_request (window->vbox, w, h);
+ /* resize */
gtk_widget_set_size_request (dropdown->viewport, w, viewport_h);
/* calc position */
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 997f292..ef3355b 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -298,7 +298,6 @@ static void
terminal_window_init (TerminalWindow *window)
{
GtkAccelGroup *accel_group;
- GtkWidget *vbox;
gboolean always_show_tabs;
GdkScreen *screen;
GdkVisual *visual;
@@ -335,8 +334,8 @@ terminal_window_init (TerminalWindow *window)
g_signal_connect_after (G_OBJECT (accel_group), "accel-activate",
G_CALLBACK (terminal_window_accel_activate), window);
- window->vbox = vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (window), vbox);
+ window->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_add (GTK_CONTAINER (window), window->vbox);
/* allocate the notebook for the terminal screens */
g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL);
@@ -368,8 +367,8 @@ terminal_window_init (TerminalWindow *window)
g_signal_connect (G_OBJECT (window->notebook), "scroll-event",
G_CALLBACK (terminal_window_notebook_scroll_event), window);
- gtk_box_pack_start (GTK_BOX (vbox), window->notebook, TRUE, TRUE, 0);
- gtk_widget_show_all (vbox);
+ gtk_box_pack_start (GTK_BOX (window->vbox), window->notebook, TRUE, TRUE, 0);
+ gtk_widget_show_all (window->vbox);
/* create encoding action */
window->encoding_action = terminal_encoding_action_new ("set-encoding", _("Set _Encoding"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list