Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### mate-panel 1.29.0

* Add optional volume control by scrolling on empty panel space

### mate-panel 1.28.1

* Build: require mate-desktop 1.28.2
Expand Down
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ PKG_CHECK_MODULES(PANEL, $GMODULE_ADD gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED pan
AC_SUBST(PANEL_CFLAGS)
AC_SUBST(PANEL_LIBS)

PKG_CHECK_MODULES(LIBPULSE, [libpulse libpulse-mainloop-glib], have_libpulse=yes, have_libpulse=no)
AM_CONDITIONAL(HAVE_LIBPULSE, test "x$have_libpulse" = "xyes")
if test "x$have_libpulse" = "xyes"; then
AC_DEFINE(HAVE_LIBPULSE, 1, [Define if libpulse is available])
PANEL_CFLAGS="$PANEL_CFLAGS $LIBPULSE_CFLAGS"
PANEL_LIBS="$PANEL_LIBS $LIBPULSE_LIBS"
fi
AC_SUBST(LIBPULSE_CFLAGS)
AC_SUBST(LIBPULSE_LIBS)

PKG_CHECK_MODULES(DCONF, dconf >= $DCONF_REQUIRED)

PKG_CHECK_MODULES(LIBMATE_PANEL_APPLET, gtk+-3.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED)
Expand Down
21 changes: 21 additions & 0 deletions data/org.mate.panel.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,26 @@
<summary>Enable SNI support</summary>
<description>If true, the panel provides support for SNI.</description>
</key>
<key name="enable-scroll-volume" type="b">
<default>false</default>
<summary>Change volume by scrolling on empty panel space</summary>
<description>If true, scrolling on an unoccupied area of a panel changes the default audio output volume. Scrolling over an applet is left unchanged.</description>
</key>
<key name="volume-scroll-step" type="u">
<default>5</default>
<range min="1" max="20"/>
<summary>Volume scroll step</summary>
<description>Percentage points changed for each mouse wheel step.</description>
</key>
<key name="volume-scroll-osd" type="b">
<default>true</default>
<summary>Show volume on-screen display</summary>
<description>Show a single transient volume indicator when scrolling changes the volume.</description>
</key>
<key name="volume-scroll-feedback" type="b">
<default>true</default>
<summary>Play volume feedback</summary>
<description>Use the desktop bell as optional feedback when scrolling changes the volume.</description>
</key>
</schema>
</schemalist>
5 changes: 5 additions & 0 deletions data/org.mate.panel.object.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<summary>Object's position on the panel</summary>
<description>The index of this panel object within the other objects with the same pack-type, from the left (or top if vertical) panel edge.</description>
</key>
<key name="relative-to-edge" enum="org.mate.panel.PanelObjectEdgeRelativity">
<default>'start'</default>
<summary>Whether to interpret the position relative to the start, center or end of the panel</summary>
<description>The position of the object is interpreted relative to one edge of the panel. This key is compatible with newer MATE panel layouts.</description>
</key>
<key name="position" type="i">
<default>0</default>
<summary>Object's position on the panel (deprecated)</summary>
Expand Down
2 changes: 2 additions & 0 deletions mate-panel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ panel_sources = \
panel-multimonitor.c \
panel-a11y.c \
panel-bindings.c \
panel-volume.c \
panel-layout.c \
panel-profile.c \
panel-lockdown.c \
Expand Down Expand Up @@ -108,6 +109,7 @@ panel_headers = \
panel-multimonitor.h \
panel-a11y.h \
panel-bindings.h \
panel-volume.h \
panel-layout.h \
panel-profile.h \
panel-enums-gsettings.h \
Expand Down
2 changes: 2 additions & 0 deletions mate-panel/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ panel_sources = [
'panel-multimonitor.c',
'panel-a11y.c',
'panel-bindings.c',
'panel-volume.c',
'panel-layout.c',
'panel-profile.c',
'panel-lockdown.c',
Expand Down Expand Up @@ -243,6 +244,7 @@ panel_sources = [
'panel-multimonitor.h',
'panel-a11y.h',
'panel-bindings.h',
'panel-volume.h',
'panel-layout.h',
'panel-profile.h',
'panel-enums-gsettings.h',
Expand Down
9 changes: 9 additions & 0 deletions mate-panel/panel-enums-gsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ typedef enum {
PANEL_OBJECT_PACK_END = 2
} PanelObjectPackType;

/* Position relative to an edge of the panel. This is the schema key used
* by newer MATE panel layouts; keep it separate from pack-type so older
* layouts remain compatible. */
typedef enum {
PANEL_OBJECT_EDGE_START = 0,
PANEL_OBJECT_EDGE_CENTER = 1,
PANEL_OBJECT_EDGE_END = 2
} PanelObjectEdgeRelativity;

typedef enum { /*< flags=0 >*/
PANEL_ORIENTATION_TOP = 1 << 0,
PANEL_ORIENTATION_RIGHT = 1 << 1,
Expand Down
34 changes: 30 additions & 4 deletions mate-panel/panel-profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,11 @@ panel_profile_load_object (char *id)
char *toplevel_id;
int position;
PanelObjectPackType pack_type;
PanelObjectEdgeRelativity relative_to_edge;
int pack_index;
gboolean right_stick;
gboolean locked;
GVariant *relative_to_edge_value;
GSettings *settings;

object_path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
Expand All @@ -1329,14 +1331,36 @@ panel_profile_load_object (char *id)
position = g_settings_get_int (settings, PANEL_OBJECT_POSITION_KEY);
toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY);
pack_type = g_settings_get_enum (settings, PANEL_OBJECT_PACK_TYPE_KEY);
relative_to_edge_value = g_settings_get_user_value (settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY);
relative_to_edge = relative_to_edge_value != NULL ?
g_settings_get_enum (settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY) :
PANEL_OBJECT_EDGE_START;
pack_index = g_settings_get_int (settings, PANEL_OBJECT_PACK_INDEX_KEY);
right_stick = g_settings_get_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY);
locked = g_settings_get_boolean (settings, PANEL_OBJECT_LOCKED_KEY);

/* If pack-type is still at the default value ('start') but right-stick
* is set, then map right-stick to PACK_END so the comparator sorts
* correctly. */
if (pack_type == PANEL_OBJECT_PACK_START && right_stick)
/* Newer MATE panel layouts store the zone in relative-to-edge, while
* older layouts use pack-type (or the deprecated panel-right-stick).
* Only override pack-type when relative-to-edge has an explicit user
* value, so old layouts keep their pack-type setting. */
if (relative_to_edge_value != NULL) {
switch (relative_to_edge) {
case PANEL_OBJECT_EDGE_CENTER:
pack_type = PANEL_OBJECT_PACK_CENTER;
break;
case PANEL_OBJECT_EDGE_END:
pack_type = PANEL_OBJECT_PACK_END;
break;
case PANEL_OBJECT_EDGE_START:
default:
pack_type = PANEL_OBJECT_PACK_START;
break;
}
}

/* If relative-to-edge is at its default ('start') but right-stick is
* set, map right-stick to PACK_END for old configurations. */
if (relative_to_edge_value == NULL && right_stick)
pack_type = PANEL_OBJECT_PACK_END;

mate_panel_applet_queue_applet_to_load (id,
Expand All @@ -1349,6 +1373,8 @@ panel_profile_load_object (char *id)

g_free (toplevel_id);
g_free (object_path);
if (relative_to_edge_value != NULL)
g_variant_unref (relative_to_edge_value);
g_object_unref (settings);
}

Expand Down
5 changes: 5 additions & 0 deletions mate-panel/panel-schemas.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#define PANEL_LOCKED_DOWN_KEY "locked-down"
#define PANEL_DISABLE_FORCE_QUIT_KEY "disable-force-quit"
#define PANEL_DISABLED_APPLETS_KEY "disabled-applets"
#define PANEL_ENABLE_SCROLL_VOLUME_KEY "enable-scroll-volume"
#define PANEL_VOLUME_SCROLL_STEP_KEY "volume-scroll-step"
#define PANEL_VOLUME_SCROLL_OSD_KEY "volume-scroll-osd"
#define PANEL_VOLUME_SCROLL_FEEDBACK_KEY "volume-scroll-feedback"

#define PANEL_TOPLEVEL_SCHEMA "org.mate.panel.toplevel"
#define PANEL_TOPLEVEL_NAME_KEY "name"
Expand Down Expand Up @@ -47,6 +51,7 @@
#define PANEL_OBJECT_TOPLEVEL_ID_KEY "toplevel-id"
#define PANEL_OBJECT_PACK_TYPE_KEY "pack-type"
#define PANEL_OBJECT_PACK_INDEX_KEY "pack-index"
#define PANEL_OBJECT_RELATIVE_TO_EDGE_KEY "relative-to-edge"
#define PANEL_OBJECT_POSITION_KEY "position"
#define PANEL_OBJECT_PANEL_RIGHT_STICK_KEY "panel-right-stick"
#define PANEL_OBJECT_LOCKED_KEY "locked"
Expand Down
70 changes: 70 additions & 0 deletions mate-panel/panel-toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "panel-config-global.h"
#include "panel-lockdown.h"
#include "panel-schemas.h"
#include "panel-volume.h"

#ifdef HAVE_X11
#include "xstuff.h"
Expand Down Expand Up @@ -3483,6 +3484,73 @@ panel_toplevel_button_release_event (GtkWidget *widget,
return TRUE;
}

static gboolean
panel_toplevel_scroll_is_on_empty_space (PanelToplevel *toplevel,
GdkEventScroll *event)
{
GtkWidget *event_widget = NULL;
GtkAllocation panel_allocation;
GtkAllocation applet_allocation;
GList *list;
gint x;
gint y;

/* The panel widget has its own GDK window, so the event can arrive at the
* toplevel even when the pointer is over the panel widget. Translate the
* event coordinates to the panel widget and hit-test its applets. */
gdk_window_get_user_data (event->window, (gpointer) &event_widget);
if (!GTK_IS_WIDGET (event_widget))
return FALSE;

if (!gtk_widget_translate_coordinates (event_widget,
GTK_WIDGET (toplevel->priv->panel_widget),
event->x, event->y, &x, &y))
return FALSE;

panel_allocation = (GtkAllocation) { 0, 0,
gtk_widget_get_allocated_width (GTK_WIDGET (toplevel->priv->panel_widget)),
gtk_widget_get_allocated_height (GTK_WIDGET (toplevel->priv->panel_widget)) };
if (x < panel_allocation.x || y < panel_allocation.y ||
x >= panel_allocation.x + panel_allocation.width ||
y >= panel_allocation.y + panel_allocation.height)
return FALSE;

for (list = toplevel->priv->panel_widget->applet_list;
list != NULL;
list = list->next) {
AppletData *applet_data = list->data;

gtk_widget_get_allocation (applet_data->applet, &applet_allocation);
if (x >= applet_allocation.x &&
x < applet_allocation.x + applet_allocation.width &&
y >= applet_allocation.y &&
y < applet_allocation.y + applet_allocation.height)
return FALSE;
}

return TRUE;
}

static gboolean
panel_toplevel_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
PanelToplevel *toplevel = PANEL_TOPLEVEL (widget);

if (event->direction == GDK_SCROLL_UP ||
event->direction == GDK_SCROLL_DOWN ||
event->direction == GDK_SCROLL_SMOOTH) {
if (panel_toplevel_scroll_is_on_empty_space (toplevel, event) &&
panel_volume_handle_scroll (event))
return TRUE;
}

if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)->scroll_event)
return GTK_WIDGET_CLASS (panel_toplevel_parent_class)->scroll_event (widget, event);

return FALSE;
}

static gboolean
panel_toplevel_configure_event (GtkWidget *widget,
GdkEventConfigure *event)
Expand Down Expand Up @@ -4364,6 +4432,7 @@ panel_toplevel_class_init (PanelToplevelClass *klass)
widget_class->configure_event = panel_toplevel_configure_event;
widget_class->key_press_event = panel_toplevel_key_press_event;
widget_class->motion_notify_event = panel_toplevel_motion_notify_event;
widget_class->scroll_event = panel_toplevel_scroll_event;
widget_class->enter_notify_event = panel_toplevel_enter_notify_event;
widget_class->leave_notify_event = panel_toplevel_leave_notify_event;
widget_class->screen_changed = panel_toplevel_screen_changed;
Expand Down Expand Up @@ -4864,6 +4933,7 @@ panel_toplevel_init (PanelToplevel *toplevel)
gtk_widget_add_events (widget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_SCROLL_MASK |
GDK_POINTER_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
Expand Down
Loading
Loading