summaryrefslogtreecommitdiff
path: root/drivemount
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-19 20:39:10 +0100
committerStefano Karapetsas <[email protected]>2014-01-19 20:39:10 +0100
commit406473f25e5282340bfc1a0057561f1f3922b08a (patch)
treec01eee312a5ffd73bbf1015e59ca4b0653a1f67a /drivemount
parentc2ef8063f9353b4e9fa315a35ce47f7bc7fefe53 (diff)
downloadmate-applets-406473f25e5282340bfc1a0057561f1f3922b08a.tar.bz2
mate-applets-406473f25e5282340bfc1a0057561f1f3922b08a.tar.xz
drivemount: Add GTK3 support
Diffstat (limited to 'drivemount')
-rw-r--r--drivemount/drive-button.c77
-rw-r--r--drivemount/drive-list.c17
-rw-r--r--drivemount/drivemount.c4
3 files changed, 97 insertions, 1 deletions
diff --git a/drivemount/drive-button.c b/drivemount/drive-button.c
index bd738fb5..1ff9c7cb 100644
--- a/drivemount/drive-button.c
+++ b/drivemount/drive-button.c
@@ -29,6 +29,10 @@
#include "drive-button.h"
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gio/gdesktopappinfo.h>
+#include <gdk/gdkkeysyms-compat.h>
+#endif
#include <string.h>
@@ -49,7 +53,11 @@ static void drive_button_set_mount (DriveButton *self,
static void drive_button_reset_popup (DriveButton *self);
static void drive_button_ensure_popup (DriveButton *self);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void drive_button_dispose (GObject *object);
+#else
static void drive_button_destroy (GtkObject *object);
+#endif
#if 0
static void drive_button_unrealize (GtkWidget *widget);
#endif /* 0 */
@@ -63,7 +71,11 @@ static void drive_button_theme_change (GtkIconTheme *icon_theme,
static void
drive_button_class_init (DriveButtonClass *class)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ G_OBJECT_CLASS(class)->dispose = drive_button_dispose;
+#else
GTK_OBJECT_CLASS(class)->destroy = drive_button_destroy;
+#endif
GTK_WIDGET_CLASS(class)->button_press_event = drive_button_button_press;
GTK_WIDGET_CLASS(class)->key_press_event = drive_button_key_press;
@@ -130,7 +142,11 @@ drive_button_new_from_mount (GMount *mount)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+drive_button_dispose (GObject *object)
+#else
drive_button_destroy (GtkObject *object)
+#endif
{
DriveButton *self = DRIVE_BUTTON (object);
@@ -142,8 +158,13 @@ drive_button_destroy (GtkObject *object)
drive_button_reset_popup (self);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (G_OBJECT_CLASS (drive_button_parent_class)->dispose)
+ (* G_OBJECT_CLASS (drive_button_parent_class)->dispose) (object);
+#else
if (GTK_OBJECT_CLASS (drive_button_parent_class)->destroy)
(* GTK_OBJECT_CLASS (drive_button_parent_class)->destroy) (object);
+#endif
}
#if 0
@@ -455,7 +476,11 @@ static void
drive_button_reset_popup (DriveButton *self)
{
if (self->popup_menu)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_destroy (GTK_WIDGET (self->popup_menu));
+#else
gtk_object_destroy (GTK_OBJECT (self->popup_menu));
+#endif
self->popup_menu = NULL;
}
@@ -516,49 +541,99 @@ open_drive (DriveButton *self, GtkWidget *item)
GdkScreen *screen;
GtkWidget *dialog;
GError *error = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GFile *file = NULL;
+ GList *files = NULL;
+ GdkAppLaunchContext *launch_context;
+ GDesktopAppInfo *app_info;
+#else
char *argv[3] = { "caja", NULL, NULL };
screen = gtk_widget_get_screen (GTK_WIDGET (self));
+#endif
if (self->volume) {
GMount *mount;
mount = g_volume_get_mount (self->volume);
if (mount) {
+#if !GTK_CHECK_VERSION (3, 0, 0)
GFile *file;
+#endif
file = g_mount_get_root (mount);
+#if !GTK_CHECK_VERSION (3, 0, 0)
argv[1] = g_file_get_uri (file);
g_object_unref(file);
+#endif
g_object_unref(mount);
}
} else if (self->mount) {
+#if !GTK_CHECK_VERSION (3, 0, 0)
GFile *file;
+#endif
file = g_mount_get_root (self->mount);
+#if !GTK_CHECK_VERSION (3, 0, 0)
argv[1] = g_file_get_uri (file);
g_object_unref(file);
+#endif
} else
g_return_if_reached();
+#if GTK_CHECK_VERSION (3, 0, 0)
+ app_info = g_desktop_app_info_new ("caja.desktop");
+
+ if (app_info) {
+ launch_context = gdk_app_launch_context_new ();
+ screen = gtk_widget_get_screen (GTK_WIDGET (self));
+ gdk_app_launch_context_set_screen (launch_context, screen);
+ files = g_list_prepend (files, file);
+ g_app_info_launch (G_APP_INFO (app_info),
+ files,
+ G_APP_LAUNCH_CONTEXT (launch_context),
+ &error);
+
+ g_object_unref (launch_context);
+ g_list_free (files);
+ }
+
+ if (!app_info || error) {
+#else
if (!gdk_spawn_on_screen (screen, NULL, argv, NULL,
G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &error)) {
+#endif
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ _("Cannot execute Caja"));
+#else
_("Cannot execute '%s'"),
argv[0]);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), error->message, NULL);
+#endif
+ if (error)
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), error->message, NULL);
+ else
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "Could not find Caja", NULL);
g_signal_connect (dialog, "response",
+#if GTK_CHECK_VERSION (3, 0, 0)
+ G_CALLBACK (gtk_widget_destroy), NULL);
+#else
G_CALLBACK (gtk_object_destroy), NULL);
+#endif
gtk_widget_show (dialog);
g_error_free (error);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_object_unref(file);
+#else
g_free (argv[1]);
+#endif
}
/* copied from mate-volume-manager/src/manager.c maybe there is a better way than
diff --git a/drivemount/drive-list.c b/drivemount/drive-list.c
index 03dbd8d2..26163160 100644
--- a/drivemount/drive-list.c
+++ b/drivemount/drive-list.c
@@ -35,7 +35,11 @@ G_DEFINE_TYPE (DriveList, drive_list, GTK_TYPE_TABLE);
static GVolumeMonitor *volume_monitor = NULL;
static void drive_list_finalize (GObject *object);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void drive_list_dispose (GObject *object);
+#else
static void drive_list_destroy (GtkObject *object);
+#endif
static void drive_list_add (GtkContainer *container, GtkWidget *child);
static void drive_list_remove (GtkContainer *container, GtkWidget *child);
@@ -70,7 +74,11 @@ static void
drive_list_class_init (DriveListClass *class)
{
G_OBJECT_CLASS (class)->finalize = drive_list_finalize;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ G_OBJECT_CLASS (class)->dispose = drive_list_dispose;
+#else
GTK_OBJECT_CLASS (class)->destroy = drive_list_destroy;
+#endif
GTK_CONTAINER_CLASS (class)->add = drive_list_add;
GTK_CONTAINER_CLASS (class)->remove = drive_list_remove;
}
@@ -144,7 +152,11 @@ drive_list_finalize (GObject *object)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+drive_list_dispose (GObject *object)
+#else
drive_list_destroy (GtkObject *object)
+#endif
{
DriveList *self = DRIVE_LIST (object);
@@ -165,8 +177,13 @@ drive_list_destroy (GtkObject *object)
g_source_remove (self->layout_tag);
self->layout_tag = 0;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (G_OBJECT_CLASS (drive_list_parent_class)->dispose)
+ (* G_OBJECT_CLASS (drive_list_parent_class)->dispose) (object);
+#else
if (GTK_OBJECT_CLASS (drive_list_parent_class)->destroy)
(* GTK_OBJECT_CLASS (drive_list_parent_class)->destroy) (object);
+#endif
}
static void
diff --git a/drivemount/drivemount.c b/drivemount/drivemount.c
index 4d8e217b..04d7d06f 100644
--- a/drivemount/drivemount.c
+++ b/drivemount/drivemount.c
@@ -79,7 +79,11 @@ static void
change_background (MatePanelApplet *applet,
MatePanelAppletBackgroundType type,
GdkColor *colour,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_t *pattern,
+#else
GdkPixmap *pixmap,
+#endif
DriveList *drivelist)
{
switch (type) {