summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/caja-share-bar.c168
-rw-r--r--src/caja-share-bar.h6
-rw-r--r--src/file-share-properties.c17
-rw-r--r--src/http.c1
-rw-r--r--src/obexpush.c7
-rw-r--r--src/share-extension.c97
-rw-r--r--src/user_share-common.c2
-rw-r--r--src/user_share.c3
8 files changed, 89 insertions, 212 deletions
diff --git a/src/caja-share-bar.c b/src/caja-share-bar.c
index df2d6a7..c704d85 100644
--- a/src/caja-share-bar.c
+++ b/src/caja-share-bar.c
@@ -27,15 +27,11 @@
#include "caja-share-bar.h"
-static void caja_share_bar_finalize (GObject *object);
-
#define CAJA_SHARE_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CAJA_TYPE_SHARE_BAR, CajaShareBarPrivate))
struct CajaShareBarPrivate
{
- GtkWidget *button;
- GtkWidget *label;
- char *str;
+ GtkWidget *label;
};
enum {
@@ -43,26 +39,7 @@ enum {
PROP_LABEL
};
-enum {
- ACTIVATE,
- LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0, };
-
-G_DEFINE_TYPE (CajaShareBar, caja_share_bar, GTK_TYPE_HBOX)
-
-GtkWidget *
-caja_share_bar_get_button (CajaShareBar *bar)
-{
- GtkWidget *button;
-
- g_return_val_if_fail (bar != NULL, NULL);
-
- button = bar->priv->button;
-
- return button;
-}
+G_DEFINE_TYPE (CajaShareBar, caja_share_bar, GTK_TYPE_INFO_BAR)
static void
caja_share_bar_set_property (GObject *object,
@@ -76,11 +53,8 @@ caja_share_bar_set_property (GObject *object,
switch (prop_id) {
case PROP_LABEL: {
- char *str;
- g_free (self->priv->str);
- str = g_strdup_printf ("<i>%s</i>", g_value_get_string (value));
- gtk_label_set_markup (GTK_LABEL (self->priv->label), str);
- self->priv->str = g_value_dup_string (value);
+ gtk_label_set_text (GTK_LABEL (self->priv->label),
+ g_value_get_string (value));
break;
}
default:
@@ -90,126 +64,70 @@ caja_share_bar_set_property (GObject *object,
}
static void
-caja_share_bar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- CajaShareBar *self;
-
- self = CAJA_SHARE_BAR (object);
-
- switch (prop_id) {
- case PROP_LABEL:
- g_value_set_string (value, self->priv->str);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
caja_share_bar_class_init (CajaShareBarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = caja_share_bar_finalize;
- object_class->get_property = caja_share_bar_get_property;
object_class->set_property = caja_share_bar_set_property;
g_type_class_add_private (klass, sizeof (CajaShareBarPrivate));
- g_object_class_install_property (G_OBJECT_CLASS(klass),
- PROP_LABEL, g_param_spec_string ("label",
- "label", "The widget's main label", NULL, G_PARAM_READWRITE));
-
-
- signals [ACTIVATE] = g_signal_new ("activate",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CajaShareBarClass, activate),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
-}
-
-static void
-button_clicked_cb (GtkWidget *button,
- CajaShareBar *bar)
-{
- g_signal_emit (bar, signals [ACTIVATE], 0);
+ g_object_class_install_property (G_OBJECT_CLASS(klass), PROP_LABEL,
+ g_param_spec_string ("label", "label",
+ "The widget's main label",
+ NULL,
+ G_PARAM_WRITABLE));
}
static void
caja_share_bar_init (CajaShareBar *bar)
{
- GtkWidget *label;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *image;
- char *hint;
+ GtkWidget *content_area;
+ GtkWidget *action_area;
+ GtkWidget *label;
+ GtkWidget *vbox;
+ GtkWidget *button;
+ PangoAttrList *attrs;
- bar->priv = CAJA_SHARE_BAR_GET_PRIVATE (bar);
+ bar->priv = CAJA_SHARE_BAR_GET_PRIVATE (bar);
- hbox = GTK_WIDGET (bar);
+ content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (bar));
+ action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_CENTER);
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+ vbox = gtk_vbox_new (FALSE, 3);
+ gtk_container_add (GTK_CONTAINER (content_area), vbox);
- label = gtk_label_new (_("Personal File Sharing"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+ attrs = pango_attr_list_new ();
+ pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
+ label = gtk_label_new (_("Personal File Sharing"));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ pango_attr_list_unref (attrs);
- bar->priv->label = gtk_label_new ("");
- hint = g_strdup_printf ("<i>%s</i>", "");
- gtk_label_set_markup (GTK_LABEL (bar->priv->label), hint);
- gtk_misc_set_alignment (GTK_MISC (bar->priv->label), 0.0, 0.5);
- gtk_widget_show (bar->priv->label);
- gtk_box_pack_start (GTK_BOX (vbox), bar->priv->label, TRUE, TRUE, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (vbox), label);
- bar->priv->button = gtk_button_new_with_label (_("Launch Preferences"));
- gtk_widget_show (bar->priv->button);
- gtk_box_pack_end (GTK_BOX (hbox), bar->priv->button, FALSE, FALSE, 0);
+ bar->priv->label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (bar->priv->label), 0.0, 0.5);
+ gtk_widget_show (bar->priv->label);
+ gtk_container_add (GTK_CONTAINER (vbox), bar->priv->label);
- image = gtk_image_new_from_icon_name ("folder-remote", GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (image);
- gtk_button_set_image (GTK_BUTTON (bar->priv->button), image);
+ button = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
+ _("Preferences"),
+ CAJA_SHARE_BAR_RESPONSE_PREFERENCES);
- g_signal_connect (bar->priv->button, "clicked",
- G_CALLBACK (button_clicked_cb),
- bar);
+ gtk_widget_set_tooltip_text (button,
+ _("Launch Personal File Sharing Preferences"));
- gtk_widget_set_tooltip_text (bar->priv->button,
- _("Launch Personal File Sharing Preferences"));
-}
-
-static void
-caja_share_bar_finalize (GObject *object)
-{
- CajaShareBar *bar;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (CAJA_IS_SHARE_BAR (object));
-
- bar = CAJA_SHARE_BAR (object);
-
- g_return_if_fail (bar->priv != NULL);
-
- G_OBJECT_CLASS (caja_share_bar_parent_class)->finalize (object);
+ gtk_widget_show_all (vbox);
}
GtkWidget *
caja_share_bar_new (const char *label)
{
- GObject *result;
-
- result = g_object_new (CAJA_TYPE_SHARE_BAR,
- "label", label,
- NULL);
-
- return GTK_WIDGET (result);
+ return g_object_new (CAJA_TYPE_SHARE_BAR,
+ "message-type", GTK_MESSAGE_QUESTION,
+ "label", label,
+ NULL);
}
diff --git a/src/caja-share-bar.h b/src/caja-share-bar.h
index ae738fa..a4e05fd 100644
--- a/src/caja-share-bar.h
+++ b/src/caja-share-bar.h
@@ -34,18 +34,20 @@ G_BEGIN_DECLS
#define CAJA_IS_SHARE_BAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CAJA_TYPE_SHARE_BAR))
#define CAJA_SHARE_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CAJA_TYPE_SHARE_BAR, CajaShareBarClass))
+#define CAJA_SHARE_BAR_RESPONSE_PREFERENCES 1
+
typedef struct CajaShareBarPrivate CajaShareBarPrivate;
typedef struct
{
- GtkHBox box;
+ GtkInfoBar parent;
CajaShareBarPrivate *priv;
} CajaShareBar;
typedef struct
{
- GtkHBoxClass parent_class;
+ GtkInfoBarClass parent_class;
void (* activate) (CajaShareBar *bar);
diff --git a/src/file-share-properties.c b/src/file-share-properties.c
index a35296f..e2aae02 100644
--- a/src/file-share-properties.c
+++ b/src/file-share-properties.c
@@ -243,23 +243,8 @@ password_combo_changed (GtkComboBox *combo_box)
static void
launch_share (void)
{
- char *argv[2];
- int i;
-
- i = 0;
- argv[i++] = USER_SHARE_PROGRAM;
- argv[i++] = NULL;
-
- if (!g_spawn_async (NULL,
- argv,
- NULL,
- 0, /* G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL */
- NULL,
- NULL,
- NULL,
- NULL)) {
+ if (!g_spawn_command_line_async (USER_SHARE_PROGRAM, NULL))
g_warning ("Unable to start mate-user-share program");
- }
}
static void
diff --git a/src/http.c b/src/http.c
index 1dff01d..c07a202 100644
--- a/src/http.c
+++ b/src/http.c
@@ -79,6 +79,7 @@ get_port (void)
memset (&addr, 0, sizeof (addr));
addr.sin_port = 0;
addr.sin_addr.s_addr = INADDR_ANY;
+ addr.sin_family = AF_INET;
reuse = 1;
setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse));
diff --git a/src/obexpush.c b/src/obexpush.c
index 2ad1adb..e458e6b 100644
--- a/src/obexpush.c
+++ b/src/obexpush.c
@@ -81,15 +81,10 @@ notification_launch_action_on_file_cb (NotifyNotification *notification,
g_get_current_time (&val);
-#if GTK_CHECK_VERSION(2,14,0)
ctx = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
screen = gdk_screen_get_default ();
gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (ctx), screen);
gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (ctx), val.tv_sec);
-#else
- ctx = NULL;
- screen = NULL;
-#endif
/* We launch the file viewer for the file */
if (g_str_equal (action, "display") != FALSE) {
@@ -219,7 +214,7 @@ device_is_authorised (const char *bdaddr)
char *device_path;
GHashTable *props;
- g_message ("checking adapter %s", g_ptr_array_index (adapters, i));
+ g_debug ("checking adapter %s", (gchar *) g_ptr_array_index (adapters, i));
adapter = dbus_g_proxy_new_for_name (connection, "org.bluez",
g_ptr_array_index (adapters, i), "org.bluez.Adapter");
diff --git a/src/share-extension.c b/src/share-extension.c
index 83fb36f..188c559 100644
--- a/src/share-extension.c
+++ b/src/share-extension.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <bluetooth-client.h>
#include <libcaja-extension/caja-menu-provider.h>
#include <libcaja-extension/caja-location-widget-provider.h>
@@ -37,12 +38,9 @@
#define CAJA_USER_SHARE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CAJA_TYPE_USER_SHARE, CajaUserShare))
#define CAJA_IS_USER_SHARE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CAJA_TYPE_USER_SHARE))
-typedef struct _CajaUserSharePrivate CajaUserSharePrivate;
-
typedef struct
{
GObject parent_slot;
- CajaUserSharePrivate *priv;
} CajaUserShare;
typedef struct
@@ -50,19 +48,9 @@ typedef struct
GObjectClass parent_slot;
} CajaUserShareClass;
-#define CAJA_USER_SHARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CAJA_TYPE_USER_SHARE, CajaUserSharePrivate))
-
-struct _CajaUserSharePrivate
-{
- GSList *widget_list;
-};
-
static GType caja_user_share_get_type (void);
static void caja_user_share_register_type (GTypeModule *module);
-static GObjectClass *parent_class;
-
-
static void
launch_process (char **argv, GtkWindow *parent)
{
@@ -104,28 +92,34 @@ launch_prefs_on_window (GtkWindow *window)
}
static void
-bar_activated_cb (CajaShareBar *bar,
- gpointer data)
+bar_response_cb (CajaShareBar *bar,
+ gint response,
+ gpointer data)
{
- launch_prefs_on_window (GTK_WINDOW (data));
+ if (response == CAJA_SHARE_BAR_RESPONSE_PREFERENCES) {
+ launch_prefs_on_window (GTK_WINDOW (data));
+ }
}
static void
-destroyed_callback (GtkWidget *widget,
- CajaUserShare *share)
+downloads_bar_set_from_bluetooth_status (GtkWidget *bar)
{
- share->priv->widget_list = g_slist_remove (share->priv->widget_list, widget);
+ BluetoothClient *client;
+ gboolean bt_powered;
+
+ client = g_object_get_data (G_OBJECT (bar), "bluetooth-client");
+ g_object_get (G_OBJECT (client),
+ "default-adapter-powered", &bt_powered,
+ NULL);
+ gtk_widget_set_visible (bar, bt_powered);
}
static void
-add_widget (CajaUserShare *share,
- GtkWidget *widget)
+default_adapter_powered_cb (GObject *gobject,
+ GParamSpec *pspec,
+ GtkWidget *bar)
{
- share->priv->widget_list = g_slist_prepend (share->priv->widget_list, widget);
-
- g_signal_connect (widget, "destroy",
- G_CALLBACK (destroyed_callback),
- share);
+ downloads_bar_set_from_bluetooth_status (bar);
}
static GtkWidget *
@@ -135,7 +129,6 @@ caja_user_share_get_location_widget (CajaLocationWidgetProvider *iface,
{
GFile *file;
GtkWidget *bar;
- CajaUserShare *share;
guint i;
gboolean enable = FALSE;
GFile *home;
@@ -167,23 +160,28 @@ caja_user_share_get_location_widget (CajaLocationWidgetProvider *iface,
if (enable == FALSE)
return NULL;
- share = CAJA_USER_SHARE (iface);
-
if (is_dir[0] != FALSE && is_dir[1] != FALSE) {
- bar = caja_share_bar_new (_("You can share files from this folder and receive files to it"));
+ bar = caja_share_bar_new (_("May be used to share or receive files"));
} else if (is_dir[0] != FALSE) {
- bar = caja_share_bar_new (_("You can share files from this folder over the network and Bluetooth"));
+ bar = caja_share_bar_new (_("May be shared over the network or Bluetooth"));
} else {
- bar = caja_share_bar_new (_("You can receive files over Bluetooth into this folder"));
- }
+ BluetoothClient *client;
+
+ bar = caja_share_bar_new (_("May be used to receive files over Bluetooth"));
- add_widget (share, caja_share_bar_get_button (CAJA_SHARE_BAR (bar)));
+ gtk_widget_set_no_show_all (bar, TRUE);
+ client = bluetooth_client_new ();
+ g_object_set_data_full (G_OBJECT (bar), "bluetooth-client", client, g_object_unref);
+ g_signal_connect (G_OBJECT (client), "notify::default-adapter-powered",
+ G_CALLBACK (default_adapter_powered_cb), bar);
+ downloads_bar_set_from_bluetooth_status (bar);
+ }
- g_signal_connect (bar, "activate",
- G_CALLBACK (bar_activated_cb),
+ g_signal_connect (bar, "response",
+ G_CALLBACK (bar_response_cb),
window);
- gtk_widget_show (bar);
+ gtk_widget_show_all (bar);
g_object_unref (file);
@@ -199,38 +197,13 @@ caja_user_share_location_widget_provider_iface_init (CajaLocationWidgetProviderI
static void
caja_user_share_instance_init (CajaUserShare *share)
{
- share->priv = CAJA_USER_SHARE_GET_PRIVATE (share);
-}
-
-static void
-caja_user_share_finalize (GObject *object)
-{
- CajaUserShare *share;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (CAJA_IS_USER_SHARE (object));
-
- share = CAJA_USER_SHARE (object);
- g_return_if_fail (share->priv != NULL);
-
- if (share->priv->widget_list != NULL) {
- g_slist_free (share->priv->widget_list);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
caja_user_share_class_init (CajaUserShareClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = caja_user_share_finalize;
- g_type_class_add_private (klass, sizeof (CajaUserSharePrivate));
}
static GType share_type = 0;
diff --git a/src/user_share-common.c b/src/user_share-common.c
index aa0597d..c929f5d 100644
--- a/src/user_share-common.c
+++ b/src/user_share-common.c
@@ -22,6 +22,8 @@
*
*/
+#include <string.h>
+
#include "user_share-common.h"
static char *
diff --git a/src/user_share.c b/src/user_share.c
index e3a0e38..91e9d69 100644
--- a/src/user_share.c
+++ b/src/user_share.c
@@ -26,6 +26,7 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <bluetooth-client.h>
#include <X11/Xlib.h>
@@ -426,7 +427,7 @@ main (int argc, char **argv)
{
GSettings *settings;
Display *xdisplay;
- int x_fd;
+ G_GNUC_UNUSED x_fd;
Window selection_owner;
Atom xatom;