[Xfce4-commits] [panel-plugins/xfce4-weather-plugin] 01/01: Enable keyboard scrolling in Details pane (bug #15912)

noreply at xfce.org noreply at xfce.org
Sun Mar 1 13:13:59 CET 2020


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-weather-plugin.

commit ff0c3ec9f71ad27b635637774d0b065d6e49b8ef
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Mar 1 07:13:52 2020 -0500

    Enable keyboard scrolling in Details pane (bug #15912)
---
 panel-plugin/weather-summary.c | 53 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index da12a5b..e66abf0 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -282,6 +282,56 @@ weather_summary_get_logo(plugin_data *data)
 }
 
 
+static gboolean
+text_view_key_pressed_cb (GtkWidget   *widget,
+                          GdkEventKey *event,
+                          gpointer     user_data)
+{
+    GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (user_data);
+    GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment (scrolled);
+    gdouble current = gtk_adjustment_get_value (adjustment);
+    gdouble min = gtk_adjustment_get_lower (adjustment);
+    gdouble max = gtk_adjustment_get_upper (adjustment);
+    gdouble step_size = 0;
+
+    switch (event->keyval) {
+        case GDK_KEY_Up:
+        case GDK_KEY_uparrow:
+            step_size = -1 * gtk_adjustment_get_step_increment (adjustment);
+            break;
+        case GDK_KEY_Down:
+        case GDK_KEY_downarrow:
+            step_size = gtk_adjustment_get_step_increment (adjustment);
+            break;
+        case GDK_KEY_Page_Up:
+            step_size = -1 * gtk_adjustment_get_page_size (adjustment);
+            break;
+        case GDK_KEY_Page_Down:
+        case GDK_KEY_space:
+            step_size = gtk_adjustment_get_page_size (adjustment);
+            break;
+        case GDK_KEY_Home:
+            step_size = -1 * current;
+            break;
+        case GDK_KEY_End:
+            step_size = max;
+            break;
+    }
+
+    if (step_size != 0) {
+        current = current + step_size;
+        if (current < min) current = min;
+        if (current > max) current = max;
+
+        gtk_adjustment_set_value (adjustment, current);
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+
 static GtkWidget *
 create_summary_tab(plugin_data *data)
 {
@@ -311,9 +361,12 @@ create_summary_tab(plugin_data *data)
     gtk_text_view_set_top_margin (GTK_TEXT_VIEW(view), 12);
     gtk_text_view_set_right_margin (GTK_TEXT_VIEW(view), 12);
     gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW(view), 12);
+
     frame = gtk_frame_new(NULL);
     scrolled = gtk_scrolled_window_new(NULL, NULL);
 
+    g_signal_connect(GTK_WIDGET(view), "key-press-event", G_CALLBACK(text_view_key_pressed_cb), scrolled);
+
     overlay = gtk_overlay_new ();
     gtk_container_add (GTK_CONTAINER (overlay), view);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list