2013-01-14 17:58:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Intel, Inc
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Author: Thomas Wood <thomas.wood@intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cc-sharing-panel.h"
|
2018-04-06 13:38:40 +02:00
|
|
|
#include "cc-hostname-entry.h"
|
2021-10-21 20:03:06 -03:00
|
|
|
#include "cc-list-row.h"
|
2013-01-14 17:58:44 +00:00
|
|
|
|
|
|
|
#include "cc-sharing-resources.h"
|
|
|
|
#include "cc-remote-login.h"
|
|
|
|
#include "file-share-properties.h"
|
|
|
|
#include "cc-media-sharing.h"
|
2014-06-20 10:07:46 +02:00
|
|
|
#include "cc-sharing-networks.h"
|
2018-02-14 20:52:37 +08:00
|
|
|
#include "cc-gnome-remote-desktop.h"
|
2014-06-20 10:07:46 +02:00
|
|
|
#include "org.gnome.SettingsDaemon.Sharing.h"
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2016-11-16 16:05:57 +01:00
|
|
|
#ifdef GDK_WINDOWING_WAYLAND
|
2021-10-21 20:03:06 -03:00
|
|
|
#include <gdk/wayland/gdkwayland.h>
|
2016-11-16 16:05:57 +01:00
|
|
|
#endif
|
2013-01-14 17:58:44 +00:00
|
|
|
#include <glib/gi18n.h>
|
2013-01-28 17:24:15 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2013-10-03 10:38:16 +01:00
|
|
|
static void cc_sharing_panel_setup_label_with_hostname (CcSharingPanel *self, GtkWidget *label);
|
2014-06-12 16:20:47 +02:00
|
|
|
static GtkWidget *cc_sharing_panel_new_media_sharing_row (const char *uri_or_path,
|
|
|
|
CcSharingPanel *self);
|
2013-10-03 10:38:16 +01:00
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
#define FILE_SHARING_SCHEMA_ID "org.gnome.desktop.file-sharing"
|
2017-08-18 17:36:32 +08:00
|
|
|
#define GNOME_REMOTE_DESKTOP_SCHEMA_ID "org.gnome.desktop.remote-desktop"
|
2018-02-14 20:52:37 +08:00
|
|
|
#define GNOME_REMOTE_DESKTOP_VNC_SCHEMA_ID "org.gnome.desktop.remote-desktop.vnc"
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GRD_VNC_AUTH_METHOD_PROMPT,
|
|
|
|
GRD_VNC_AUTH_METHOD_PASSWORD
|
|
|
|
} GrdVncAuthMethod;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
struct _CcSharingPanel
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2018-06-01 09:30:39 +12:00
|
|
|
CcPanel parent_instance;
|
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *approve_connections_radiobutton;
|
2013-01-14 17:58:44 +00:00
|
|
|
GtkWidget *hostname_entry;
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *main_list_box;
|
|
|
|
GtkWidget *master_switch;
|
|
|
|
GtkWidget *media_sharing_dialog;
|
|
|
|
GtkWidget *media_sharing_headerbar;
|
2020-05-11 13:49:28 +05:30
|
|
|
GtkWidget *media_sharing_row;
|
2014-06-20 10:07:46 +02:00
|
|
|
GtkWidget *media_sharing_switch;
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *personal_file_sharing_dialog;
|
|
|
|
GtkWidget *personal_file_sharing_grid;
|
|
|
|
GtkWidget *personal_file_sharing_headerbar;
|
|
|
|
GtkWidget *personal_file_sharing_label;
|
|
|
|
GtkWidget *personal_file_sharing_password_entry;
|
|
|
|
GtkWidget *personal_file_sharing_password_label;
|
|
|
|
GtkWidget *personal_file_sharing_require_password_switch;
|
2020-05-11 13:49:28 +05:30
|
|
|
GtkWidget *personal_file_sharing_row;
|
2014-06-20 10:07:46 +02:00
|
|
|
GtkWidget *personal_file_sharing_switch;
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *password_grid;
|
|
|
|
GtkWidget *remote_control_box;
|
|
|
|
GtkWidget *remote_control_checkbutton;
|
|
|
|
GtkWidget *remote_control_password_entry;
|
|
|
|
GtkWidget *remote_login_dialog;
|
|
|
|
GtkWidget *remote_login_label;
|
2020-05-11 13:49:28 +05:30
|
|
|
GtkWidget *remote_login_row;
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *remote_login_switch;
|
|
|
|
GtkWidget *require_password_radiobutton;
|
|
|
|
GtkWidget *screen_sharing_dialog;
|
|
|
|
GtkWidget *screen_sharing_grid;
|
|
|
|
GtkWidget *screen_sharing_headerbar;
|
|
|
|
GtkWidget *screen_sharing_label;
|
2020-05-11 13:49:28 +05:30
|
|
|
GtkWidget *screen_sharing_row;
|
2014-06-20 10:07:46 +02:00
|
|
|
GtkWidget *screen_sharing_switch;
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *shared_folders_grid;
|
|
|
|
GtkWidget *shared_folders_listbox;
|
|
|
|
GtkWidget *show_password_checkbutton;
|
|
|
|
|
|
|
|
GDBusProxy *sharing_proxy;
|
2014-06-20 10:07:46 +02:00
|
|
|
|
2017-08-29 17:52:52 +02:00
|
|
|
guint remote_desktop_name_watch;
|
2013-01-14 17:58:44 +00:00
|
|
|
};
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
CC_PANEL_REGISTER (CcSharingPanel, cc_sharing_panel)
|
|
|
|
|
2018-10-15 11:49:19 +13:00
|
|
|
#define OFF_IF_VISIBLE(x, y) { if (gtk_widget_is_visible(x) && (y) != NULL && gtk_widget_is_sensitive(y)) gtk_switch_set_active (GTK_SWITCH(y), FALSE); }
|
2014-06-20 10:07:46 +02:00
|
|
|
|
2013-02-19 09:50:53 +00:00
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
cc_sharing_panel_master_switch_notify (CcSharingPanel *self)
|
2013-02-19 09:50:53 +00:00
|
|
|
{
|
|
|
|
gboolean active;
|
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
active = gtk_switch_get_active (GTK_SWITCH (self->master_switch));
|
2013-02-19 09:50:53 +00:00
|
|
|
|
|
|
|
if (!active)
|
|
|
|
{
|
|
|
|
/* disable all services if the master switch is not active */
|
2020-05-11 13:49:28 +05:30
|
|
|
OFF_IF_VISIBLE(self->media_sharing_row, self->media_sharing_switch);
|
|
|
|
OFF_IF_VISIBLE(self->personal_file_sharing_row, self->personal_file_sharing_switch);
|
|
|
|
OFF_IF_VISIBLE(self->screen_sharing_row, self->screen_sharing_switch);
|
2014-06-20 10:07:46 +02:00
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->remote_login_switch), FALSE);
|
2013-02-19 09:50:53 +00:00
|
|
|
}
|
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_set_sensitive (self->main_list_box, active);
|
2013-02-19 09:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_sharing_panel_constructed (GObject *object)
|
|
|
|
{
|
2018-06-01 09:30:39 +12:00
|
|
|
CcSharingPanel *self = CC_SHARING_PANEL (object);
|
2013-02-19 09:50:53 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_sharing_panel_parent_class)->constructed (object);
|
|
|
|
|
|
|
|
/* add the master switch */
|
|
|
|
cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (object)),
|
2019-05-21 12:57:45 -03:00
|
|
|
gtk_widget_get_parent (self->master_switch),
|
|
|
|
GTK_POS_RIGHT);
|
2013-02-19 09:50:53 +00:00
|
|
|
}
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_dispose (GObject *object)
|
|
|
|
{
|
2018-06-01 09:30:39 +12:00
|
|
|
CcSharingPanel *self = CC_SHARING_PANEL (object);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
if (self->remote_desktop_name_watch)
|
|
|
|
g_bus_unwatch_name (self->remote_desktop_name_watch);
|
|
|
|
self->remote_desktop_name_watch = 0;
|
2017-08-29 17:52:52 +02:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
if (self->media_sharing_dialog)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_window_destroy (GTK_WINDOW (self->media_sharing_dialog));
|
2018-06-01 09:30:39 +12:00
|
|
|
self->media_sharing_dialog = NULL;
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
if (self->personal_file_sharing_dialog)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_window_destroy (GTK_WINDOW (self->personal_file_sharing_dialog));
|
2018-06-01 09:30:39 +12:00
|
|
|
self->personal_file_sharing_dialog = NULL;
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
if (self->remote_login_dialog)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_window_destroy (GTK_WINDOW (self->remote_login_dialog));
|
2018-06-01 09:30:39 +12:00
|
|
|
self->remote_login_dialog = NULL;
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
if (self->screen_sharing_dialog)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_window_destroy (GTK_WINDOW (self->screen_sharing_dialog));
|
2018-06-01 09:30:39 +12:00
|
|
|
self->screen_sharing_dialog = NULL;
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
g_clear_object (&self->sharing_proxy);
|
2014-06-20 10:07:46 +02:00
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
G_OBJECT_CLASS (cc_sharing_panel_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2013-05-28 12:06:12 +02:00
|
|
|
static const char *
|
|
|
|
cc_sharing_panel_get_help_uri (CcPanel *panel)
|
|
|
|
{
|
2015-03-04 11:33:25 +00:00
|
|
|
return "help:gnome-help/prefs-sharing";
|
2013-05-28 12:06:12 +02:00
|
|
|
}
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_class_init (CcSharingPanelClass *klass)
|
|
|
|
{
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2013-01-14 17:58:44 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2013-05-28 12:06:12 +02:00
|
|
|
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2013-02-19 09:50:53 +00:00
|
|
|
object_class->constructed = cc_sharing_panel_constructed;
|
2013-01-14 17:58:44 +00:00
|
|
|
object_class->dispose = cc_sharing_panel_dispose;
|
2013-05-28 12:06:12 +02:00
|
|
|
|
|
|
|
panel_class->get_help_uri = cc_sharing_panel_get_help_uri;
|
2018-01-17 23:18:37 -02:00
|
|
|
|
2018-11-08 14:25:48 +13:00
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/sharing/cc-sharing-panel.ui");
|
2018-06-01 11:17:12 +12:00
|
|
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, approve_connections_radiobutton);
|
2018-09-21 18:32:48 +02:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, hostname_entry);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, screen_sharing_grid);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, shared_folders_grid);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, main_list_box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_dialog);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_headerbar);
|
2020-05-11 13:49:28 +05:30
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, media_sharing_row);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_dialog);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_grid);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_headerbar);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_label);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_password_entry);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_password_label);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_require_password_switch);
|
2020-05-11 13:49:28 +05:30
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_row);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, password_grid);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_control_box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_control_checkbutton);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_control_password_entry);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_dialog);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_label);
|
2020-05-11 13:49:28 +05:30
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_row);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, require_password_radiobutton);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, screen_sharing_dialog);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, screen_sharing_headerbar);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, screen_sharing_label);
|
2020-05-11 13:49:28 +05:30
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, screen_sharing_row);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, shared_folders_listbox);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, show_password_checkbutton);
|
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
g_type_ensure (CC_TYPE_LIST_ROW);
|
2018-01-17 23:18:37 -02:00
|
|
|
g_type_ensure (CC_TYPE_HOSTNAME_ENTRY);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_sharing_panel_run_dialog (CcSharingPanel *self,
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *dialog)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *parent;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2013-10-03 10:38:16 +01:00
|
|
|
/* ensure labels with the hostname are updated if the hostname has changed */
|
|
|
|
cc_sharing_panel_setup_label_with_hostname (self,
|
2018-06-01 11:17:12 +12:00
|
|
|
self->screen_sharing_label);
|
|
|
|
cc_sharing_panel_setup_label_with_hostname (self, self->remote_login_label);
|
2013-10-03 10:38:16 +01:00
|
|
|
cc_sharing_panel_setup_label_with_hostname (self,
|
2018-06-01 11:17:12 +12:00
|
|
|
self->personal_file_sharing_label);
|
2013-10-03 10:38:16 +01:00
|
|
|
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self)));
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
cc_sharing_panel_main_list_box_row_activated (CcSharingPanel *self,
|
|
|
|
GtkListBoxRow *row)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *dialog;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2020-05-11 13:49:28 +05:30
|
|
|
if (row == GTK_LIST_BOX_ROW (self->media_sharing_row))
|
2018-06-01 11:17:12 +12:00
|
|
|
dialog = self->media_sharing_dialog;
|
2020-05-11 13:49:28 +05:30
|
|
|
else if (row == GTK_LIST_BOX_ROW (self->personal_file_sharing_row))
|
2018-06-01 11:17:12 +12:00
|
|
|
dialog = self->personal_file_sharing_dialog;
|
2020-05-11 13:49:28 +05:30
|
|
|
else if (row == GTK_LIST_BOX_ROW (self->remote_login_row))
|
2018-06-01 11:17:12 +12:00
|
|
|
dialog = self->remote_login_dialog;
|
2020-05-11 13:49:28 +05:30
|
|
|
else if (row == GTK_LIST_BOX_ROW (self->screen_sharing_row))
|
2018-06-01 11:17:12 +12:00
|
|
|
dialog = self->screen_sharing_dialog;
|
|
|
|
else
|
2013-01-14 17:58:44 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
gtk_list_box_select_row (GTK_LIST_BOX (self->main_list_box), NULL);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
cc_sharing_panel_run_dialog (self, dialog);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-02-19 09:50:53 +00:00
|
|
|
cc_sharing_panel_switch_to_label_transform_func (GBinding *binding,
|
|
|
|
const GValue *source_value,
|
|
|
|
GValue *target_value,
|
|
|
|
CcSharingPanel *self)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
if (!G_VALUE_HOLDS_BOOLEAN (source_value))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!G_VALUE_HOLDS_STRING (target_value))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
active = g_value_get_boolean (source_value);
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
g_value_set_string (target_value, C_("service is enabled", "On"));
|
|
|
|
else
|
|
|
|
g_value_set_string (target_value, C_("service is disabled", "Off"));
|
|
|
|
|
2013-02-19 09:50:53 +00:00
|
|
|
/* ensure the master switch is active if one of the services is active */
|
|
|
|
if (active)
|
2018-06-01 09:30:39 +12:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->master_switch), TRUE);
|
2013-02-19 09:50:53 +00:00
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-06-20 10:07:46 +02:00
|
|
|
static gboolean
|
|
|
|
cc_sharing_panel_networks_to_label_transform_func (GBinding *binding,
|
|
|
|
const GValue *source_value,
|
|
|
|
GValue *target_value,
|
|
|
|
CcSharingPanel *self)
|
|
|
|
{
|
|
|
|
CcSharingStatus status;
|
|
|
|
|
|
|
|
if (!G_VALUE_HOLDS_UINT (source_value))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!G_VALUE_HOLDS_STRING (target_value))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
status = g_value_get_uint (source_value);
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case CC_SHARING_STATUS_OFF:
|
|
|
|
g_value_set_string (target_value, C_("service is disabled", "Off"));
|
|
|
|
break;
|
|
|
|
case CC_SHARING_STATUS_ENABLED:
|
|
|
|
g_value_set_string (target_value, C_("service is enabled", "Enabled"));
|
|
|
|
break;
|
|
|
|
case CC_SHARING_STATUS_ACTIVE:
|
|
|
|
g_value_set_string (target_value, C_("service is active", "Active"));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ensure the master switch is active if one of the services is active */
|
|
|
|
if (status != CC_SHARING_STATUS_OFF)
|
2018-06-01 09:30:39 +12:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->master_switch), TRUE);
|
2014-06-20 10:07:46 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
static void
|
2013-02-19 09:50:53 +00:00
|
|
|
cc_sharing_panel_bind_switch_to_label (CcSharingPanel *self,
|
|
|
|
GtkWidget *gtkswitch,
|
2020-05-11 13:49:28 +05:30
|
|
|
GtkWidget *row)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2020-05-11 13:49:28 +05:30
|
|
|
g_object_bind_property_full (gtkswitch, "active", row, "secondary-label",
|
2013-01-14 17:58:44 +00:00
|
|
|
G_BINDING_SYNC_CREATE,
|
2013-02-19 09:50:53 +00:00
|
|
|
(GBindingTransformFunc) cc_sharing_panel_switch_to_label_transform_func,
|
|
|
|
NULL, self, NULL);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2014-06-20 10:07:46 +02:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_bind_networks_to_label (CcSharingPanel *self,
|
|
|
|
GtkWidget *networks,
|
2020-05-11 13:49:28 +05:30
|
|
|
GtkWidget *list_row)
|
2014-06-20 10:07:46 +02:00
|
|
|
{
|
2020-05-11 13:49:28 +05:30
|
|
|
g_object_bind_property_full (networks, "status", list_row, "secondary-label",
|
2014-06-20 10:07:46 +02:00
|
|
|
G_BINDING_SYNC_CREATE,
|
|
|
|
(GBindingTransformFunc) cc_sharing_panel_networks_to_label_transform_func,
|
|
|
|
NULL, self, NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_bind_switch_to_widgets (GtkWidget *gtkswitch,
|
|
|
|
GtkWidget *first_widget,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
va_list w;
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
va_start (w, first_widget);
|
|
|
|
|
|
|
|
g_object_bind_property (gtkswitch, "active", first_widget,
|
|
|
|
"sensitive", G_BINDING_SYNC_CREATE);
|
|
|
|
|
|
|
|
while ((widget = va_arg (w, GtkWidget*)))
|
|
|
|
{
|
|
|
|
g_object_bind_property (gtkswitch, "active", widget,
|
|
|
|
"sensitive", G_BINDING_SYNC_CREATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end (w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-10-21 20:03:06 -03:00
|
|
|
on_add_folder_dialog_response_cb (GtkDialog *dialog,
|
|
|
|
gint response,
|
|
|
|
CcSharingPanel *self)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autofree gchar *folder = NULL;
|
2021-10-21 20:03:06 -03:00
|
|
|
g_autoptr(GFile) file = NULL;
|
|
|
|
GtkWidget *child;
|
2013-11-14 23:55:04 +01:00
|
|
|
gboolean matching = FALSE;
|
2021-10-21 20:03:06 -03:00
|
|
|
gint n_rows = 0;
|
2014-06-12 16:20:47 +02:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
if (response != GTK_RESPONSE_ACCEPT)
|
2015-02-09 11:28:24 +01:00
|
|
|
goto bail;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
|
|
|
folder = g_file_get_uri (file);
|
2013-11-14 09:16:34 +01:00
|
|
|
if (!folder || g_str_equal (folder, ""))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
g_debug ("Trying to add %s", folder);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
for (child = gtk_widget_get_first_child (self->shared_folders_listbox);
|
|
|
|
child;
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2013-10-02 16:42:18 +01:00
|
|
|
{
|
2014-06-12 16:20:47 +02:00
|
|
|
const char *string;
|
2013-10-02 16:42:18 +01:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
string = g_object_get_data (G_OBJECT (child), "path");
|
2013-11-14 09:25:30 +01:00
|
|
|
matching = (g_strcmp0 (string, folder) == 0);
|
2013-10-02 16:42:18 +01:00
|
|
|
|
|
|
|
if (matching)
|
2013-11-14 09:16:34 +01:00
|
|
|
{
|
|
|
|
g_debug ("Found a duplicate for %s", folder);
|
|
|
|
break;
|
|
|
|
}
|
2021-10-21 20:03:06 -03:00
|
|
|
|
|
|
|
n_rows++;
|
2013-10-02 16:42:18 +01:00
|
|
|
}
|
|
|
|
|
2013-11-14 09:16:34 +01:00
|
|
|
if (!matching)
|
2014-06-12 16:20:47 +02:00
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
GtkWidget *row = cc_sharing_panel_new_media_sharing_row (folder, self);
|
2014-06-12 16:20:47 +02:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_list_box_insert (GTK_LIST_BOX (self->shared_folders_listbox),
|
|
|
|
row,
|
|
|
|
n_rows - 1);
|
2014-06-12 16:20:47 +02:00
|
|
|
}
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2013-11-14 09:16:34 +01:00
|
|
|
bail:
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_sharing_panel_add_folder (CcSharingPanel *self,
|
|
|
|
GtkListBoxRow *row)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-add")))
|
|
|
|
return;
|
|
|
|
|
|
|
|
dialog = gtk_file_chooser_dialog_new (_("Choose a Folder"),
|
|
|
|
GTK_WINDOW (self->media_sharing_dialog),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Open"), GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect_object (dialog,
|
|
|
|
"response",
|
|
|
|
G_CALLBACK (on_add_folder_dialog_response_cb),
|
|
|
|
self,
|
|
|
|
0);
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
cc_sharing_panel_remove_folder (CcSharingPanel *self,
|
|
|
|
GtkButton *button)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2014-06-12 16:20:47 +02:00
|
|
|
GtkWidget *row;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2014-06-12 16:20:47 +02:00
|
|
|
row = g_object_get_data (G_OBJECT (button), "row");
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_list_box_remove (GTK_LIST_BOX (self->shared_folders_listbox), row);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
cc_sharing_panel_media_sharing_dialog_response (CcSharingPanel *self,
|
|
|
|
gint reponse_id)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autoptr(GPtrArray) folders = NULL;
|
2021-10-21 20:03:06 -03:00
|
|
|
GtkWidget *child;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
|
|
|
folders = g_ptr_array_new_with_free_func (g_free);
|
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
for (child = gtk_widget_get_first_child (self->shared_folders_listbox);
|
|
|
|
child;
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2014-06-12 16:20:47 +02:00
|
|
|
const char *folder;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
folder = g_object_get_data (G_OBJECT (child), "path");
|
2014-06-12 16:20:47 +02:00
|
|
|
if (folder == NULL)
|
|
|
|
continue;
|
|
|
|
g_ptr_array_add (folders, g_strdup (folder));
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_ptr_array_add (folders, NULL);
|
|
|
|
|
2014-06-20 10:07:46 +02:00
|
|
|
cc_media_sharing_set_preferences ((gchar **) folders->pdata);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 16:20:47 +02:00
|
|
|
#define ICON_NAME_FOLDER "folder-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_DESKTOP "user-desktop-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_DOCUMENTS "folder-documents-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_DOWNLOAD "folder-download-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_MUSIC "folder-music-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_PICTURES "folder-pictures-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_PUBLIC_SHARE "folder-publicshare-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_TEMPLATES "folder-templates-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_VIDEOS "folder-videos-symbolic"
|
|
|
|
#define ICON_NAME_FOLDER_SAVED_SEARCH "folder-saved-search-symbolic"
|
|
|
|
|
|
|
|
static GIcon *
|
|
|
|
special_directory_get_gicon (GUserDirectory directory)
|
|
|
|
{
|
|
|
|
#define ICON_CASE(x) \
|
|
|
|
case G_USER_DIRECTORY_ ## x: \
|
|
|
|
return g_themed_icon_new_with_default_fallbacks (ICON_NAME_FOLDER_ ## x);
|
|
|
|
|
|
|
|
switch (directory)
|
|
|
|
{
|
|
|
|
ICON_CASE (DESKTOP);
|
|
|
|
ICON_CASE (DOCUMENTS);
|
|
|
|
ICON_CASE (DOWNLOAD);
|
|
|
|
ICON_CASE (MUSIC);
|
|
|
|
ICON_CASE (PICTURES);
|
|
|
|
ICON_CASE (PUBLIC_SHARE);
|
|
|
|
ICON_CASE (TEMPLATES);
|
|
|
|
ICON_CASE (VIDEOS);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return g_themed_icon_new_with_default_fallbacks (ICON_NAME_FOLDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef ICON_CASE
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
cc_sharing_panel_new_media_sharing_row (const char *uri_or_path,
|
|
|
|
CcSharingPanel *self)
|
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
GtkWidget *row, *w;
|
2014-06-12 16:20:47 +02:00
|
|
|
GUserDirectory dir = G_USER_N_DIRECTORIES;
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autoptr(GIcon) icon = NULL;
|
2014-06-12 16:20:47 +02:00
|
|
|
guint i;
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autofree gchar *basename = NULL;
|
|
|
|
g_autofree gchar *path = NULL;
|
|
|
|
g_autoptr(GFile) file = NULL;
|
2014-06-12 16:20:47 +02:00
|
|
|
|
|
|
|
file = g_file_new_for_commandline_arg (uri_or_path);
|
|
|
|
path = g_file_get_path (file);
|
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
row = adw_action_row_new ();
|
2014-06-12 16:20:47 +02:00
|
|
|
|
|
|
|
/* Find the icon and create it */
|
|
|
|
for (i = 0; i < G_USER_N_DIRECTORIES; i++)
|
|
|
|
{
|
|
|
|
if (g_strcmp0 (path, g_get_user_special_dir (i)) == 0)
|
|
|
|
{
|
|
|
|
dir = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
icon = special_directory_get_gicon (dir);
|
2021-10-21 20:03:06 -03:00
|
|
|
adw_action_row_add_prefix (ADW_ACTION_ROW (row),
|
|
|
|
gtk_image_new_from_gicon (icon));
|
2014-06-12 16:20:47 +02:00
|
|
|
|
|
|
|
/* Label */
|
|
|
|
basename = g_filename_display_basename (path);
|
2021-10-21 20:03:06 -03:00
|
|
|
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), basename);
|
2014-06-12 16:20:47 +02:00
|
|
|
|
|
|
|
/* Remove button */
|
2021-10-21 20:03:06 -03:00
|
|
|
w = gtk_button_new_from_icon_name ("window-close-symbolic");
|
|
|
|
gtk_widget_add_css_class (w, "flat");
|
2014-06-12 16:20:47 +02:00
|
|
|
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
|
2021-10-21 20:03:06 -03:00
|
|
|
adw_action_row_add_suffix (ADW_ACTION_ROW (row), w);
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (G_OBJECT (w), "clicked",
|
|
|
|
G_CALLBACK (cc_sharing_panel_remove_folder), self, G_CONNECT_SWAPPED);
|
2014-06-12 16:20:47 +02:00
|
|
|
g_object_set_data (G_OBJECT (w), "row", row);
|
|
|
|
|
2018-06-01 11:00:19 +12:00
|
|
|
g_object_set_data_full (G_OBJECT (row), "path", g_steal_pointer (&path), g_free);
|
2014-06-12 16:20:47 +02:00
|
|
|
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
cc_sharing_panel_new_add_media_sharing_row (CcSharingPanel *self)
|
|
|
|
{
|
|
|
|
GtkWidget *row, *box, *w;
|
|
|
|
|
|
|
|
row = gtk_list_box_row_new ();
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
|
2014-06-12 16:20:47 +02:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
w = gtk_image_new_from_icon_name ("list-add-symbolic");
|
2014-06-12 16:20:47 +02:00
|
|
|
gtk_widget_set_hexpand (w, TRUE);
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_widget_set_margin_top (w, 12);
|
|
|
|
gtk_widget_set_margin_bottom (w, 12);
|
|
|
|
gtk_box_append (GTK_BOX (box), w);
|
2014-06-12 16:20:47 +02:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (w), "row", row);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (row), "is-add", GINT_TO_POINTER (1));
|
|
|
|
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
static GtkWidget *
|
|
|
|
create_switch_with_bindings (GtkSwitch *from)
|
|
|
|
{
|
|
|
|
GtkWidget *new_switch = gtk_switch_new ();
|
|
|
|
|
|
|
|
g_object_bind_property (from, "visible", new_switch, "visible", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
|
|
|
g_object_bind_property (from, "state", new_switch, "state", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
|
|
|
g_object_bind_property (from, "active", new_switch, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
|
|
|
g_object_bind_property (from, "sensitive", new_switch, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
|
|
|
|
|
|
|
return new_switch;
|
|
|
|
}
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_setup_media_sharing_dialog (CcSharingPanel *self)
|
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
g_auto(GStrv) folders = NULL;
|
|
|
|
GStrv list;
|
2018-10-15 11:32:03 +13:00
|
|
|
GtkWidget *row, *networks, *w;
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autofree gchar *path = NULL;
|
2013-01-15 17:54:00 +01:00
|
|
|
|
|
|
|
path = g_find_program_in_path ("rygel");
|
|
|
|
if (path == NULL)
|
|
|
|
{
|
2020-05-11 13:49:28 +05:30
|
|
|
gtk_widget_hide (self->media_sharing_row);
|
2013-01-15 17:54:00 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (self->media_sharing_dialog, "response",
|
|
|
|
G_CALLBACK (cc_sharing_panel_media_sharing_dialog_response),
|
|
|
|
self, G_CONNECT_SWAPPED);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2014-06-20 10:07:46 +02:00
|
|
|
cc_media_sharing_get_preferences (&folders);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
|
|
|
list = folders;
|
|
|
|
while (list && *list)
|
|
|
|
{
|
2014-06-12 16:20:47 +02:00
|
|
|
row = cc_sharing_panel_new_media_sharing_row (*list, self);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_list_box_insert (GTK_LIST_BOX (self->shared_folders_listbox), row, -1);
|
2013-01-14 17:58:44 +00:00
|
|
|
list++;
|
|
|
|
}
|
|
|
|
|
2018-10-15 11:32:03 +13:00
|
|
|
row = cc_sharing_panel_new_add_media_sharing_row (self);
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_list_box_append (GTK_LIST_BOX (self->shared_folders_listbox), row);
|
2014-06-12 16:20:47 +02:00
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (self->shared_folders_listbox, "row-activated",
|
|
|
|
G_CALLBACK (cc_sharing_panel_add_folder), self, G_CONNECT_SWAPPED);
|
2014-06-12 16:20:47 +02:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
networks = cc_sharing_networks_new (self->sharing_proxy, "rygel");
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_grid_attach (GTK_GRID (self->shared_folders_grid), networks, 0, 4, 2, 1);
|
2014-06-20 10:07:46 +02:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
w = create_switch_with_bindings (GTK_SWITCH (g_object_get_data (G_OBJECT (networks), "switch")));
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (self->media_sharing_headerbar), w);
|
2018-06-01 09:30:39 +12:00
|
|
|
self->media_sharing_switch = w;
|
2014-06-20 10:07:46 +02:00
|
|
|
|
|
|
|
cc_sharing_panel_bind_networks_to_label (self, networks,
|
2020-05-11 13:49:28 +05:30
|
|
|
self->media_sharing_row);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2013-06-13 11:55:42 +01:00
|
|
|
static void
|
2016-03-24 16:23:25 +01:00
|
|
|
cc_sharing_panel_setup_label (CcSharingPanel *self,
|
|
|
|
GtkWidget *label,
|
|
|
|
const gchar *hostname)
|
2013-06-13 11:55:42 +01:00
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autofree gchar *text = NULL;
|
2013-10-03 10:38:16 +01:00
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
if (label == self->personal_file_sharing_label)
|
2019-12-16 11:04:50 +13:00
|
|
|
{
|
|
|
|
g_autofree gchar *url = g_strdup_printf ("<a href=\"dav://%s\">dav://%s</a>", hostname, hostname);
|
|
|
|
/* TRANSLATORS: %s is replaced with a link to a dav://<hostname> URL */
|
|
|
|
text = g_strdup_printf (_("File Sharing allows you to share your Public folder with others on your current network using: %s"), url);
|
|
|
|
}
|
2018-06-01 11:17:12 +12:00
|
|
|
else if (label == self->remote_login_label)
|
2019-12-16 11:04:50 +13:00
|
|
|
{
|
|
|
|
g_autofree gchar *command = g_strdup_printf ("<a href=\"ssh %s\">ssh %s</a>", hostname, hostname);
|
|
|
|
/* TRANSLATORS: %s is replaced with a link to a "ssh <hostname>" command to run */
|
|
|
|
text = g_strdup_printf (_("When remote login is enabled, remote users can connect using the Secure Shell command:\n%s"), command);
|
|
|
|
}
|
2018-06-01 11:17:12 +12:00
|
|
|
else if (label == self->screen_sharing_label)
|
2019-12-16 11:04:50 +13:00
|
|
|
{
|
|
|
|
g_autofree gchar *url = g_strdup_printf ("<a href=\"vnc://%s\">vnc://%s</a>", hostname, hostname);
|
|
|
|
/* TRANSLATORS: %s is replaced with a link to a vnc://<hostname> URL */
|
|
|
|
text = g_strdup_printf (_("Screen sharing allows remote users to view or control your screen by connecting to %s"), url);
|
|
|
|
}
|
2016-03-24 16:23:25 +01:00
|
|
|
else
|
|
|
|
g_assert_not_reached ();
|
2013-06-13 11:55:42 +01:00
|
|
|
|
2016-03-24 16:23:25 +01:00
|
|
|
gtk_label_set_label (GTK_LABEL (label), text);
|
2013-06-13 11:55:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
CcSharingPanel *panel;
|
|
|
|
GtkWidget *label;
|
|
|
|
} GetHostNameData;
|
|
|
|
|
2018-06-01 11:00:19 +12:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GetHostNameData, g_free);
|
|
|
|
|
2013-06-13 11:55:42 +01:00
|
|
|
static void
|
2018-06-01 11:00:19 +12:00
|
|
|
cc_sharing_panel_get_host_name_fqdn_done (GObject *object,
|
2013-06-13 11:55:42 +01:00
|
|
|
GAsyncResult *res,
|
2018-06-01 11:00:19 +12:00
|
|
|
gpointer user_data)
|
2013-06-13 11:55:42 +01:00
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
GDBusConnection *connection = G_DBUS_CONNECTION (object);
|
|
|
|
g_autoptr(GetHostNameData) data = user_data;
|
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
g_autoptr(GVariant) variant = NULL;
|
2013-06-13 11:55:42 +01:00
|
|
|
const gchar *fqdn;
|
|
|
|
|
|
|
|
variant = g_dbus_connection_call_finish (connection, res, &error);
|
|
|
|
|
|
|
|
if (variant == NULL)
|
|
|
|
{
|
|
|
|
/* Avahi service may not be available */
|
|
|
|
g_debug ("Error calling GetHostNameFqdn: %s", error->message);
|
|
|
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autofree gchar *hostname = NULL;
|
2013-06-13 11:55:42 +01:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
hostname = cc_hostname_entry_get_hostname (CC_HOSTNAME_ENTRY (data->panel->hostname_entry));
|
2013-06-13 11:55:42 +01:00
|
|
|
|
2016-03-24 16:23:25 +01:00
|
|
|
cc_sharing_panel_setup_label (data->panel, data->label, hostname);
|
2013-06-13 11:55:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_variant_get (variant, "(&s)", &fqdn);
|
|
|
|
|
2016-03-24 16:23:25 +01:00
|
|
|
cc_sharing_panel_setup_label (data->panel, data->label, fqdn);
|
2013-06-13 11:55:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_sharing_panel_bus_ready (GObject *object,
|
|
|
|
GAsyncResult *res,
|
2018-06-01 11:00:19 +12:00
|
|
|
gpointer user_data)
|
2013-06-13 11:55:42 +01:00
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autoptr(GDBusConnection) connection = NULL;
|
|
|
|
g_autoptr(GetHostNameData) data = user_data;
|
|
|
|
g_autoptr(GError) error = NULL;
|
2013-06-13 11:55:42 +01:00
|
|
|
|
|
|
|
connection = g_bus_get_finish (res, &error);
|
|
|
|
|
|
|
|
if (connection == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Could not connect to system bus: %s", error->message);
|
|
|
|
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
{
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autofree gchar *hostname = NULL;
|
2013-06-13 11:55:42 +01:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
hostname = cc_hostname_entry_get_hostname (CC_HOSTNAME_ENTRY (data->panel->hostname_entry));
|
2013-06-13 11:55:42 +01:00
|
|
|
|
2016-03-24 16:23:25 +01:00
|
|
|
cc_sharing_panel_setup_label (data->panel, data->label, hostname);
|
2013-06-13 11:55:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_dbus_connection_call (connection,
|
|
|
|
"org.freedesktop.Avahi",
|
|
|
|
"/",
|
|
|
|
"org.freedesktop.Avahi.Server",
|
|
|
|
"GetHostNameFqdn",
|
|
|
|
NULL,
|
|
|
|
(GVariantType*)"(s)",
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
-1,
|
2020-01-31 10:30:10 +13:00
|
|
|
cc_panel_get_cancellable (CC_PANEL (data->panel)),
|
2018-06-01 11:00:19 +12:00
|
|
|
cc_sharing_panel_get_host_name_fqdn_done,
|
2013-06-13 11:55:42 +01:00
|
|
|
data);
|
2018-06-01 11:00:19 +12:00
|
|
|
g_steal_pointer (&data);
|
2013-06-13 11:55:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_setup_label_with_hostname (CcSharingPanel *self,
|
|
|
|
GtkWidget *label)
|
2021-10-21 20:03:06 -03:00
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2013-06-13 11:55:42 +01:00
|
|
|
GetHostNameData *get_hostname_data;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2013-06-13 11:55:42 +01:00
|
|
|
/* set the hostname */
|
|
|
|
get_hostname_data = g_new (GetHostNameData, 1);
|
|
|
|
get_hostname_data->panel = self;
|
|
|
|
get_hostname_data->label = label;
|
2017-08-29 18:00:54 +02:00
|
|
|
g_bus_get (G_BUS_TYPE_SYSTEM,
|
2020-01-31 10:30:10 +13:00
|
|
|
cc_panel_get_cancellable (CC_PANEL (self)),
|
2018-06-01 11:00:19 +12:00
|
|
|
cc_sharing_panel_bus_ready,
|
2013-06-13 11:55:42 +01:00
|
|
|
get_hostname_data);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
file_sharing_get_require_password (GValue *value,
|
|
|
|
GVariant *variant,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (g_str_equal (g_variant_get_string (variant, NULL), "always"))
|
|
|
|
g_value_set_boolean (value, TRUE);
|
|
|
|
else
|
|
|
|
g_value_set_boolean (value, FALSE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
file_sharing_set_require_password (const GValue *value,
|
|
|
|
const GVariantType *type,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (g_value_get_boolean (value))
|
|
|
|
return g_variant_new_string ("always");
|
|
|
|
else
|
|
|
|
return g_variant_new_string ("never");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_sharing_password_changed (GtkEntry *entry)
|
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
file_share_write_out_password (gtk_editable_get_text (GTK_EDITABLE (entry)));
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_sharing_panel_setup_personal_file_sharing_dialog (CcSharingPanel *self)
|
|
|
|
{
|
|
|
|
GSettings *settings;
|
2018-06-01 11:17:12 +12:00
|
|
|
GtkWidget *networks, *w;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
cc_sharing_panel_bind_switch_to_widgets (self->personal_file_sharing_require_password_switch,
|
|
|
|
self->personal_file_sharing_password_entry,
|
|
|
|
self->personal_file_sharing_password_label,
|
2013-01-14 17:58:44 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
cc_sharing_panel_setup_label_with_hostname (self,
|
2018-06-01 11:17:12 +12:00
|
|
|
self->personal_file_sharing_label);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
|
|
|
/* the password cannot be read, so just make sure the entry is not empty */
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (self->personal_file_sharing_password_entry),
|
|
|
|
"password");
|
2013-01-14 17:58:44 +00:00
|
|
|
|
|
|
|
settings = g_settings_new (FILE_SHARING_SCHEMA_ID);
|
|
|
|
g_settings_bind_with_mapping (settings, "require-password",
|
2018-06-01 11:17:12 +12:00
|
|
|
self->personal_file_sharing_require_password_switch,
|
2013-01-14 17:58:44 +00:00
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT,
|
|
|
|
file_sharing_get_require_password,
|
|
|
|
file_sharing_set_require_password, NULL, NULL);
|
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
g_signal_connect (self->personal_file_sharing_password_entry,
|
2013-01-14 17:58:44 +00:00
|
|
|
"notify::text", G_CALLBACK (file_sharing_password_changed),
|
|
|
|
NULL);
|
2014-06-20 10:07:46 +02:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
networks = cc_sharing_networks_new (self->sharing_proxy, "gnome-user-share-webdav");
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_grid_attach (GTK_GRID (self->personal_file_sharing_grid), networks, 0, 3, 2, 1);
|
2014-06-20 10:07:46 +02:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
w = create_switch_with_bindings (GTK_SWITCH (g_object_get_data (G_OBJECT (networks), "switch")));
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (self->personal_file_sharing_headerbar), w);
|
2018-06-01 09:30:39 +12:00
|
|
|
self->personal_file_sharing_switch = w;
|
2014-06-20 10:07:46 +02:00
|
|
|
|
|
|
|
cc_sharing_panel_bind_networks_to_label (self,
|
|
|
|
networks,
|
2020-05-11 13:49:28 +05:30
|
|
|
self->personal_file_sharing_row);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
remote_login_switch_activate (CcSharingPanel *self)
|
2013-01-14 17:58:44 +00:00
|
|
|
{
|
2019-11-22 11:09:20 +13:00
|
|
|
cc_remote_login_set_enabled (cc_panel_get_cancellable (CC_PANEL (self)), GTK_SWITCH (self->remote_login_switch));
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_sharing_panel_setup_remote_login_dialog (CcSharingPanel *self)
|
|
|
|
{
|
2018-06-01 11:17:12 +12:00
|
|
|
cc_sharing_panel_bind_switch_to_label (self, self->remote_login_switch,
|
2020-05-11 13:49:28 +05:30
|
|
|
self->remote_login_row);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
cc_sharing_panel_setup_label_with_hostname (self, self->remote_login_label);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (self->remote_login_switch, "notify::active",
|
|
|
|
G_CALLBACK (remote_login_switch_activate), self, G_CONNECT_SWAPPED);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_set_sensitive (self->remote_login_switch, FALSE);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2020-01-31 10:30:10 +13:00
|
|
|
cc_remote_login_get_enabled (cc_panel_get_cancellable (CC_PANEL (self)),
|
2018-06-01 11:17:12 +12:00
|
|
|
GTK_SWITCH (self->remote_login_switch),
|
2020-05-11 13:49:28 +05:30
|
|
|
self->remote_login_row);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
cc_sharing_panel_check_schema_available (CcSharingPanel *self,
|
|
|
|
const gchar *schema_id)
|
|
|
|
{
|
2014-11-29 16:39:34 +01:00
|
|
|
GSettingsSchemaSource *source;
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autoptr(GSettingsSchema) schema = NULL;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2014-11-29 16:39:34 +01:00
|
|
|
source = g_settings_schema_source_get_default ();
|
|
|
|
if (!source)
|
2013-01-14 17:58:44 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2014-11-29 16:39:34 +01:00
|
|
|
schema = g_settings_schema_source_lookup (source, schema_id, TRUE);
|
|
|
|
if (!schema)
|
|
|
|
return FALSE;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2014-11-29 16:39:34 +01:00
|
|
|
return TRUE;
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 16:31:58 -03:00
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
screen_sharing_show_cb (CcSharingPanel *self)
|
2013-06-24 16:31:58 -03:00
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (self->show_password_checkbutton),
|
|
|
|
FALSE);
|
2013-06-24 16:31:58 -03:00
|
|
|
}
|
|
|
|
|
2013-07-29 12:34:25 -03:00
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
screen_sharing_hide_cb (CcSharingPanel *self)
|
2013-07-29 12:34:25 -03:00
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
GtkCheckButton *ac_radio;
|
2013-07-29 12:34:25 -03:00
|
|
|
GtkEntry *pw_entry;
|
|
|
|
const gchar *password;
|
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
ac_radio = GTK_CHECK_BUTTON (self->approve_connections_radiobutton);
|
2018-06-01 11:17:12 +12:00
|
|
|
pw_entry = GTK_ENTRY (self->remote_control_password_entry);
|
2021-10-21 20:03:06 -03:00
|
|
|
password = gtk_editable_get_text (GTK_EDITABLE (pw_entry));
|
2013-07-29 12:34:25 -03:00
|
|
|
|
|
|
|
if (password == NULL || *password == '\0')
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_check_button_set_active (ac_radio, TRUE);
|
2013-07-29 12:34:25 -03:00
|
|
|
}
|
|
|
|
|
2013-06-26 09:07:14 -03:00
|
|
|
#define MAX_PASSWORD_SIZE 8
|
|
|
|
static void
|
2019-11-22 11:09:20 +13:00
|
|
|
screen_sharing_password_insert_text_cb (CcSharingPanel *self,
|
|
|
|
gchar *new_text,
|
|
|
|
gint new_text_length,
|
|
|
|
gpointer position)
|
2013-06-26 09:07:14 -03:00
|
|
|
{
|
|
|
|
int l, available_size;
|
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
l = gtk_entry_buffer_get_bytes (gtk_entry_get_buffer (GTK_ENTRY (self->remote_control_password_entry)));
|
2013-06-26 09:07:14 -03:00
|
|
|
|
|
|
|
if (l + new_text_length <= MAX_PASSWORD_SIZE)
|
|
|
|
return;
|
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_stop_emission_by_name (self->remote_control_password_entry, "insert-text");
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (self->remote_control_password_entry));
|
2013-06-26 09:07:14 -03:00
|
|
|
|
|
|
|
available_size = g_utf8_strlen (new_text, MAX_PASSWORD_SIZE - l);
|
|
|
|
if (available_size == 0)
|
|
|
|
return;
|
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_handlers_block_by_func (self->remote_control_password_entry,
|
2013-06-26 09:07:14 -03:00
|
|
|
(gpointer) screen_sharing_password_insert_text_cb,
|
2019-11-22 11:09:20 +13:00
|
|
|
self);
|
|
|
|
gtk_editable_insert_text (GTK_EDITABLE (self->remote_control_password_entry), new_text, available_size, position);
|
|
|
|
g_signal_handlers_unblock_by_func (self->remote_control_password_entry,
|
2013-06-26 09:07:14 -03:00
|
|
|
(gpointer) screen_sharing_password_insert_text_cb,
|
2019-11-22 11:09:20 +13:00
|
|
|
self);
|
2013-06-26 09:07:14 -03:00
|
|
|
}
|
|
|
|
#undef MAX_PASSWORD_SIZE
|
|
|
|
|
2019-11-22 11:18:30 +13:00
|
|
|
static void
|
|
|
|
on_vnc_password_entry_notify_text (CcSharingPanel *self)
|
|
|
|
{
|
2021-10-21 20:03:06 -03:00
|
|
|
const char *password = gtk_editable_get_text (GTK_EDITABLE (self->remote_control_password_entry));
|
|
|
|
cc_grd_store_vnc_password (password, cc_panel_get_cancellable (CC_PANEL (self)));
|
2019-11-22 11:18:30 +13:00
|
|
|
}
|
|
|
|
|
2017-08-18 17:36:32 +08:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_setup_screen_sharing_dialog_gnome_remote_desktop (CcSharingPanel *self)
|
|
|
|
{
|
2019-11-22 11:18:30 +13:00
|
|
|
g_autofree gchar *password = NULL;
|
2018-02-14 20:52:37 +08:00
|
|
|
g_autoptr(GSettings) vnc_settings = NULL;
|
2017-08-18 17:36:32 +08:00
|
|
|
GtkWidget *networks, *w;
|
|
|
|
|
2018-02-14 20:52:37 +08:00
|
|
|
cc_sharing_panel_bind_switch_to_widgets (self->require_password_radiobutton, self->password_grid, NULL);
|
|
|
|
|
|
|
|
cc_sharing_panel_setup_label_with_hostname (self, self->screen_sharing_label);
|
|
|
|
|
|
|
|
g_object_bind_property (self->show_password_checkbutton,
|
|
|
|
"active",
|
|
|
|
self->remote_control_password_entry,
|
|
|
|
"visibility",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
|
|
|
|
/* make sure the password entry is hidden by default */
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (self->screen_sharing_dialog,
|
|
|
|
"show",
|
|
|
|
G_CALLBACK (screen_sharing_show_cb),
|
|
|
|
self,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
|
|
|
g_signal_connect_object (self->screen_sharing_dialog,
|
|
|
|
"hide",
|
|
|
|
G_CALLBACK (screen_sharing_hide_cb),
|
|
|
|
self,
|
|
|
|
G_CONNECT_SWAPPED);
|
2018-02-14 20:52:37 +08:00
|
|
|
|
2019-11-22 11:18:30 +13:00
|
|
|
password = cc_grd_lookup_vnc_password (cc_panel_get_cancellable (CC_PANEL (self)));
|
|
|
|
if (password != NULL)
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (self->remote_control_password_entry), password);
|
2020-02-11 19:10:15 +01:00
|
|
|
|
2018-02-14 20:52:37 +08:00
|
|
|
/* accept at most 8 bytes in password entry */
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (self->remote_control_password_entry,
|
|
|
|
"insert-text",
|
|
|
|
G_CALLBACK (screen_sharing_password_insert_text_cb),
|
|
|
|
self,
|
|
|
|
G_CONNECT_SWAPPED);
|
2018-02-14 20:52:37 +08:00
|
|
|
|
|
|
|
/* Bind settings to widgets */
|
|
|
|
vnc_settings = g_settings_new (GNOME_REMOTE_DESKTOP_VNC_SCHEMA_ID);
|
|
|
|
|
|
|
|
g_settings_bind (vnc_settings,
|
|
|
|
"view-only",
|
|
|
|
self->remote_control_checkbutton,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
|
|
|
|
|
|
|
|
g_settings_bind_with_mapping (vnc_settings,
|
|
|
|
"auth-method",
|
|
|
|
self->approve_connections_radiobutton,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT,
|
|
|
|
cc_grd_get_is_auth_method_prompt,
|
|
|
|
cc_grd_set_is_auth_method_prompt,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_settings_bind_with_mapping (vnc_settings,
|
|
|
|
"auth-method",
|
|
|
|
self->require_password_radiobutton,
|
|
|
|
"active",
|
|
|
|
G_SETTINGS_BIND_DEFAULT,
|
|
|
|
cc_grd_get_is_auth_method_password,
|
|
|
|
cc_grd_set_is_auth_method_password,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2019-11-22 11:18:30 +13:00
|
|
|
g_signal_connect_object (self->remote_control_password_entry,
|
|
|
|
"notify::text",
|
|
|
|
G_CALLBACK (on_vnc_password_entry_notify_text),
|
|
|
|
self,
|
|
|
|
G_CONNECT_SWAPPED);
|
2018-02-14 20:52:37 +08:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
networks = cc_sharing_networks_new (self->sharing_proxy, "gnome-remote-desktop");
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_box_append (GTK_BOX (self->remote_control_box), networks);
|
2017-08-18 17:36:32 +08:00
|
|
|
|
2021-10-21 20:03:06 -03:00
|
|
|
w = create_switch_with_bindings (GTK_SWITCH (g_object_get_data (G_OBJECT (networks), "switch")));
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (self->screen_sharing_headerbar), w);
|
2018-06-01 09:30:39 +12:00
|
|
|
self->screen_sharing_switch = w;
|
2017-08-18 17:36:32 +08:00
|
|
|
|
|
|
|
cc_sharing_panel_bind_networks_to_label (self, networks,
|
2020-05-11 13:49:28 +05:30
|
|
|
self->screen_sharing_row);
|
2017-08-29 17:52:52 +02:00
|
|
|
}
|
2017-08-18 17:36:32 +08:00
|
|
|
|
2017-08-29 17:52:52 +02:00
|
|
|
static void
|
|
|
|
remote_desktop_name_appeared (GDBusConnection *connection,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *name_owner,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
CcSharingPanel *self = CC_SHARING_PANEL (user_data);
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
g_bus_unwatch_name (self->remote_desktop_name_watch);
|
|
|
|
self->remote_desktop_name_watch = 0;
|
2017-08-29 17:52:52 +02:00
|
|
|
|
|
|
|
cc_sharing_panel_setup_screen_sharing_dialog_gnome_remote_desktop (self);
|
2020-05-11 13:49:28 +05:30
|
|
|
gtk_widget_show (self->screen_sharing_row);
|
2017-08-18 17:36:32 +08:00
|
|
|
}
|
|
|
|
|
2017-08-29 17:52:52 +02:00
|
|
|
static void
|
|
|
|
check_remote_desktop_available (CcSharingPanel *self)
|
2017-08-18 17:36:32 +08:00
|
|
|
{
|
|
|
|
if (!cc_sharing_panel_check_schema_available (self, GNOME_REMOTE_DESKTOP_SCHEMA_ID))
|
2017-08-29 17:52:52 +02:00
|
|
|
return;
|
2017-08-18 17:36:32 +08:00
|
|
|
|
2018-02-14 20:52:37 +08:00
|
|
|
if (!cc_sharing_panel_check_schema_available (self, GNOME_REMOTE_DESKTOP_VNC_SCHEMA_ID))
|
|
|
|
return;
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
self->remote_desktop_name_watch = g_bus_watch_name (G_BUS_TYPE_SESSION,
|
2017-08-29 17:52:52 +02:00
|
|
|
"org.gnome.Mutter.RemoteDesktop",
|
|
|
|
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
|
|
|
remote_desktop_name_appeared,
|
|
|
|
NULL,
|
|
|
|
self,
|
|
|
|
NULL);
|
|
|
|
}
|
2017-08-18 17:36:32 +08:00
|
|
|
|
2017-08-29 17:52:52 +02:00
|
|
|
static void
|
|
|
|
sharing_proxy_ready (GObject *source,
|
|
|
|
GAsyncResult *res,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
CcSharingPanel *self;
|
|
|
|
GDBusProxy *proxy;
|
2018-06-01 11:00:19 +12:00
|
|
|
g_autoptr(GError) error = NULL;
|
2017-08-29 17:52:52 +02:00
|
|
|
|
|
|
|
proxy = G_DBUS_PROXY (gsd_sharing_proxy_new_for_bus_finish (res, &error));
|
|
|
|
if (!proxy) {
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
g_warning ("Failed to get sharing proxy: %s", error->message);
|
|
|
|
return;
|
|
|
|
}
|
2017-08-18 17:36:32 +08:00
|
|
|
|
2017-08-29 17:52:52 +02:00
|
|
|
self = CC_SHARING_PANEL (user_data);
|
2018-06-01 09:30:39 +12:00
|
|
|
self->sharing_proxy = proxy;
|
2017-08-29 17:52:52 +02:00
|
|
|
|
|
|
|
/* media sharing */
|
|
|
|
cc_sharing_panel_setup_media_sharing_dialog (self);
|
|
|
|
|
|
|
|
/* personal file sharing */
|
|
|
|
if (cc_sharing_panel_check_schema_available (self, FILE_SHARING_SCHEMA_ID))
|
|
|
|
cc_sharing_panel_setup_personal_file_sharing_dialog (self);
|
|
|
|
else
|
2020-05-11 13:49:28 +05:30
|
|
|
gtk_widget_hide (self->personal_file_sharing_row);
|
2017-08-29 17:52:52 +02:00
|
|
|
|
|
|
|
/* remote login */
|
|
|
|
cc_sharing_panel_setup_remote_login_dialog (self);
|
2017-08-18 17:36:32 +08:00
|
|
|
|
2017-08-29 17:52:52 +02:00
|
|
|
/* screen sharing */
|
2020-06-16 10:48:23 +02:00
|
|
|
check_remote_desktop_available (self);
|
|
|
|
gtk_widget_hide (self->screen_sharing_row);
|
2017-08-18 17:36:32 +08:00
|
|
|
}
|
|
|
|
|
2013-01-14 17:58:44 +00:00
|
|
|
static void
|
|
|
|
cc_sharing_panel_init (CcSharingPanel *self)
|
|
|
|
{
|
2013-07-19 16:30:22 +03:00
|
|
|
GtkWidget *box;
|
2013-01-14 17:58:44 +00:00
|
|
|
|
|
|
|
g_resources_register (cc_sharing_get_resource ());
|
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (self->main_list_box, "row-activated",
|
|
|
|
G_CALLBACK (cc_sharing_panel_main_list_box_row_activated), self, G_CONNECT_SWAPPED);
|
2013-01-14 17:58:44 +00:00
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
g_signal_connect (self->media_sharing_dialog, "response",
|
2013-01-14 17:58:44 +00:00
|
|
|
G_CALLBACK (gtk_widget_hide), NULL);
|
2018-06-01 09:30:39 +12:00
|
|
|
g_signal_connect (self->personal_file_sharing_dialog, "response",
|
2013-01-14 17:58:44 +00:00
|
|
|
G_CALLBACK (gtk_widget_hide), NULL);
|
2018-06-01 09:30:39 +12:00
|
|
|
g_signal_connect (self->remote_login_dialog, "response",
|
2013-01-14 17:58:44 +00:00
|
|
|
G_CALLBACK (gtk_widget_hide), NULL);
|
2018-06-01 09:30:39 +12:00
|
|
|
g_signal_connect (self->screen_sharing_dialog, "response",
|
2013-01-14 17:58:44 +00:00
|
|
|
G_CALLBACK (gtk_widget_hide), NULL);
|
|
|
|
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (self->main_list_box),
|
2013-01-14 17:58:44 +00:00
|
|
|
TRUE);
|
|
|
|
|
2013-02-19 09:50:53 +00:00
|
|
|
/* create the master switch */
|
2013-07-19 16:30:22 +03:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
|
|
|
2018-06-01 09:30:39 +12:00
|
|
|
self->master_switch = gtk_switch_new ();
|
|
|
|
gtk_widget_set_valign (self->master_switch, GTK_ALIGN_CENTER);
|
2021-10-21 20:03:06 -03:00
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (self->master_switch),
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Sharing"),
|
|
|
|
-1);
|
|
|
|
gtk_box_append (GTK_BOX (box), self->master_switch);
|
2013-02-19 09:50:53 +00:00
|
|
|
|
|
|
|
/* start the panel in the disabled state */
|
2018-06-01 09:30:39 +12:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->master_switch), FALSE);
|
2018-06-01 11:17:12 +12:00
|
|
|
gtk_widget_set_sensitive (self->main_list_box, FALSE);
|
2019-11-22 11:09:20 +13:00
|
|
|
g_signal_connect_object (self->master_switch, "notify::active",
|
|
|
|
G_CALLBACK (cc_sharing_panel_master_switch_notify), self, G_CONNECT_SWAPPED);
|
2013-02-19 09:50:53 +00:00
|
|
|
|
2017-08-29 17:52:52 +02:00
|
|
|
gsd_sharing_proxy_new_for_bus (G_BUS_TYPE_SESSION,
|
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
"org.gnome.SettingsDaemon.Sharing",
|
|
|
|
"/org/gnome/SettingsDaemon/Sharing",
|
2020-01-31 10:30:10 +13:00
|
|
|
cc_panel_get_cancellable (CC_PANEL (self)),
|
2017-08-29 17:52:52 +02:00
|
|
|
sharing_proxy_ready,
|
|
|
|
self);
|
2013-01-29 16:23:17 +00:00
|
|
|
|
|
|
|
/* make sure the hostname entry isn't focused by default */
|
|
|
|
g_signal_connect_swapped (self, "map", G_CALLBACK (gtk_widget_grab_focus),
|
2018-06-01 11:17:12 +12:00
|
|
|
self->main_list_box);
|
2013-01-14 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CcSharingPanel *
|
|
|
|
cc_sharing_panel_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (CC_TYPE_SHARING_PANEL, NULL);
|
|
|
|
}
|