Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDA support: Make MATE panel aware of being run inside a remote deskt… #824

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
30 changes: 30 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ GTK_REQUIRED=3.22.0
LIBWNCK_REQUIRED=3.4.6
LIBWNCK_PREVIEWS_OPTIONAL=3.32.0
WEATHER_REQUIRED=1.17.0
RDA_REQUIRED=0.0.3

dnl pkg-config dependency checks

Expand Down Expand Up @@ -243,6 +244,34 @@ if test "x$have_randr" = "xyes"; then
AC_DEFINE(HAVE_RANDR, 1, [Have the Xrandr extension library])
fi

dnl Remote Desktop Awareness

AC_ARG_ENABLE(rda,
[AS_HELP_STRING([--enable-rda],
[Enable RDA (Remote Desktop Awareness,
default is to enable only if RDA development library is detected)])],,
[enable_rda=$enableval],
[enable_rda=auto])

# Check if we have librda installed, and thus should build with Wayland support
have_rda=no
if test "x$enable_rda" != "xno"; then
PKG_CHECK_MODULES(RDA, rda >= $RDA_REQUIRED, have_rda=yes, [
if test "x$enable_rda" = "xyes"; then
AC_MSG_ERROR([Remote Desktop Awareness enabled but RDA library not found])
fi
])
fi

AM_CONDITIONAL(ENABLE_RDA, [test "x$have_rda" = "xyes"])

if test "x$have_rda" = "xyes"; then
AC_DEFINE(HAVE_RDA, 1, [Have the Remote Desktop Awareness library])
fi

AC_SUBST(RDA_CFLAGS)
AC_SUBST(RDA_LIBS)

dnl Modules dir
AC_SUBST([modulesdir],"\$(libdir)/mate-panel/modules")

Expand Down Expand Up @@ -381,6 +410,7 @@ echo "
Wayland support: ${have_wayland}
X11 support: ${have_x11}
XRandr support: ${have_randr}
RDA support: ${have_rda}
Build introspection support: ${found_introspection}
Build gtk-doc documentation: ${enable_gtk_doc}

Expand Down
16 changes: 12 additions & 4 deletions mate-panel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ AM_CPPFLAGS = \
-I$(top_builddir)/mate-panel/libpanel-util \
-DMATELOCALEDIR=\""$(datadir)/locale"\" \
-DPANELDATADIR=\""$(datadir)/mate-panel"\" \
$(DISABLE_DEPRECATED_CFLAGS) \
$(WAYLAND_CFLAGS)
$(DISABLE_DEPRECATED_CFLAGS)

AM_CFLAGS = $(WARN_CFLAGS)

Expand Down Expand Up @@ -145,6 +144,11 @@ mate_panel_CPPFLAGS = \
-DPANEL_MODULES_DIR=\"$(modulesdir)\" \
-DMATEMENU_I_KNOW_THIS_IS_UNSTABLE

if ENABLE_RDA
mate_panel_CPPFLAGS += \
$(RDA_CFLAGS)
endif

if ENABLE_WAYLAND
mate_panel_CPPFLAGS += \
$(WAYLAND_CFLAGS)
Expand All @@ -157,8 +161,12 @@ mate_panel_LDADD = \
$(PANEL_LIBS) \
$(DCONF_LIBS) \
$(XRANDR_LIBS) \
$(X_LIBS) \
$(WAYLAND_LIBS)
$(X_LIBS)

if ENABLE_RDA
mate_panel_LDADD += \
$(RDA_LIBS)
endif

if ENABLE_WAYLAND
mate_panel_LDADD += \
Expand Down
37 changes: 37 additions & 0 deletions mate-panel/panel-action-button.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <glib/gi18n.h>
#include <gio/gio.h>

#ifdef HAVE_RDA
#include <rda/rda.h>
#endif

#define MATE_DESKTOP_USE_UNSTABLE_API
#include <libmate-desktop/mate-desktop-utils.h>
#include <libmate-desktop/mate-gsettings.h>
Expand Down Expand Up @@ -86,6 +90,9 @@ static const char *panel_action_type [PANEL_ACTION_LAST] = {
[PANEL_ACTION_NONE] = "none",
[PANEL_ACTION_LOCK] = "lock",
[PANEL_ACTION_LOGOUT] = "logout",
#ifdef HAVE_RDA
[PANEL_ACTION_SUSPEND] = "suspend",
#endif
[PANEL_ACTION_RUN] = "run",
[PANEL_ACTION_SEARCH] = "search",
[PANEL_ACTION_FORCE_QUIT] = "force-quit",
Expand Down Expand Up @@ -213,6 +220,24 @@ panel_action_logout (GtkWidget *widget)
PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL);
}

