sharing: Add per-network sharing
Using the new D-Bus service from gnome-settings-daemon. https://bugzilla.gnome.org/show_bug.cgi?id=727580
This commit is contained in:
parent
e526257020
commit
cbeba7c6bf
13 changed files with 1106 additions and 197 deletions
|
@ -2,6 +2,7 @@
|
||||||
cappletname = sharing
|
cappletname = sharing
|
||||||
|
|
||||||
uidir = $(pkgdatadir)/ui/sharing
|
uidir = $(pkgdatadir)/ui/sharing
|
||||||
|
dbus_built_sources = org.gnome.SettingsDaemon.Sharing.c org.gnome.SettingsDaemon.Sharing.h
|
||||||
|
|
||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = \
|
||||||
$(PANEL_CFLAGS) \
|
$(PANEL_CFLAGS) \
|
||||||
|
@ -15,6 +16,7 @@ noinst_LTLIBRARIES = libsharing.la
|
||||||
BUILT_SOURCES = \
|
BUILT_SOURCES = \
|
||||||
cc-sharing-resources.c \
|
cc-sharing-resources.c \
|
||||||
cc-sharing-resources.h \
|
cc-sharing-resources.h \
|
||||||
|
$(dbus_built_sources) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libsharing_la_SOURCES = \
|
libsharing_la_SOURCES = \
|
||||||
|
@ -29,6 +31,11 @@ libsharing_la_SOURCES = \
|
||||||
vino-preferences.h \
|
vino-preferences.h \
|
||||||
file-share-properties.c \
|
file-share-properties.c \
|
||||||
file-share-properties.h \
|
file-share-properties.h \
|
||||||
|
cc-sharing-networks.c \
|
||||||
|
cc-sharing-networks.h \
|
||||||
|
cc-sharing-switch.c \
|
||||||
|
cc-sharing-switch.h \
|
||||||
|
gsd-sharing-enums.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +45,12 @@ cc-sharing-resources.c: sharing.gresource.xml $(resource_files)
|
||||||
cc-sharing-resources.h: sharing.gresource.xml $(resource_files)
|
cc-sharing-resources.h: sharing.gresource.xml $(resource_files)
|
||||||
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_sharing $<
|
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_sharing $<
|
||||||
|
|
||||||
|
$(dbus_built_sources) : Makefile.am org.gnome.SettingsDaemon.Sharing.xml
|
||||||
|
$(AM_V_GEN) gdbus-codegen \
|
||||||
|
--interface-prefix org.gnome.SettingsDaemon. \
|
||||||
|
--c-namespace Gsd \
|
||||||
|
--generate-c-code org.gnome.SettingsDaemon.Sharing \
|
||||||
|
$(srcdir)/org.gnome.SettingsDaemon.Sharing.xml
|
||||||
|
|
||||||
libsharing_la_LIBADD = $(PANEL_LIBS) $(SHARING_PANEL_LIBS) $(BLUETOOTH_LIBS)
|
libsharing_la_LIBADD = $(PANEL_LIBS) $(SHARING_PANEL_LIBS) $(BLUETOOTH_LIBS)
|
||||||
libsharing_la_LDFLAGS = $(PANEL_LDFLAGS)
|
libsharing_la_LDFLAGS = $(PANEL_LDFLAGS)
|
||||||
|
@ -63,6 +76,6 @@ desktop_in_files = gnome-sharing-panel.desktop.in
|
||||||
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
|
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
|
||||||
|
|
||||||
CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(polkit_policy_DATA) $(polkit_policy_in_files) $(BUILT_SOURCES)
|
CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(polkit_policy_DATA) $(polkit_policy_in_files) $(BUILT_SOURCES)
|
||||||
EXTRA_DIST = $(resource_files) sharing.gresource.xml org.gnome.controlcenter.remote-login-helper.policy.in.in
|
EXTRA_DIST = $(resource_files) sharing.gresource.xml org.gnome.controlcenter.remote-login-helper.policy.in.in org.gnome.SettingsDaemon.Sharing.xml
|
||||||
|
|
||||||
-include $(top_srcdir)/git.mk
|
-include $(top_srcdir)/git.mk
|
||||||
|
|
|
@ -25,11 +25,6 @@
|
||||||
#include <gio/gdesktopappinfo.h>
|
#include <gio/gdesktopappinfo.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#define BUS_NAME "org.gnome.Rygel1"
|
|
||||||
#define OBJECT_PATH "/org/gnome/Rygel1"
|
|
||||||
#define INTERFACE_NAME "org.gnome.Rygel1"
|
|
||||||
#define RYGEL_DESKTOP_ID "rygel.desktop"
|
|
||||||
|
|
||||||
static GKeyFile*
|
static GKeyFile*
|
||||||
cc_media_sharing_open_key_file (void)
|
cc_media_sharing_open_key_file (void)
|
||||||
{
|
{
|
||||||
|
@ -49,81 +44,13 @@ cc_media_sharing_open_key_file (void)
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
cc_media_sharing_enable_autostart (void)
|
|
||||||
{
|
|
||||||
const gchar *source;
|
|
||||||
gchar *destination;
|
|
||||||
GDesktopAppInfo *info;
|
|
||||||
GFile *file;
|
|
||||||
|
|
||||||
info = g_desktop_app_info_new (RYGEL_DESKTOP_ID);
|
|
||||||
if (!info)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* start rygel */
|
|
||||||
g_app_info_launch (G_APP_INFO (info), NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* create a symbolic link to the rygel desktop file in the autostart
|
|
||||||
* directory */
|
|
||||||
source = g_desktop_app_info_get_filename (info);
|
|
||||||
|
|
||||||
destination = g_build_filename (g_get_user_config_dir (), "autostart",
|
|
||||||
RYGEL_DESKTOP_ID, NULL);
|
|
||||||
file = g_file_new_for_path (destination);
|
|
||||||
g_free (destination);
|
|
||||||
|
|
||||||
g_file_make_symbolic_link (file, source, NULL, NULL);
|
|
||||||
|
|
||||||
g_object_unref (info);
|
|
||||||
g_object_unref (file);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cc_media_sharing_bus_ready_callback (GObject *object,
|
|
||||||
GAsyncResult *result,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GDBusConnection *connection;
|
|
||||||
|
|
||||||
connection = g_bus_get_finish (result, NULL);
|
|
||||||
|
|
||||||
if (!connection)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_dbus_connection_call (connection, BUS_NAME, OBJECT_PATH, INTERFACE_NAME,
|
|
||||||
"Shutdown", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cc_media_sharing_disable_autostart (void)
|
|
||||||
{
|
|
||||||
gchar *path;
|
|
||||||
|
|
||||||
path = g_build_filename (g_get_user_config_dir (), "autostart",
|
|
||||||
RYGEL_DESKTOP_ID, NULL);
|
|
||||||
|
|
||||||
g_unlink (path);
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
/* stop rygel */
|
|
||||||
g_bus_get (G_BUS_TYPE_SESSION, NULL, cc_media_sharing_bus_ready_callback,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_media_sharing_get_preferences (gboolean *enabled,
|
cc_media_sharing_get_preferences (gchar ***folders)
|
||||||
gchar ***folders)
|
|
||||||
{
|
{
|
||||||
GKeyFile *file;
|
GKeyFile *file;
|
||||||
|
|
||||||
file = cc_media_sharing_open_key_file ();
|
file = cc_media_sharing_open_key_file ();
|
||||||
|
|
||||||
if (enabled)
|
|
||||||
*enabled = (g_key_file_get_boolean (file, "general", "upnp-enabled", NULL) &&
|
|
||||||
g_key_file_get_boolean (file, "MediaExport", "enabled", NULL));
|
|
||||||
|
|
||||||
if (folders)
|
if (folders)
|
||||||
{
|
{
|
||||||
gsize length;
|
gsize length;
|
||||||
|
@ -161,8 +88,7 @@ cc_media_sharing_get_preferences (gboolean *enabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_media_sharing_set_preferences (gboolean enabled,
|
cc_media_sharing_set_preferences (gchar **folders)
|
||||||
gchar **folders)
|
|
||||||
{
|
{
|
||||||
GKeyFile *file;
|
GKeyFile *file;
|
||||||
gchar **str_list;
|
gchar **str_list;
|
||||||
|
@ -172,13 +98,8 @@ cc_media_sharing_set_preferences (gboolean enabled,
|
||||||
|
|
||||||
file = cc_media_sharing_open_key_file ();
|
file = cc_media_sharing_open_key_file ();
|
||||||
|
|
||||||
if (enabled)
|
g_key_file_set_boolean (file, "general", "upnp-enabled", TRUE);
|
||||||
cc_media_sharing_enable_autostart ();
|
g_key_file_set_boolean (file, "MediaExport", "enabled", TRUE);
|
||||||
else
|
|
||||||
cc_media_sharing_disable_autostart ();
|
|
||||||
|
|
||||||
g_key_file_set_boolean (file, "general", "upnp-enabled", enabled);
|
|
||||||
g_key_file_set_boolean (file, "MediaExport", "enabled", enabled);
|
|
||||||
|
|
||||||
str_list = folders;
|
str_list = folders;
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
void cc_media_sharing_get_preferences (gboolean *enabled, gchar ***folders);
|
void cc_media_sharing_get_preferences (gchar ***folders);
|
||||||
void cc_media_sharing_set_preferences (gboolean enabled, gchar **folders);
|
void cc_media_sharing_set_preferences (gchar **folders);
|
||||||
|
|
||||||
#endif /* __CC_MEDIA_SHARING_H__ */
|
#endif /* __CC_MEDIA_SHARING_H__ */
|
||||||
|
|
571
panels/sharing/cc-sharing-networks.c
Normal file
571
panels/sharing/cc-sharing-networks.c
Normal file
|
@ -0,0 +1,571 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Bastien Nocera <hadess@hadess.net>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include "cc-sharing-networks.h"
|
||||||
|
#include "org.gnome.SettingsDaemon.Sharing.h"
|
||||||
|
#include "gsd-sharing-enums.h"
|
||||||
|
|
||||||
|
struct _CcSharingNetworksPrivate {
|
||||||
|
GtkWidget *listbox;
|
||||||
|
GtkWidget *scrolledwindow;
|
||||||
|
|
||||||
|
GtkWidget *current_row;
|
||||||
|
GtkWidget *current_label;
|
||||||
|
GtkWidget *current_icon;
|
||||||
|
GtkWidget *current_switch;
|
||||||
|
|
||||||
|
GtkWidget *no_network_row;
|
||||||
|
|
||||||
|
char *service_name;
|
||||||
|
GsdSharing *proxy;
|
||||||
|
CcSharingStatus status;
|
||||||
|
|
||||||
|
GList *networks; /* list of CcSharingNetwork */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (CcSharingNetworks, cc_sharing_networks, GTK_TYPE_GRID,
|
||||||
|
G_ADD_PRIVATE (CcSharingNetworks))
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_PROXY,
|
||||||
|
PROP_SERVICE_NAME,
|
||||||
|
PROP_STATUS
|
||||||
|
};
|
||||||
|
|
||||||
|
static void cc_sharing_networks_class_init (CcSharingNetworksClass *klass);
|
||||||
|
static void cc_sharing_networks_init (CcSharingNetworks *self);
|
||||||
|
static void cc_sharing_networks_finalize (GObject *object);
|
||||||
|
|
||||||
|
static void cc_sharing_update_networks_box (CcSharingNetworks *self);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *network_name;
|
||||||
|
char *carrier_type;
|
||||||
|
} CcSharingNetwork;
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_network_free (gpointer data)
|
||||||
|
{
|
||||||
|
CcSharingNetwork *net = data;
|
||||||
|
|
||||||
|
g_free (net->network_name);
|
||||||
|
g_free (net->carrier_type);
|
||||||
|
g_free (net);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_update_status (CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
CcSharingStatus status;
|
||||||
|
|
||||||
|
if (self->priv->networks == NULL)
|
||||||
|
status = CC_SHARING_STATUS_OFF;
|
||||||
|
else if (gtk_widget_is_visible (self->priv->current_switch) &&
|
||||||
|
gtk_switch_get_active (GTK_SWITCH (self->priv->current_switch)))
|
||||||
|
status = CC_SHARING_STATUS_ACTIVE;
|
||||||
|
else
|
||||||
|
status = CC_SHARING_STATUS_ENABLED;
|
||||||
|
|
||||||
|
if (status != self->priv->status) {
|
||||||
|
self->priv->status = status;
|
||||||
|
g_object_notify (G_OBJECT (self), "status");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_panel_list_box_update_header (GtkListBoxRow *row,
|
||||||
|
GtkListBoxRow *before,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget *current;
|
||||||
|
|
||||||
|
if (before == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
current = gtk_list_box_row_get_header (row);
|
||||||
|
if (current == NULL)
|
||||||
|
{
|
||||||
|
current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
gtk_widget_show (current);
|
||||||
|
gtk_list_box_row_set_header (row, current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_update_networks (CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
GVariant *networks;
|
||||||
|
char *network_name, *carrier_type;
|
||||||
|
GVariantIter iter;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
g_list_free_full (self->priv->networks, cc_sharing_network_free);
|
||||||
|
self->priv->networks = NULL;
|
||||||
|
|
||||||
|
if (!gsd_sharing_call_list_networks_sync (self->priv->proxy, self->priv->service_name, &networks, NULL, &error)) {
|
||||||
|
g_warning ("couldn't list networks: %s", error->message);
|
||||||
|
g_dbus_proxy_set_cached_property (G_DBUS_PROXY (self->priv->proxy),
|
||||||
|
"SharingStatus",
|
||||||
|
g_variant_new_uint32 (GSD_SHARING_STATUS_OFFLINE));
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_variant_iter_init (&iter, networks);
|
||||||
|
while (g_variant_iter_next (&iter, "{ss}", &network_name, &carrier_type)) {
|
||||||
|
CcSharingNetwork *net;
|
||||||
|
|
||||||
|
net = g_new0 (CcSharingNetwork, 1);
|
||||||
|
net->network_name = network_name;
|
||||||
|
net->carrier_type = carrier_type;
|
||||||
|
self->priv->networks = g_list_prepend (self->priv->networks, net);
|
||||||
|
}
|
||||||
|
self->priv->networks = g_list_reverse (self->priv->networks);
|
||||||
|
|
||||||
|
g_variant_unref (networks);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_remove_network (GtkWidget *button,
|
||||||
|
CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
GtkWidget *row;
|
||||||
|
GError *error = NULL;
|
||||||
|
gboolean ret;
|
||||||
|
const char *network_name;
|
||||||
|
|
||||||
|
row = g_object_get_data (G_OBJECT (button), "row");
|
||||||
|
network_name = g_object_get_data (G_OBJECT (row), "network-name");
|
||||||
|
|
||||||
|
ret = gsd_sharing_call_disable_service_sync (self->priv->proxy,
|
||||||
|
self->priv->service_name,
|
||||||
|
network_name,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
if (!ret) {
|
||||||
|
g_warning ("Failed to remove service %s: %s",
|
||||||
|
self->priv->service_name, error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_sharing_update_networks (self);
|
||||||
|
cc_sharing_update_networks_box (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
cc_sharing_networks_enable_network (GtkSwitch *widget,
|
||||||
|
gboolean state,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
CcSharingNetworks *self = user_data;
|
||||||
|
GError *error = NULL;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
ret = gsd_sharing_call_enable_service_sync (self->priv->proxy,
|
||||||
|
self->priv->service_name,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
} else {
|
||||||
|
ret = gsd_sharing_call_disable_service_sync (self->priv->proxy,
|
||||||
|
self->priv->service_name,
|
||||||
|
gsd_sharing_get_current_network (self->priv->proxy),
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
gtk_switch_set_state (widget, state);
|
||||||
|
} else {
|
||||||
|
g_warning ("Failed to %s service %s: %s", state ? "enable" : "disable",
|
||||||
|
self->priv->service_name, error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
gtk_switch_set_active (widget, !state);
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_sharing_update_networks (self);
|
||||||
|
cc_sharing_networks_update_status (self);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
cc_sharing_networks_new_row (const char *network_name,
|
||||||
|
const char *carrier_type,
|
||||||
|
CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
GtkWidget *row, *box, *w;
|
||||||
|
const char *icon_name;
|
||||||
|
|
||||||
|
row = gtk_list_box_row_new ();
|
||||||
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
|
||||||
|
gtk_container_add (GTK_CONTAINER (row), box);
|
||||||
|
|
||||||
|
if (g_strcmp0 (carrier_type, "802-11-wireless") == 0) {
|
||||||
|
icon_name = "network-wireless-offline-symbolic";
|
||||||
|
} else if (g_strcmp0 (carrier_type, "802-3-ethernet") == 0) {
|
||||||
|
icon_name = "network-wired-disconnected-symbolic";
|
||||||
|
} else {
|
||||||
|
icon_name = "network-wired-symbolic";
|
||||||
|
}
|
||||||
|
|
||||||
|
w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_widget_set_margin_end (w, 12);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), w);
|
||||||
|
|
||||||
|
/* Label */
|
||||||
|
w = gtk_label_new (network_name);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), w);
|
||||||
|
|
||||||
|
/* Remove button */
|
||||||
|
w = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||||
|
gtk_button_set_relief (GTK_BUTTON (w), GTK_RELIEF_NONE);
|
||||||
|
gtk_widget_set_margin_top (w, 3);
|
||||||
|
gtk_widget_set_margin_bottom (w, 3);
|
||||||
|
gtk_widget_set_margin_end (w, 12);
|
||||||
|
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
|
||||||
|
gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
|
||||||
|
g_signal_connect (G_OBJECT (w), "clicked",
|
||||||
|
G_CALLBACK (cc_sharing_networks_remove_network), self);
|
||||||
|
g_object_set_data (G_OBJECT (w), "row", row);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (row), "network-name", g_strdup (network_name), g_free);
|
||||||
|
|
||||||
|
gtk_widget_show_all (row);
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
cc_sharing_networks_new_current_row (CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
GtkWidget *row, *box, *w;
|
||||||
|
|
||||||
|
row = gtk_list_box_row_new ();
|
||||||
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
|
||||||
|
gtk_container_add (GTK_CONTAINER (row), box);
|
||||||
|
|
||||||
|
/* Icon */
|
||||||
|
w = gtk_image_new_from_icon_name ("image-missing", GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_widget_set_margin_end (w, 12);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), w);
|
||||||
|
self->priv->current_icon = w;
|
||||||
|
|
||||||
|
/* Label */
|
||||||
|
w = gtk_label_new ("");
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), w);
|
||||||
|
self->priv->current_label = w;
|
||||||
|
|
||||||
|
w = gtk_switch_new ();
|
||||||
|
gtk_widget_set_margin_top (w, 3);
|
||||||
|
gtk_widget_set_margin_bottom (w, 3);
|
||||||
|
gtk_widget_set_margin_end (w, 12);
|
||||||
|
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
|
||||||
|
gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
|
||||||
|
g_signal_connect (G_OBJECT (w), "state-set",
|
||||||
|
G_CALLBACK (cc_sharing_networks_enable_network), self);
|
||||||
|
self->priv->current_switch = w;
|
||||||
|
g_object_set_data (G_OBJECT (w), "row", row);
|
||||||
|
|
||||||
|
gtk_widget_show_all (box);
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
cc_sharing_networks_new_no_network_row (CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
GtkWidget *row, *box, *w;
|
||||||
|
|
||||||
|
row = gtk_list_box_row_new ();
|
||||||
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
|
||||||
|
gtk_container_add (GTK_CONTAINER (row), box);
|
||||||
|
|
||||||
|
/* Label */
|
||||||
|
w = gtk_label_new (_("No networks selected for sharing"));
|
||||||
|
gtk_widget_set_hexpand (w, TRUE);
|
||||||
|
gtk_widget_set_halign (w, GTK_ALIGN_CENTER);
|
||||||
|
gtk_style_context_add_class (gtk_widget_get_style_context (w), "dim-label");
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), w);
|
||||||
|
|
||||||
|
gtk_widget_show_all (box);
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_update_networks_box (CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
gboolean current_visible;
|
||||||
|
const char *current_network;
|
||||||
|
GList *children, *l;
|
||||||
|
|
||||||
|
children = gtk_container_get_children (GTK_CONTAINER (self->priv->listbox));
|
||||||
|
for (l = children; l != NULL; l = l->next) {
|
||||||
|
GtkWidget *row = l->data;
|
||||||
|
|
||||||
|
if (row != self->priv->current_row &&
|
||||||
|
row != self->priv->no_network_row)
|
||||||
|
gtk_widget_destroy (row);
|
||||||
|
}
|
||||||
|
g_list_free (children);
|
||||||
|
|
||||||
|
current_network = gsd_sharing_get_current_network (self->priv->proxy);
|
||||||
|
|
||||||
|
if (current_network != NULL &&
|
||||||
|
!g_str_equal (current_network, "")) {
|
||||||
|
gboolean available;
|
||||||
|
const char *carrier_type, *icon_name;
|
||||||
|
|
||||||
|
gtk_widget_show (self->priv->current_row);
|
||||||
|
current_visible = TRUE;
|
||||||
|
|
||||||
|
/* Network name */
|
||||||
|
g_object_set_data_full (G_OBJECT (self->priv->current_row),
|
||||||
|
"network-name", g_strdup (current_network), g_free);
|
||||||
|
gtk_label_set_label (GTK_LABEL (self->priv->current_label), current_network);
|
||||||
|
|
||||||
|
/* Icon */
|
||||||
|
carrier_type = gsd_sharing_get_carrier_type (self->priv->proxy);
|
||||||
|
if (g_strcmp0 (carrier_type, "802-11-wireless") == 0) {
|
||||||
|
icon_name = "network-wireless-signal-excellent-symbolic";
|
||||||
|
} else if (g_strcmp0 (carrier_type, "802-3-ethernet") == 0) {
|
||||||
|
icon_name = "network-wired-symbolic";
|
||||||
|
} else {
|
||||||
|
icon_name = "network-wired-symbolic";
|
||||||
|
}
|
||||||
|
gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->current_icon), icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||||
|
|
||||||
|
/* State */
|
||||||
|
available = gsd_sharing_get_sharing_status (self->priv->proxy) == GSD_SHARING_STATUS_AVAILABLE;
|
||||||
|
gtk_widget_set_sensitive (self->priv->current_switch, available);
|
||||||
|
//FIXME add a subtitle explaining why it's disabled
|
||||||
|
} else {
|
||||||
|
gtk_widget_hide (self->priv->current_row);
|
||||||
|
current_visible = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (l = self->priv->networks; l != NULL; l = l->next) {
|
||||||
|
CcSharingNetwork *net = l->data;
|
||||||
|
GtkWidget *row;
|
||||||
|
|
||||||
|
if (g_strcmp0 (net->network_name, current_network) == 0) {
|
||||||
|
g_signal_handlers_block_by_func (self->priv->current_switch,
|
||||||
|
cc_sharing_networks_enable_network, self);
|
||||||
|
gtk_switch_set_state (GTK_SWITCH (self->priv->current_switch), TRUE);
|
||||||
|
g_signal_handlers_unblock_by_func (self->priv->current_switch,
|
||||||
|
cc_sharing_networks_enable_network, self);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
row = cc_sharing_networks_new_row (net->network_name,
|
||||||
|
net->carrier_type,
|
||||||
|
self);
|
||||||
|
gtk_list_box_insert (GTK_LIST_BOX (self->priv->listbox), row, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->priv->networks == NULL &&
|
||||||
|
!current_visible) {
|
||||||
|
gtk_widget_show (self->priv->no_network_row);
|
||||||
|
} else {
|
||||||
|
gtk_widget_hide (self->priv->no_network_row);
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_sharing_networks_update_status (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
current_network_changed (GObject *object,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
cc_sharing_update_networks (self);
|
||||||
|
cc_sharing_update_networks_box (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
CcSharingNetworks *self;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (cc_sharing_networks_parent_class)->constructed (object);
|
||||||
|
|
||||||
|
self = CC_SHARING_NETWORKS (object);
|
||||||
|
|
||||||
|
gtk_list_box_set_header_func (GTK_LIST_BOX (self->priv->listbox),
|
||||||
|
cc_sharing_panel_list_box_update_header, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
self->priv->current_row = cc_sharing_networks_new_current_row (self);
|
||||||
|
gtk_list_box_insert (GTK_LIST_BOX (self->priv->listbox), self->priv->current_row, -1);
|
||||||
|
g_object_set_data (G_OBJECT (self), "switch", self->priv->current_switch);
|
||||||
|
|
||||||
|
self->priv->no_network_row = cc_sharing_networks_new_no_network_row (self);
|
||||||
|
gtk_list_box_insert (GTK_LIST_BOX (self->priv->listbox), self->priv->no_network_row, -1);
|
||||||
|
|
||||||
|
cc_sharing_update_networks (self);
|
||||||
|
cc_sharing_update_networks_box (self);
|
||||||
|
|
||||||
|
g_signal_connect (self->priv->proxy, "notify::current-network",
|
||||||
|
G_CALLBACK (current_network_changed), self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_init (CcSharingNetworks *self)
|
||||||
|
{
|
||||||
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
self->priv = cc_sharing_networks_get_instance_private (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
cc_sharing_networks_new (GDBusProxy *proxy,
|
||||||
|
const char *service_name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GSD_IS_SHARING (proxy), NULL);
|
||||||
|
g_return_val_if_fail (service_name != NULL, NULL);
|
||||||
|
|
||||||
|
return GTK_WIDGET (g_object_new (CC_TYPE_SHARING_NETWORKS,
|
||||||
|
"proxy", proxy,
|
||||||
|
"service-name", service_name,
|
||||||
|
NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CcSharingNetworks *self;
|
||||||
|
|
||||||
|
self = CC_SHARING_NETWORKS (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_SERVICE_NAME:
|
||||||
|
self->priv->service_name = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
|
case PROP_PROXY:
|
||||||
|
self->priv->proxy = g_value_dup_object (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CcSharingNetworks *self;
|
||||||
|
|
||||||
|
self = CC_SHARING_NETWORKS (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_STATUS:
|
||||||
|
g_value_set_uint (value, self->priv->status);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
CcSharingNetworks *self;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (CC_IS_SHARING_NETWORKS (object));
|
||||||
|
|
||||||
|
self = CC_SHARING_NETWORKS (object);
|
||||||
|
|
||||||
|
g_return_if_fail (self->priv != NULL);
|
||||||
|
|
||||||
|
g_clear_object (&self->priv->proxy);
|
||||||
|
g_clear_pointer (&self->priv->service_name, g_free);
|
||||||
|
|
||||||
|
if (self->priv->networks != NULL) {
|
||||||
|
g_list_free_full (self->priv->networks, cc_sharing_network_free);
|
||||||
|
self->priv->networks = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (cc_sharing_networks_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_networks_class_init (CcSharingNetworksClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->set_property = cc_sharing_networks_set_property;
|
||||||
|
object_class->get_property = cc_sharing_networks_get_property;
|
||||||
|
object_class->finalize = cc_sharing_networks_finalize;
|
||||||
|
object_class->constructed = cc_sharing_networks_constructed;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_PROXY,
|
||||||
|
g_param_spec_object ("proxy",
|
||||||
|
"proxy",
|
||||||
|
"proxy",
|
||||||
|
GSD_TYPE_SHARING_PROXY,
|
||||||
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_SERVICE_NAME,
|
||||||
|
g_param_spec_string ("service-name",
|
||||||
|
"service-name",
|
||||||
|
"service-name",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_STATUS,
|
||||||
|
g_param_spec_uint ("status",
|
||||||
|
"status",
|
||||||
|
"status",
|
||||||
|
CC_SHARING_STATUS_UNSET, CC_SHARING_STATUS_ACTIVE + 1, CC_SHARING_STATUS_OFF,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
gtk_widget_class_set_template_from_resource (widget_class,
|
||||||
|
"/org/gnome/control-center/sharing/networks.ui");
|
||||||
|
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, CcSharingNetworks, scrolledwindow);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, CcSharingNetworks, listbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: sw=2 ts=8 cindent noai bs=2
|
||||||
|
*/
|
63
panels/sharing/cc-sharing-networks.h
Normal file
63
panels/sharing/cc-sharing-networks.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Bastien Nocera <hadess@hadess.net>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CC_SHARING_NETWORKS_H__
|
||||||
|
#define __CC_SHARING_NETWORKS_H__
|
||||||
|
|
||||||
|
#include <gtk/gtkgrid.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CC_TYPE_SHARING_NETWORKS (cc_sharing_networks_get_type ())
|
||||||
|
#define CC_SHARING_NETWORKS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_SHARING_NETWORKS, CcSharingNetworks))
|
||||||
|
#define CC_SHARING_NETWORKS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_SHARING_NETWORKS, CcSharingNetworksClass))
|
||||||
|
#define CC_IS_SHARING_NETWORKS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_SHARING_NETWORKS))
|
||||||
|
#define CC_IS_SHARING_NETWORKS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_SHARING_NETWORKS))
|
||||||
|
#define CC_SHARING_NETWORKS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_SHARING_NETWORKS, CcSharingNetworksClass))
|
||||||
|
|
||||||
|
typedef struct _CcSharingNetworks CcSharingNetworks;
|
||||||
|
typedef struct _CcSharingNetworksPrivate CcSharingNetworksPrivate;
|
||||||
|
typedef struct _CcSharingNetworksClass CcSharingNetworksClass;
|
||||||
|
|
||||||
|
struct _CcSharingNetworks
|
||||||
|
{
|
||||||
|
GtkGrid parent_instance;
|
||||||
|
|
||||||
|
CcSharingNetworksPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CcSharingNetworksClass
|
||||||
|
{
|
||||||
|
GtkGridClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CC_SHARING_STATUS_UNSET,
|
||||||
|
CC_SHARING_STATUS_OFF,
|
||||||
|
CC_SHARING_STATUS_ENABLED,
|
||||||
|
CC_SHARING_STATUS_ACTIVE
|
||||||
|
} CcSharingStatus;
|
||||||
|
|
||||||
|
GType cc_sharing_networks_get_type (void) G_GNUC_CONST;
|
||||||
|
GtkWidget * cc_sharing_networks_new (GDBusProxy *proxy,
|
||||||
|
const char *service_name);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __CC_SHARING_NETWORKS_H__ */
|
|
@ -27,6 +27,9 @@
|
||||||
#include "cc-remote-login.h"
|
#include "cc-remote-login.h"
|
||||||
#include "file-share-properties.h"
|
#include "file-share-properties.h"
|
||||||
#include "cc-media-sharing.h"
|
#include "cc-media-sharing.h"
|
||||||
|
#include "cc-sharing-networks.h"
|
||||||
|
#include "cc-sharing-switch.h"
|
||||||
|
#include "org.gnome.SettingsDaemon.Sharing.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -68,6 +71,12 @@ struct _CcSharingPanelPrivate
|
||||||
GtkWidget *master_switch;
|
GtkWidget *master_switch;
|
||||||
GtkWidget *hostname_entry;
|
GtkWidget *hostname_entry;
|
||||||
|
|
||||||
|
GDBusProxy *sharing_proxy;
|
||||||
|
|
||||||
|
GtkWidget *media_sharing_switch;
|
||||||
|
GtkWidget *personal_file_sharing_switch;
|
||||||
|
GtkWidget *screen_sharing_switch;
|
||||||
|
|
||||||
GtkWidget *bluetooth_sharing_dialog;
|
GtkWidget *bluetooth_sharing_dialog;
|
||||||
GtkWidget *media_sharing_dialog;
|
GtkWidget *media_sharing_dialog;
|
||||||
GtkWidget *personal_file_sharing_dialog;
|
GtkWidget *personal_file_sharing_dialog;
|
||||||
|
@ -79,6 +88,8 @@ struct _CcSharingPanelPrivate
|
||||||
GDBusProxy *rfkill;
|
GDBusProxy *rfkill;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define OFF_IF_VISIBLE(x) { if (gtk_widget_is_visible(x) && gtk_widget_is_sensitive(x)) gtk_switch_set_active (GTK_SWITCH(x), FALSE); }
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_sharing_panel_master_switch_notify (GtkSwitch *gtkswitch,
|
cc_sharing_panel_master_switch_notify (GtkSwitch *gtkswitch,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
|
@ -92,11 +103,11 @@ cc_sharing_panel_master_switch_notify (GtkSwitch *gtkswitch,
|
||||||
if (!active)
|
if (!active)
|
||||||
{
|
{
|
||||||
/* disable all services if the master switch is not active */
|
/* disable all services if the master switch is not active */
|
||||||
gtk_switch_set_active (GTK_SWITCH (WID ("remote-view-switch")), FALSE);
|
OFF_IF_VISIBLE(priv->media_sharing_switch);
|
||||||
|
OFF_IF_VISIBLE(priv->personal_file_sharing_switch);
|
||||||
|
OFF_IF_VISIBLE(priv->screen_sharing_switch);
|
||||||
|
|
||||||
gtk_switch_set_active (GTK_SWITCH (WID ("remote-login-switch")), FALSE);
|
gtk_switch_set_active (GTK_SWITCH (WID ("remote-login-switch")), FALSE);
|
||||||
gtk_switch_set_active (GTK_SWITCH (WID ("share-public-folder-on-network-switch")),
|
|
||||||
FALSE);
|
|
||||||
gtk_switch_set_active (GTK_SWITCH (WID ("share-media-switch")), FALSE);
|
|
||||||
gtk_switch_set_active (GTK_SWITCH (WID ("save-received-files-to-downloads-switch")),
|
gtk_switch_set_active (GTK_SWITCH (WID ("save-received-files-to-downloads-switch")),
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
|
@ -166,6 +177,8 @@ cc_sharing_panel_dispose (GObject *object)
|
||||||
priv->screen_sharing_dialog = NULL;
|
priv->screen_sharing_dialog = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (&priv->sharing_proxy);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_sharing_panel_parent_class)->dispose (object);
|
G_OBJECT_CLASS (cc_sharing_panel_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,6 +334,43 @@ cc_sharing_panel_switch_to_label_transform_func (GBinding *binding,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
gtk_switch_set_active (GTK_SWITCH (self->priv->master_switch), TRUE);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_sharing_panel_bind_switch_to_label (CcSharingPanel *self,
|
cc_sharing_panel_bind_switch_to_label (CcSharingPanel *self,
|
||||||
GtkWidget *gtkswitch,
|
GtkWidget *gtkswitch,
|
||||||
|
@ -332,6 +382,17 @@ cc_sharing_panel_bind_switch_to_label (CcSharingPanel *self,
|
||||||
NULL, self, NULL);
|
NULL, self, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_panel_bind_networks_to_label (CcSharingPanel *self,
|
||||||
|
GtkWidget *networks,
|
||||||
|
GtkWidget *label)
|
||||||
|
{
|
||||||
|
g_object_bind_property_full (networks, "status", label, "label",
|
||||||
|
G_BINDING_SYNC_CREATE,
|
||||||
|
(GBindingTransformFunc) cc_sharing_panel_networks_to_label_transform_func,
|
||||||
|
NULL, self, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_sharing_panel_bind_switch_to_widgets (GtkWidget *gtkswitch,
|
cc_sharing_panel_bind_switch_to_widgets (GtkWidget *gtkswitch,
|
||||||
GtkWidget *first_widget,
|
GtkWidget *first_widget,
|
||||||
|
@ -564,8 +625,7 @@ cc_sharing_panel_media_sharing_dialog_response (GtkDialog *dialog,
|
||||||
|
|
||||||
g_ptr_array_add (folders, NULL);
|
g_ptr_array_add (folders, NULL);
|
||||||
|
|
||||||
cc_media_sharing_set_preferences (gtk_switch_get_active (GTK_SWITCH (WID ("share-media-switch"))),
|
cc_media_sharing_set_preferences ((gchar **) folders->pdata);
|
||||||
(gchar **) folders->pdata);
|
|
||||||
|
|
||||||
g_ptr_array_free (folders, TRUE);
|
g_ptr_array_free (folders, TRUE);
|
||||||
}
|
}
|
||||||
|
@ -696,8 +756,7 @@ cc_sharing_panel_setup_media_sharing_dialog (CcSharingPanel *self)
|
||||||
{
|
{
|
||||||
CcSharingPanelPrivate *priv = self->priv;
|
CcSharingPanelPrivate *priv = self->priv;
|
||||||
gchar **folders, **list;
|
gchar **folders, **list;
|
||||||
gboolean enabled;
|
GtkWidget *box, *networks, *grid, *w;
|
||||||
GtkWidget *box;
|
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
path = g_find_program_in_path ("rygel");
|
path = g_find_program_in_path ("rygel");
|
||||||
|
@ -708,21 +767,11 @@ cc_sharing_panel_setup_media_sharing_dialog (CcSharingPanel *self)
|
||||||
}
|
}
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
|
||||||
cc_sharing_panel_bind_switch_to_label (self, WID ("share-media-switch"),
|
|
||||||
WID ("media-sharing-status-label"));
|
|
||||||
|
|
||||||
|
|
||||||
cc_sharing_panel_bind_switch_to_widgets (WID ("share-media-switch"),
|
|
||||||
WID ("shared-folders-box"),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_signal_connect (WID ("media-sharing-dialog"), "response",
|
g_signal_connect (WID ("media-sharing-dialog"), "response",
|
||||||
G_CALLBACK (cc_sharing_panel_media_sharing_dialog_response),
|
G_CALLBACK (cc_sharing_panel_media_sharing_dialog_response),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
cc_media_sharing_get_preferences (&enabled, &folders);
|
cc_media_sharing_get_preferences (&folders);
|
||||||
|
|
||||||
gtk_switch_set_active (GTK_SWITCH (WID ("share-media-switch")), enabled);
|
|
||||||
|
|
||||||
box = WID ("shared-folders-listbox");
|
box = WID ("shared-folders-listbox");
|
||||||
gtk_list_box_set_header_func (GTK_LIST_BOX (box),
|
gtk_list_box_set_header_func (GTK_LIST_BOX (box),
|
||||||
|
@ -749,6 +798,18 @@ cc_sharing_panel_setup_media_sharing_dialog (CcSharingPanel *self)
|
||||||
|
|
||||||
|
|
||||||
g_strfreev (folders);
|
g_strfreev (folders);
|
||||||
|
|
||||||
|
networks = cc_sharing_networks_new (self->priv->sharing_proxy, "rygel");
|
||||||
|
grid = WID ("grid4");
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), networks, 0, 4, 2, 1);
|
||||||
|
gtk_widget_show (networks);
|
||||||
|
|
||||||
|
w = cc_sharing_switch_new (networks);
|
||||||
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (WID ("media-sharing-headerbar")), w);
|
||||||
|
self->priv->media_sharing_switch = w;
|
||||||
|
|
||||||
|
cc_sharing_panel_bind_networks_to_label (self, networks,
|
||||||
|
WID ("media-sharing-status-label"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -964,15 +1025,7 @@ cc_sharing_panel_setup_personal_file_sharing_dialog (CcSharingPanel *self)
|
||||||
{
|
{
|
||||||
CcSharingPanelPrivate *priv = self->priv;
|
CcSharingPanelPrivate *priv = self->priv;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
|
GtkWidget *networks, *grid, *w;
|
||||||
|
|
||||||
cc_sharing_panel_bind_switch_to_label (self,
|
|
||||||
WID ("share-public-folder-on-network-switch"),
|
|
||||||
WID ("personal-file-sharing-status-label"));
|
|
||||||
|
|
||||||
cc_sharing_panel_bind_switch_to_widgets (WID ("share-public-folder-on-network-switch"),
|
|
||||||
WID ("require-password-grid"),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
cc_sharing_panel_bind_switch_to_widgets (WID ("personal-file-sharing-require-password-switch"),
|
cc_sharing_panel_bind_switch_to_widgets (WID ("personal-file-sharing-require-password-switch"),
|
||||||
WID ("personal-file-sharing-password-entry"),
|
WID ("personal-file-sharing-password-entry"),
|
||||||
|
@ -987,10 +1040,6 @@ cc_sharing_panel_setup_personal_file_sharing_dialog (CcSharingPanel *self)
|
||||||
"password");
|
"password");
|
||||||
|
|
||||||
settings = g_settings_new (FILE_SHARING_SCHEMA_ID);
|
settings = g_settings_new (FILE_SHARING_SCHEMA_ID);
|
||||||
g_settings_bind (settings, "enabled",
|
|
||||||
WID ("share-public-folder-on-network-switch"), "active",
|
|
||||||
G_SETTINGS_BIND_DEFAULT);
|
|
||||||
|
|
||||||
g_settings_bind_with_mapping (settings, "require-password",
|
g_settings_bind_with_mapping (settings, "require-password",
|
||||||
WID ("personal-file-sharing-require-password-switch"),
|
WID ("personal-file-sharing-require-password-switch"),
|
||||||
"active",
|
"active",
|
||||||
|
@ -1001,6 +1050,19 @@ cc_sharing_panel_setup_personal_file_sharing_dialog (CcSharingPanel *self)
|
||||||
g_signal_connect (WID ("personal-file-sharing-password-entry"),
|
g_signal_connect (WID ("personal-file-sharing-password-entry"),
|
||||||
"notify::text", G_CALLBACK (file_sharing_password_changed),
|
"notify::text", G_CALLBACK (file_sharing_password_changed),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
networks = cc_sharing_networks_new (self->priv->sharing_proxy, "gnome-user-share-webdav");
|
||||||
|
grid = WID ("grid2");
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), networks, 0, 3, 2, 1);
|
||||||
|
gtk_widget_show (networks);
|
||||||
|
|
||||||
|
w = cc_sharing_switch_new (networks);
|
||||||
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (WID ("personal-file-sharing-headerbar")), w);
|
||||||
|
self->priv->personal_file_sharing_switch = w;
|
||||||
|
|
||||||
|
cc_sharing_panel_bind_networks_to_label (self,
|
||||||
|
networks,
|
||||||
|
WID ("personal-file-sharing-status-label"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1114,13 +1176,7 @@ cc_sharing_panel_setup_screen_sharing_dialog (CcSharingPanel *self)
|
||||||
{
|
{
|
||||||
CcSharingPanelPrivate *priv = self->priv;
|
CcSharingPanelPrivate *priv = self->priv;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
|
GtkWidget *networks, *box, *w;
|
||||||
cc_sharing_panel_bind_switch_to_label (self, WID ("remote-view-switch"),
|
|
||||||
WID ("screen-sharing-status-label"));
|
|
||||||
|
|
||||||
cc_sharing_panel_bind_switch_to_widgets (WID ("remote-view-switch"),
|
|
||||||
WID ("remote-control-box"),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
cc_sharing_panel_bind_switch_to_widgets (WID ("require-password-radiobutton"),
|
cc_sharing_panel_bind_switch_to_widgets (WID ("require-password-radiobutton"),
|
||||||
WID ("password-grid"),
|
WID ("password-grid"),
|
||||||
|
@ -1131,8 +1187,6 @@ cc_sharing_panel_setup_screen_sharing_dialog (CcSharingPanel *self)
|
||||||
|
|
||||||
/* settings bindings */
|
/* settings bindings */
|
||||||
settings = g_settings_new (VINO_SCHEMA_ID);
|
settings = g_settings_new (VINO_SCHEMA_ID);
|
||||||
g_settings_bind (settings, "enabled", WID ("remote-view-switch"), "active",
|
|
||||||
G_SETTINGS_BIND_DEFAULT);
|
|
||||||
g_settings_bind (settings, "view-only", WID ("remote-control-switch"),
|
g_settings_bind (settings, "view-only", WID ("remote-control-switch"),
|
||||||
"active",
|
"active",
|
||||||
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
|
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
|
||||||
|
@ -1165,6 +1219,18 @@ cc_sharing_panel_setup_screen_sharing_dialog (CcSharingPanel *self)
|
||||||
/* accept at most 8 bytes in password entry */
|
/* accept at most 8 bytes in password entry */
|
||||||
g_signal_connect (WID ("remote-control-password-entry"), "insert-text",
|
g_signal_connect (WID ("remote-control-password-entry"), "insert-text",
|
||||||
G_CALLBACK (screen_sharing_password_insert_text_cb), self);
|
G_CALLBACK (screen_sharing_password_insert_text_cb), self);
|
||||||
|
|
||||||
|
networks = cc_sharing_networks_new (self->priv->sharing_proxy, "vino-server");
|
||||||
|
box = WID ("remote-control-box");
|
||||||
|
gtk_box_pack_end (GTK_BOX (box), networks, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show (networks);
|
||||||
|
|
||||||
|
w = cc_sharing_switch_new (networks);
|
||||||
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (WID ("screen-sharing-headerbar")), w);
|
||||||
|
self->priv->screen_sharing_switch = w;
|
||||||
|
|
||||||
|
cc_sharing_panel_bind_networks_to_label (self, networks,
|
||||||
|
WID ("screen-sharing-status-label"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1181,6 +1247,7 @@ cc_sharing_panel_init (CcSharingPanel *self)
|
||||||
"remote-login-dialog",
|
"remote-login-dialog",
|
||||||
"screen-sharing-dialog",
|
"screen-sharing-dialog",
|
||||||
NULL };
|
NULL };
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
g_resources_register (cc_sharing_get_resource ());
|
g_resources_register (cc_sharing_get_resource ());
|
||||||
|
|
||||||
|
@ -1240,6 +1307,16 @@ cc_sharing_panel_init (CcSharingPanel *self)
|
||||||
g_signal_connect (priv->master_switch, "notify::active",
|
g_signal_connect (priv->master_switch, "notify::active",
|
||||||
G_CALLBACK (cc_sharing_panel_master_switch_notify), self);
|
G_CALLBACK (cc_sharing_panel_master_switch_notify), self);
|
||||||
|
|
||||||
|
self->priv->sharing_proxy = G_DBUS_PROXY (gsd_sharing_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"org.gnome.SettingsDaemon.Sharing",
|
||||||
|
"/org/gnome/SettingsDaemon/Sharing",
|
||||||
|
NULL,
|
||||||
|
&error));
|
||||||
|
if (!self->priv->sharing_proxy) {
|
||||||
|
g_warning ("Failed to get sharing proxy: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
/* bluetooth */
|
/* bluetooth */
|
||||||
if (cc_sharing_panel_check_schema_available (self, FILE_SHARING_SCHEMA_ID))
|
if (cc_sharing_panel_check_schema_available (self, FILE_SHARING_SCHEMA_ID))
|
||||||
|
|
135
panels/sharing/cc-sharing-switch.c
Normal file
135
panels/sharing/cc-sharing-switch.c
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Bastien Nocera <hadess@hadess.net>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include "cc-sharing-switch.h"
|
||||||
|
|
||||||
|
struct _CcSharingSwitchPrivate {
|
||||||
|
GtkWidget *widget;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (CcSharingSwitch, cc_sharing_switch, GTK_TYPE_SWITCH,
|
||||||
|
G_ADD_PRIVATE (CcSharingSwitch))
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_WIDGET
|
||||||
|
};
|
||||||
|
|
||||||
|
static void cc_sharing_switch_class_init (CcSharingSwitchClass *klass);
|
||||||
|
static void cc_sharing_switch_init (CcSharingSwitch *self);
|
||||||
|
static void cc_sharing_switch_finalize (GObject *object);
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_switch_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
CcSharingSwitch *self;
|
||||||
|
GtkWidget *other_sw;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (cc_sharing_switch_parent_class)->constructed (object);
|
||||||
|
|
||||||
|
self = CC_SHARING_SWITCH (object);
|
||||||
|
|
||||||
|
other_sw = g_object_get_data (G_OBJECT (self->priv->widget), "switch");
|
||||||
|
|
||||||
|
g_object_bind_property (other_sw, "visible", self, "visible", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||||
|
g_object_bind_property (other_sw, "state", self, "state", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||||
|
g_object_bind_property (other_sw, "active", self, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||||
|
g_object_bind_property (other_sw, "sensitive", self, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||||
|
|
||||||
|
gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_switch_init (CcSharingSwitch *self)
|
||||||
|
{
|
||||||
|
self->priv = cc_sharing_switch_get_instance_private (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
cc_sharing_switch_new (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (widget != NULL, NULL);
|
||||||
|
|
||||||
|
return GTK_WIDGET (g_object_new (CC_TYPE_SHARING_SWITCH,
|
||||||
|
"widget", widget,
|
||||||
|
NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_switch_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
CcSharingSwitch *self;
|
||||||
|
|
||||||
|
self = CC_SHARING_SWITCH (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_WIDGET:
|
||||||
|
self->priv->widget = g_value_dup_object (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_switch_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
CcSharingSwitch *self;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (CC_IS_SHARING_SWITCH (object));
|
||||||
|
|
||||||
|
self = CC_SHARING_SWITCH (object);
|
||||||
|
|
||||||
|
g_return_if_fail (self->priv != NULL);
|
||||||
|
|
||||||
|
g_clear_object (&self->priv->widget);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (cc_sharing_switch_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cc_sharing_switch_class_init (CcSharingSwitchClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->set_property = cc_sharing_switch_set_property;
|
||||||
|
object_class->finalize = cc_sharing_switch_finalize;
|
||||||
|
object_class->constructed = cc_sharing_switch_constructed;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_WIDGET,
|
||||||
|
g_param_spec_object ("widget",
|
||||||
|
"widget",
|
||||||
|
"widget",
|
||||||
|
GTK_TYPE_WIDGET,
|
||||||
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: sw=2 ts=8 cindent noai bs=2
|
||||||
|
*/
|
55
panels/sharing/cc-sharing-switch.h
Normal file
55
panels/sharing/cc-sharing-switch.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Bastien Nocera <hadess@hadess.net>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CC_SHARING_SWITCH_H__
|
||||||
|
#define __CC_SHARING_SWITCH_H__
|
||||||
|
|
||||||
|
#include <gtk/gtkswitch.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CC_TYPE_SHARING_SWITCH (cc_sharing_switch_get_type ())
|
||||||
|
#define CC_SHARING_SWITCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_SHARING_SWITCH, CcSharingSwitch))
|
||||||
|
#define CC_SHARING_SWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_SHARING_SWITCH, CcSharingSwitchClass))
|
||||||
|
#define CC_IS_SHARING_SWITCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_SHARING_SWITCH))
|
||||||
|
#define CC_IS_SHARING_SWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_SHARING_SWITCH))
|
||||||
|
#define CC_SHARING_SWITCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_SHARING_SWITCH, CcSharingSwitchClass))
|
||||||
|
|
||||||
|
typedef struct _CcSharingSwitch CcSharingSwitch;
|
||||||
|
typedef struct _CcSharingSwitchPrivate CcSharingSwitchPrivate;
|
||||||
|
typedef struct _CcSharingSwitchClass CcSharingSwitchClass;
|
||||||
|
|
||||||
|
struct _CcSharingSwitch
|
||||||
|
{
|
||||||
|
GtkSwitch parent_instance;
|
||||||
|
|
||||||
|
CcSharingSwitchPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CcSharingSwitchClass
|
||||||
|
{
|
||||||
|
GtkSwitchClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType cc_sharing_switch_get_type (void) G_GNUC_CONST;
|
||||||
|
GtkWidget * cc_sharing_switch_new (GtkWidget *widget);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __CC_SHARING_SWITCH_H__ */
|
34
panels/sharing/gsd-sharing-enums.h
Normal file
34
panels/sharing/gsd-sharing-enums.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Bastien Nocera <hadess@hadess.net>
|
||||||
|
*
|
||||||
|
* 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GSD_SHARING_ENUMS_H
|
||||||
|
#define __GSD_SHARING_ENUMS_H
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GSD_SHARING_STATUS_OFFLINE,
|
||||||
|
GSD_SHARING_STATUS_DISABLED_MOBILE_BROADBAND,
|
||||||
|
GSD_SHARING_STATUS_DISABLED_LOW_SECURITY,
|
||||||
|
GSD_SHARING_STATUS_AVAILABLE
|
||||||
|
} GsdSharingStatus;
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GSD_SHARING_ENUMS_H */
|
68
panels/sharing/networks.ui
Normal file
68
panels/sharing/networks.ui
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.18.1 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.10"/>
|
||||||
|
<template class="CcSharingNetworks" parent="GtkGrid">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_start">12</property>
|
||||||
|
<property name="margin_end">6</property>
|
||||||
|
<property name="margin_top">12</property>
|
||||||
|
<property name="margin_bottom">12</property>
|
||||||
|
<property name="row_spacing">12</property>
|
||||||
|
<property name="column_spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label15">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Networks</property>
|
||||||
|
<property name="mnemonic_widget">scrolledwindow</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="shared-networks-box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScrolledWindow" id="scrolledwindow">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<property name="shadow_type">in</property>
|
||||||
|
<property name="vscrollbar-policy">never</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBox" id="listbox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
18
panels/sharing/org.gnome.SettingsDaemon.Sharing.xml
Normal file
18
panels/sharing/org.gnome.SettingsDaemon.Sharing.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<node name="/org/gnome/SettingsDaemon/Sharing">
|
||||||
|
<interface name='org.gnome.SettingsDaemon.Sharing'>
|
||||||
|
<property name='CurrentNetwork' type='s' access='read'/>
|
||||||
|
<property name='CarrierType' type='s' access='read'/>
|
||||||
|
<property name='SharingStatus' type='u' access='read'/>
|
||||||
|
<method name='EnableService'>
|
||||||
|
<arg name='service_name' direction='in' type='s'/>
|
||||||
|
</method>
|
||||||
|
<method name='DisableService'>
|
||||||
|
<arg name='service_name' direction='in' type='s'/>
|
||||||
|
<arg name='network' direction='in' type='s'/>
|
||||||
|
</method>
|
||||||
|
<method name='ListNetworks'>
|
||||||
|
<arg name='service_name' direction='in' type='s'/>
|
||||||
|
<arg name='networks' direction='out' type='a{ss}'/>
|
||||||
|
</method>
|
||||||
|
</interface>
|
||||||
|
</node>
|
|
@ -2,5 +2,6 @@
|
||||||
<gresources>
|
<gresources>
|
||||||
<gresource prefix="/org/gnome/control-center/sharing">
|
<gresource prefix="/org/gnome/control-center/sharing">
|
||||||
<file preprocess="xml-stripblanks">sharing.ui</file>
|
<file preprocess="xml-stripblanks">sharing.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">networks.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|
|
@ -419,38 +419,6 @@
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkSwitch" id="share-public-folder-on-network-switch">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="label16">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="label" translatable="yes">Share Public Folder On This Network</property>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="weight" value="bold"/>
|
|
||||||
</attributes>
|
|
||||||
<property name="mnemonic_widget">share-public-folder-on-network-switch</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="require-password-grid">
|
<object class="GtkGrid" id="require-password-grid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -536,6 +504,17 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="titlebar">
|
||||||
|
<object class="GtkHeaderBar" id="personal-file-sharing-headerbar">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="title" translatable="yes">Personal File Sharing</property>
|
||||||
|
<property name="show_close_button">True</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkDialog" id="remote-login-dialog">
|
<object class="GtkDialog" id="remote-login-dialog">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -673,35 +652,6 @@
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkSwitch" id="remote-view-switch">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="label20">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="label" translatable="yes">Screen Sharing</property>
|
|
||||||
<property name="mnemonic_widget">remote-view-switch</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="remote-control-box">
|
<object class="GtkBox" id="remote-control-box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -898,6 +848,17 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="titlebar">
|
||||||
|
<object class="GtkHeaderBar" id="screen-sharing-headerbar">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="title" translatable="yes">Screen Sharing</property>
|
||||||
|
<property name="show_close_button">True</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkDialog" id="media-sharing-dialog">
|
<object class="GtkDialog" id="media-sharing-dialog">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -1006,19 +967,11 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="titlebar">
|
<child type="titlebar">
|
||||||
<object class="GtkHeaderBar" id="headerbar1">
|
<object class="GtkHeaderBar" id="media-sharing-headerbar">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title">Media Sharing</property>
|
<property name="title">Media Sharing</property>
|
||||||
<property name="show_close_button">True</property>
|
<property name="show_close_button">True</property>
|
||||||
<child>
|
|
||||||
<object class="GtkSwitch" id="share-media-switch">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue