|
37 | 37 | BUTTON_RELEASE, |
38 | 38 | ACTIVATE, |
39 | 39 | STATE_CHANGED, |
| 40 | + SCROLL, |
40 | 41 | LAST_SIGNAL |
41 | 42 | }; |
42 | 43 |
|
@@ -163,6 +164,24 @@ state_to_str (XAppStatusIconState state) |
163 | 164 | } |
164 | 165 | } |
165 | 166 |
|
| 167 | +static const gchar * |
| 168 | +direction_to_str (XAppScrollDirection direction) |
| 169 | +{ |
| 170 | + switch (direction) |
| 171 | + { |
| 172 | + case XAPP_SCROLL_UP: |
| 173 | + return "Up"; |
| 174 | + case XAPP_SCROLL_DOWN: |
| 175 | + return "Down"; |
| 176 | + case XAPP_SCROLL_LEFT: |
| 177 | + return "Left"; |
| 178 | + case XAPP_SCROLL_RIGHT: |
| 179 | + return "Right"; |
| 180 | + default: |
| 181 | + return "Unknown"; |
| 182 | + } |
| 183 | +} |
| 184 | + |
166 | 185 | static gint |
167 | 186 | adjust_y_for_monitor_bounds (gint init_x, |
168 | 187 | gint init_y, |
@@ -438,6 +457,30 @@ handle_click_method (XAppStatusIconInterface *skeleton, |
438 | 457 | return TRUE; |
439 | 458 | } |
440 | 459 |
|
| 460 | +static gboolean |
| 461 | +handle_scroll_method (XAppStatusIconInterface *skeleton, |
| 462 | + GDBusMethodInvocation *invocation, |
| 463 | + gint delta, |
| 464 | + XAppScrollDirection direction, |
| 465 | + guint _time, |
| 466 | + XAppStatusIcon *icon) |
| 467 | +{ |
| 468 | + g_debug ("XAppStatusIcon: received Scroll from monitor %s: " |
| 469 | + "delta: %d , direction: %s , time: %u", |
| 470 | + g_dbus_method_invocation_get_sender (invocation), |
| 471 | + delta, direction_to_str (direction), _time); |
| 472 | + |
| 473 | + g_signal_emit(icon, signals[SCROLL], 0, |
| 474 | + delta, |
| 475 | + direction, |
| 476 | + _time); |
| 477 | + |
| 478 | + xapp_status_icon_interface_complete_scroll (skeleton, |
| 479 | + invocation); |
| 480 | + |
| 481 | + return TRUE; |
| 482 | +} |
| 483 | + |
441 | 484 | static void |
442 | 485 | popup_gtk_status_icon_with_menu (XAppStatusIcon *icon, |
443 | 486 | GtkMenu *menu, |
@@ -724,7 +767,8 @@ typedef struct |
724 | 767 | static SkeletonSignal skeleton_signals[] = { |
725 | 768 | // signal name callback |
726 | 769 | { "handle-button-press", handle_click_method }, |
727 | | - { "handle-button-release", handle_click_method } |
| 770 | + { "handle-button-release", handle_click_method }, |
| 771 | + { "handle-scroll", handle_scroll_method } |
728 | 772 | }; |
729 | 773 |
|
730 | 774 | static gboolean |
@@ -1344,6 +1388,25 @@ xapp_status_icon_class_init (XAppStatusIconClass *klass) |
1344 | 1388 | 0, |
1345 | 1389 | NULL, NULL, NULL, |
1346 | 1390 | G_TYPE_NONE, 1, XAPP_TYPE_STATUS_ICON_STATE); |
| 1391 | + |
| 1392 | + /** |
| 1393 | + * XAppStatusIcon::scroll-event: |
| 1394 | + * @icon: The #XAppStatusIcon |
| 1395 | + * @amount: The amount of movement for the scroll event |
| 1396 | + * @direction: the #XAppScrollDirection of the scroll event |
| 1397 | + * @time: The time supplied by the event, or 0 |
| 1398 | + * |
| 1399 | + * Gets emitted when the user uses the mouse scroll wheel over the status icon. |
| 1400 | + * For the most part, amounts will always be 1, unless an applet supports smooth |
| 1401 | + * scrolling. Generally the direction value is most important. |
| 1402 | + */ |
| 1403 | + signals [SCROLL] = |
| 1404 | + g_signal_new ("scroll-event", |
| 1405 | + XAPP_TYPE_STATUS_ICON, |
| 1406 | + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
| 1407 | + 0, |
| 1408 | + NULL, NULL, NULL, |
| 1409 | + G_TYPE_NONE, 3, G_TYPE_INT, XAPP_TYPE_SCROLL_DIRECTION, G_TYPE_UINT); |
1347 | 1410 | } |
1348 | 1411 |
|
1349 | 1412 | /** |
|
0 commit comments