summaryrefslogtreecommitdiff
path: root/drivemount
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-11-22 17:47:06 +0300
committermonsta <[email protected]>2016-11-22 17:47:06 +0300
commitf7acf55db3ab4b97d60faae24555a07b6b08d43c (patch)
tree6feb99e63f801161642669b01c9ce0c217e60d0b /drivemount
parent45354a60352e05eba7e66e24a171e713876d71e9 (diff)
downloadmate-applets-f7acf55db3ab4b97d60faae24555a07b6b08d43c.tar.bz2
mate-applets-f7acf55db3ab4b97d60faae24555a07b6b08d43c.tar.xz
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
and require mate-panel >= 1.17 WARNING: use GTK+3 build of libmateweather for this build. that lib is not migrated to GTK+3 only as we will possibly use libgweather instead of it.
Diffstat (limited to 'drivemount')
-rw-r--r--drivemount/drive-button.c82
-rw-r--r--drivemount/drive-list.c28
-rw-r--r--drivemount/drive-list.h8
-rw-r--r--drivemount/drivemount.c4
4 files changed, 1 insertions, 121 deletions
diff --git a/drivemount/drive-button.c b/drivemount/drive-button.c
index e94d45a4..d3fd2d58 100644
--- a/drivemount/drive-button.c
+++ b/drivemount/drive-button.c
@@ -29,9 +29,7 @@
#include "drive-button.h"
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
-#if GTK_CHECK_VERSION (3, 0, 0)
#include <gio/gdesktopappinfo.h>
-#endif
#include <string.h>
@@ -70,7 +68,6 @@ drive_button_class_init (DriveButtonClass *class)
GTK_WIDGET_CLASS(class)->button_press_event = drive_button_button_press;
GTK_WIDGET_CLASS(class)->key_press_event = drive_button_key_press;
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkCssProvider *provider;
provider = gtk_css_provider_new ();
@@ -85,22 +82,6 @@ drive_button_class_init (DriveButtonClass *class)
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
-
-#else
- gtk_rc_parse_string ("\n"
- " style \"drive-button-style\"\n"
- " {\n"
- " GtkWidget::focus-line-width=0\n"
- " GtkWidget::focus-padding=0\n"
- " bg_pixmap[NORMAL] = \"<parent>\"\n"
- " bg_pixmap[ACTIVE] = \"<parent>\"\n"
- " bg_pixmap[PRELIGHT] = \"<parent>\"\n"
- " bg_pixmap[INSENSITIVE] = \"<parent>\"\n"
- " }\n"
- "\n"
- " class \"DriveButton\" style \"drive-button-style\"\n"
- "\n");
-#endif
}
static void
@@ -202,11 +183,7 @@ position_menu (GtkMenu *menu, gint *x, gint *y,
direction = gtk_widget_get_direction (widget);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
-#else
- gtk_widget_get_requisition (GTK_WIDGET (menu), &requisition);
-#endif
twidth = requisition.width;
theight = requisition.height;
@@ -383,13 +360,8 @@ drive_button_update (gpointer user_data)
g_free (display_name);
/* base the icon size on the desired button size */
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_get_preferred_size (GTK_WIDGET (self), NULL, &button_req);
gtk_widget_get_preferred_size (gtk_bin_get_child (GTK_BIN (self)), NULL, &image_req);
-#else
- gtk_widget_size_request (GTK_WIDGET (self), &button_req);
- gtk_widget_size_request (gtk_bin_get_child (GTK_BIN (self)), &image_req);
-#endif
width = self->icon_size - (button_req.width - image_req.width);
height = self->icon_size - (button_req.height - image_req.height);
@@ -401,11 +373,7 @@ drive_button_update (gpointer user_data)
if (icon_info)
{
pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
g_object_unref (icon_info);
-#else
- gtk_icon_info_free (icon_info);
-#endif
}
g_object_unref (icon);
@@ -422,11 +390,7 @@ drive_button_update (gpointer user_data)
gtk_image_set_from_pixbuf (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (self))), pixbuf);
g_object_unref (pixbuf);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_get_preferred_size (GTK_WIDGET (self), NULL, &button_req);
-#else
- gtk_widget_size_request (GTK_WIDGET (self), &button_req);
-#endif
return FALSE;
}
@@ -554,60 +518,31 @@ 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;
GAppInfo *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_app_info_get_default_for_type("inode/directory", FALSE);
if (!app_info)
app_info = G_APP_INFO (g_desktop_app_info_new ("caja.desktop"));
if (app_info) {
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display = gtk_widget_get_display (item);
launch_context = gdk_display_get_app_launch_context (display);
-#else
- launch_context = gdk_app_launch_context_new ();
-#endif
screen = gtk_widget_get_screen (GTK_WIDGET (self));
gdk_app_launch_context_set_screen (launch_context, screen);
files = g_list_prepend (files, file);
@@ -621,21 +556,11 @@ open_drive (DriveButton *self, GtkWidget *item)
}
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]);
-#endif
if (error)
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), error->message, NULL);
else
@@ -645,11 +570,8 @@ open_drive (DriveButton *self, GtkWidget *item)
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
@@ -994,7 +916,6 @@ drive_button_ensure_popup (DriveButton *self)
gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
/*Set up custom theme and transparency support */
GtkWidget *toplevel = gtk_widget_get_toplevel (self->popup_menu);
/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
@@ -1006,5 +927,4 @@ drive_button_ensure_popup (DriveButton *self)
context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
gtk_style_context_add_class(context,"gnome-panel-menu-bar");
gtk_style_context_add_class(context,"mate-panel-menu-bar");
-#endif
}
diff --git a/drivemount/drive-list.c b/drivemount/drive-list.c
index a1018398..78dd2e66 100644
--- a/drivemount/drive-list.c
+++ b/drivemount/drive-list.c
@@ -30,11 +30,7 @@
#include "drive-button.h"
#include <glib/gi18n.h>
-#if GTK_CHECK_VERSION(3, 0, 0)
G_DEFINE_TYPE (DriveList, drive_list, GTK_TYPE_GRID);
-#else
-G_DEFINE_TYPE (DriveList, drive_list, GTK_TYPE_TABLE);
-#endif
static GVolumeMonitor *volume_monitor = NULL;
@@ -84,12 +80,8 @@ drive_list_init (DriveList *self)
{
GList *volumes, *mounts, *tmp;
-#if GTK_CHECK_VERSION(3, 0, 0)
gtk_grid_set_column_homogeneous (GTK_GRID (self), TRUE);
gtk_grid_set_row_homogeneous (GTK_GRID (self), TRUE);
-#else
- gtk_table_set_homogeneous (GTK_TABLE (self), TRUE);
-#endif
self->volumes = g_hash_table_new (NULL, NULL);
self->mounts = g_hash_table_new (NULL, NULL);
@@ -248,36 +240,16 @@ relayout_buttons (gpointer data)
if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
gtk_container_child_set (GTK_CONTAINER (self), button,
-#if GTK_CHECK_VERSION(3, 0, 0)
"left-attach", i + 1, "top-attach", 0,
"width", 1, "height", 1,
NULL);
-#else
- "left_attach", i, "right_attach", i+1,
- "top_attach", 0, "bottom_attach", 1,
- "x_options", GTK_FILL,
- "y_options", GTK_FILL,
- NULL);
-#endif
} else {
gtk_container_child_set (GTK_CONTAINER (self), button,
-#if GTK_CHECK_VERSION(3, 0, 0)
"left-attach", 0, "top-attach", i + 1,
"width", 1, "height", 1,
NULL);
-#else
- "left_attach", 0, "right_attach", 1,
- "top_attach", i, "bottom_attach", i+1,
- "x_options", GTK_FILL,
- "y_options", GTK_FILL,
- NULL);
-#endif
}
}
-#if !GTK_CHECK_VERSION(3, 0, 0)
- /* shrink wrap the table */
- gtk_table_resize (GTK_TABLE (self), 1, 1);
-#endif
return FALSE;
}
diff --git a/drivemount/drive-list.h b/drivemount/drive-list.h
index 76693ca7..690e0c4b 100644
--- a/drivemount/drive-list.h
+++ b/drivemount/drive-list.h
@@ -39,11 +39,7 @@ typedef struct _DriveListClass DriveListClass;
struct _DriveList
{
-#if GTK_CHECK_VERSION(3, 0, 0)
GtkGrid parent;
-#else
- GtkTable parent;
-#endif
GHashTable *volumes;
GHashTable *mounts;
@@ -56,11 +52,7 @@ struct _DriveList
struct _DriveListClass
{
-#if GTK_CHECK_VERSION(3, 0, 0)
GtkGridClass parent_class;
-#else
- GtkTableClass parent_class;
-#endif
};
GType drive_list_get_type (void);
diff --git a/drivemount/drivemount.c b/drivemount/drivemount.c
index 28904ee7..196af363 100644
--- a/drivemount/drivemount.c
+++ b/drivemount/drivemount.c
@@ -79,11 +79,7 @@ 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) {