#ifdef HAVE_RDA
/* Suspend Remote Session
*/
static void
panel_action_suspend (GtkWidget *widget)
{

rda_session_suspend();

}

static gboolean
panel_action_suspend_not_supported(void)
{
return (!rda_session_can_be_suspended());
}
#endif /* HAVE_RDA */

static void
panel_action_shutdown (GtkWidget *widget)
{
Expand Down Expand Up @@ -361,6 +386,18 @@ static PanelAction actions [PANEL_ACTION_LAST] = {
panel_action_logout, NULL, NULL,
panel_lockdown_get_disable_log_out
},
#ifdef HAVE_RDA
[PANEL_ACTION_SUSPEND] = {
PANEL_ACTION_SUSPEND,
PANEL_ICON_SUSPEND,
N_("Suspend Session..."),
N_("Suspend the Remote Session and Resume later"),
"gospanel-20",
"ACTION:suspend:NEW",
panel_action_suspend, NULL, NULL,
panel_action_suspend_not_supported
},
#endif /* HAVE_RDA */
[PANEL_ACTION_RUN] = {
PANEL_ACTION_RUN,
PANEL_ICON_RUN,
Expand Down
1 change: 1 addition & 0 deletions mate-panel/panel-enums-gsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef enum {
PANEL_ACTION_NONE = 0,
PANEL_ACTION_LOCK,
PANEL_ACTION_LOGOUT,
PANEL_ACTION_SUSPEND,
PANEL_ACTION_RUN,
PANEL_ACTION_SEARCH,
PANEL_ACTION_FORCE_QUIT,
Expand Down
5 changes: 5 additions & 0 deletions mate-panel/panel-icon-names.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <config.h>

#ifndef PANEL_ICON_NAMES_H
#define PANEL_ICON_NAMES_H

Expand All @@ -21,6 +23,9 @@
#define PANEL_ICON_LAUNCHER "mate-panel-launcher"
#define PANEL_ICON_LOCKSCREEN "system-lock-screen"
#define PANEL_ICON_LOGOUT "system-log-out"
#ifdef HAVE_RDA
#define PANEL_ICON_SUSPEND "stock_media-pause"
#endif
#define PANEL_ICON_MAIN_MENU "start-here"
#define PANEL_ICON_NETWORK "network-workgroup"
#define PANEL_ICON_NETWORK_SERVER "network-server"
Expand Down
31 changes: 31 additions & 0 deletions mate-panel/panel-menu-items.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#include <string.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#ifdef HAVE_RDA
#include <rda/rda.h>
#endif
#include <libmate-desktop/mate-gsettings.h>

#include <libpanel-util/panel-error.h>
Expand Down Expand Up @@ -1543,6 +1546,28 @@ panel_menu_items_append_lock_logout (GtkWidget *menu)
}
g_list_free (children);

#ifdef HAVE_RDA
if (rda_session_can_be_suspended())
{

label = g_strdup_printf (_("Suspend %s Session..."),
rda_get_remote_technology_name());
tooltip = g_strdup_printf (_("Suspend this %s session and resume it later..."),
rda_get_remote_technology_name());
item = panel_menu_items_create_action_item_full (PANEL_ACTION_SUSPEND,
label, tooltip);
g_free (label);
g_free (tooltip);

if (item != NULL) {
/* this separator will always be inserted */
add_menu_separator (menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}

}
#endif /* HAVE_RDA */

if (panel_lock_screen_action_available("lock"))
{
item = panel_menu_items_create_action_item(PANEL_ACTION_LOCK);
Expand Down Expand Up @@ -1605,13 +1630,19 @@ panel_menu_items_append_lock_logout (GtkWidget *menu)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}

#ifdef HAVE_RDA
if (rda_session_is_local()) {
#endif /* HAVE_RDA */
item = panel_menu_items_create_action_item (PANEL_ACTION_SHUTDOWN);
if (item != NULL) {
if (!separator_inserted)
add_menu_separator (menu);

gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
#ifdef HAVE_RDA
}
#endif /* HAVE_RDA */
}

void
Expand Down