Skip to content

Commit

Permalink
RDA support: Make MATE panel aware of being run inside a remote deskt…
Browse files Browse the repository at this point in the history
…op technology.
  • Loading branch information
sunweaver committed Nov 9, 2018
1 parent a73abb8 commit 24c31d2
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ if test "x$have_randr" = "xyes"; then
AC_DEFINE(HAVE_RANDR, 1, [Have the Xrandr extension library])
fi

dnl Remote Desktop Awareness

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

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

Expand Down
2 changes: 2 additions & 0 deletions mate-panel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ mate_panel_SOURCES = \
mate_panel_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(XRANDR_CFLAGS) \
$(RDA_CFLAGS) \
-DPANEL_MODULES_DIR=\"$(modulesdir)\" \
-DMATEMENU_I_KNOW_THIS_IS_UNSTABLE

Expand All @@ -135,6 +136,7 @@ mate_panel_LDADD = \
$(DCONF_LIBS) \
$(XRANDR_LIBS) \
$(X_LIBS) \
$(RDA_LIBS) \
-lm

mate_panel_LDFLAGS = -export-dynamic
Expand Down
38 changes: 38 additions & 0 deletions mate-panel/panel-action-button.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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 @@ -96,6 +100,9 @@ static ObsoleteEnumStringPair panel_action_type_map [] = {
{ PANEL_ACTION_FORCE_QUIT, "force-quit" },
{ PANEL_ACTION_CONNECT_SERVER, "connect-server" },
{ PANEL_ACTION_SHUTDOWN, "shutdown" },
#ifdef HAVE_RDA
{ PANEL_ACTION_SUSPEND, "suspend" },
#endif
{ 0, NULL },
};

Expand Down Expand Up @@ -232,6 +239,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 @@ -412,6 +437,19 @@ static PanelAction actions [] = {
panel_action_shutdown, NULL, NULL,
panel_action_shutdown_reboot_is_disabled
}
#ifdef HAVE_RDA
,
{
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 */
};

gboolean
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 @@ -68,6 +68,7 @@ typedef enum {
PANEL_ACTION_FORCE_QUIT,
PANEL_ACTION_CONNECT_SERVER,
PANEL_ACTION_SHUTDOWN,
PANEL_ACTION_SUSPEND,
PANEL_ACTION_LAST
} PanelActionButtonType;

Expand Down
1 change: 1 addition & 0 deletions mate-panel/panel-icon-names.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define PANEL_ICON_SAVED_SEARCH "folder-saved-search"
#define PANEL_ICON_SEARCHTOOL "system-search"
#define PANEL_ICON_SHUTDOWN "system-shutdown"
#define PANEL_ICON_SUSPEND "stock_media-pause"
#define PANEL_ICON_THEME "preferences-desktop-theme"
#define PANEL_ICON_TRASH "user-trash"
#define PANEL_ICON_UNKNOWN "image-missing"
Expand Down
25 changes: 25 additions & 0 deletions mate-panel/panel-menu-items.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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 @@ -1582,6 +1585,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

0 comments on commit 24c31d2

Please sign in to comment.