summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-16 05:08:48 -0800
committerStefano Karapetsas <[email protected]>2012-11-16 05:08:48 -0800
commitdc66bc40724191f0068869773576dc4edf042c6f (patch)
tree74b9684feea188736b21f2c829f29befaaf2e9da
parent935e1fed604f48e68d125d205c890a59f46f8f21 (diff)
parent1466df20591105550738a1d0784a623af9909abf (diff)
downloadcaja-dc66bc40724191f0068869773576dc4edf042c6f.tar.bz2
caja-dc66bc40724191f0068869773576dc4edf042c6f.tar.xz
Merge pull request #42 from jasmineaura/develop
Bring Caja up to speed, stage1
-rw-r--r--configure.in6
-rw-r--r--eel/Makefile.am162
-rw-r--r--eel/eel-alert-dialog.c490
-rw-r--r--eel/eel-alert-dialog.h60
-rw-r--r--eel/eel-background-box.c3
-rw-r--r--eel/eel-background.c190
-rw-r--r--eel/eel-background.h4
-rw-r--r--eel/eel-canvas-rect-ellipse.c467
-rw-r--r--eel/eel-canvas-rect-ellipse.h11
-rw-r--r--eel/eel-canvas.c383
-rw-r--r--eel/eel-canvas.h29
-rw-r--r--eel/eel-debug-drawing.c93
-rw-r--r--eel/eel-editable-label.c480
-rw-r--r--eel/eel-editable-label.h3
-rw-r--r--eel/eel-gdk-extensions.c310
-rw-r--r--eel/eel-gdk-extensions.h55
-rw-r--r--eel/eel-gdk-pixbuf-extensions.c54
-rw-r--r--eel/eel-gdk-pixbuf-extensions.h13
-rw-r--r--eel/eel-glib-extensions.c285
-rw-r--r--eel/eel-glib-extensions.h35
-rw-r--r--eel/eel-graphic-effects.c84
-rw-r--r--eel/eel-graphic-effects.h4
-rw-r--r--eel/eel-gtk-extensions.c792
-rw-r--r--eel/eel-gtk-extensions.h66
-rw-r--r--eel/eel-i18n.c52
-rw-r--r--eel/eel-i18n.h55
-rw-r--r--eel/eel-image-table.c387
-rw-r--r--eel/eel-labeled-image.c360
-rw-r--r--eel/eel-lib-self-check-functions.h1
-rw-r--r--eel/eel-mate-extensions.c20
-rw-r--r--eel/eel-mate-extensions.h4
-rw-r--r--eel/eel-pango-extensions.c615
-rw-r--r--eel/eel-pango-extensions.h55
-rw-r--r--eel/eel-stock-dialogs.c76
-rw-r--r--eel/eel-types.c82
-rw-r--r--eel/eel-types.h32
-rw-r--r--eel/eel-vfs-extensions.c30
-rw-r--r--eel/eel-vfs-extensions.h1
-rw-r--r--eel/eel-wrap-table.c245
-rw-r--r--eel/eel-xml-extensions.c2
-rw-r--r--eel/eel.h2
-rw-r--r--eel/eelmarshal.list13
-rwxr-xr-xeel/makeenums.pl220
-rwxr-xr-xeel/maketypes.awk155
-rw-r--r--libcaja-private/Makefile.am45
-rw-r--r--libcaja-private/caja-autorun.c16
-rw-r--r--libcaja-private/caja-bookmark.c4
-rw-r--r--libcaja-private/caja-cell-renderer-pixbuf-emblem.c519
-rw-r--r--libcaja-private/caja-cell-renderer-pixbuf-emblem.h68
-rw-r--r--libcaja-private/caja-cell-renderer-text-ellipsized.c88
-rw-r--r--libcaja-private/caja-clipboard.c23
-rw-r--r--libcaja-private/caja-column-utilities.c5
-rw-r--r--libcaja-private/caja-customization-data.c13
-rw-r--r--libcaja-private/caja-debug-log.c4
-rw-r--r--libcaja-private/caja-directory-async.c22
-rw-r--r--libcaja-private/caja-directory-background.c54
-rw-r--r--libcaja-private/caja-directory.c20
-rw-r--r--libcaja-private/caja-dnd.c7
-rw-r--r--libcaja-private/caja-emblem-utils.c4
-rw-r--r--libcaja-private/caja-entry.c24
-rw-r--r--libcaja-private/caja-file-changes-queue.c16
-rw-r--r--libcaja-private/caja-file-conflict-dialog.c1
-rw-r--r--libcaja-private/caja-file-dnd.c4
-rw-r--r--libcaja-private/caja-file-operations.c48
-rw-r--r--libcaja-private/caja-file-utilities.c3
-rw-r--r--libcaja-private/caja-file.c28
-rw-r--r--libcaja-private/caja-horizontal-splitter.c307
-rw-r--r--libcaja-private/caja-horizontal-splitter.h76
-rw-r--r--libcaja-private/caja-icon-canvas-item.c454
-rw-r--r--libcaja-private/caja-icon-canvas-item.h8
-rw-r--r--libcaja-private/caja-icon-container.c262
-rw-r--r--libcaja-private/caja-icon-dnd.c212
-rw-r--r--libcaja-private/caja-icon-dnd.h8
-rw-r--r--libcaja-private/caja-icon-info.c48
-rw-r--r--libcaja-private/caja-icon-info.h4
-rw-r--r--libcaja-private/caja-icon-names.h9
-rw-r--r--libcaja-private/caja-icon-private.h5
-rw-r--r--libcaja-private/caja-iso9660.h110
-rw-r--r--libcaja-private/caja-keep-last-vertical-box.c9
-rw-r--r--libcaja-private/caja-marshal.c2
-rw-r--r--libcaja-private/caja-marshal.list23
-rw-r--r--libcaja-private/caja-merged-directory.c3
-rw-r--r--libcaja-private/caja-mime-actions.c68
-rw-r--r--libcaja-private/caja-mime-application-chooser.c18
-rw-r--r--libcaja-private/caja-open-with-dialog.c17
-rw-r--r--libcaja-private/caja-program-choosing.c16
-rw-r--r--libcaja-private/caja-progress-info.c10
-rw-r--r--libcaja-private/caja-query.c5
-rw-r--r--libcaja-private/caja-search-engine-beagle.c4
-rw-r--r--libcaja-private/caja-search-engine-simple.c10
-rw-r--r--libcaja-private/caja-search-engine-tracker.c4
-rw-r--r--libcaja-private/caja-thumbnails.c4
-rw-r--r--libcaja-private/caja-tree-view-drag-dest.c48
-rw-r--r--libcaja-private/caja-undostack-manager.c25
-rw-r--r--libcaja-private/caja-window-info.h5
-rw-r--r--libcaja-private/caja-window-slot-info.c14
-rw-r--r--libcaja-private/caja-window-slot-info.h19
-rw-r--r--src/Makefile.am39
-rw-r--r--src/caja-application.c183
-rw-r--r--src/caja-application.h15
-rw-r--r--src/caja-bookmark-list.c9
-rw-r--r--src/caja-bookmarks-window.c47
-rw-r--r--src/caja-bookmarks-window.ui1
-rw-r--r--src/caja-connect-server-dialog-main.c150
-rw-r--r--src/caja-connect-server-dialog-nonmain.c76
-rw-r--r--src/caja-connect-server-dialog.c1644
-rw-r--r--src/caja-connect-server-dialog.h48
-rw-r--r--src/caja-connect-server-operation.c140
-rw-r--r--src/caja-connect-server-operation.h63
-rw-r--r--src/caja-desktop-window.c74
-rw-r--r--src/caja-desktop-window.h1
-rw-r--r--src/caja-emblem-sidebar.c12
-rw-r--r--src/caja-file-management-properties.c25
-rw-r--r--src/caja-file-management-properties.ui248
-rw-r--r--src/caja-history-sidebar.c5
-rw-r--r--src/caja-image-properties-page.c5
-rw-r--r--src/caja-information-panel.c37
-rw-r--r--src/caja-location-bar.c20
-rw-r--r--src/caja-location-dialog.c20
-rw-r--r--src/caja-location-entry.c57
-rw-r--r--src/caja-main.c12
-rw-r--r--src/caja-main.h6
-rw-r--r--src/caja-navigation-bar.c11
-rw-r--r--src/caja-navigation-window-menus.c54
-rw-r--r--src/caja-navigation-window-pane.c20
-rw-r--r--src/caja-navigation-window-slot.c6
-rw-r--r--src/caja-navigation-window.c28
-rw-r--r--src/caja-notes-viewer.c5
-rw-r--r--src/caja-pathbar.c224
-rw-r--r--src/caja-places-sidebar.c1053
-rw-r--r--src/caja-property-browser.c166
-rw-r--r--src/caja-query-editor.c16
-rw-r--r--src/caja-search-bar.c6
-rw-r--r--src/caja-side-pane.c16
-rw-r--r--src/caja-sidebar-title.c262
-rw-r--r--src/caja-sidebar-title.h3
-rw-r--r--src/caja-spatial-window.c309
-rw-r--r--src/caja-spatial-window.h2
-rw-r--r--src/caja-trash-bar.c3
-rw-r--r--src/caja-view-as-action.c8
-rw-r--r--src/caja-window-bookmarks.c2
-rw-r--r--src/caja-window-manage-views.c235
-rw-r--r--src/caja-window-menus.c10
-rw-r--r--src/caja-window-private.h4
-rw-r--r--src/caja-window-slot.c3
-rw-r--r--src/caja-window-slot.h13
-rw-r--r--src/caja-window-toolbars.c13
-rw-r--r--src/caja-window.c189
-rw-r--r--src/caja-window.h10
-rw-r--r--src/caja-zoom-control.c21
-rw-r--r--src/file-manager/Makefile.am37
-rw-r--r--src/file-manager/fm-desktop-icon-view.c63
-rw-r--r--src/file-manager/fm-directory-view.c94
-rw-r--r--src/file-manager/fm-icon-view.c36
-rw-r--r--src/file-manager/fm-list-model.c158
-rw-r--r--src/file-manager/fm-list-model.h9
-rw-r--r--src/file-manager/fm-list-view.c30
-rw-r--r--src/file-manager/fm-properties-window.c163
-rw-r--r--src/file-manager/fm-tree-model.c132
-rw-r--r--src/file-manager/fm-tree-model.h1
-rw-r--r--src/file-manager/fm-tree-view.c16
-rw-r--r--test/Makefile.am2
-rw-r--r--test/test-eel-image-scrolled.c187
-rw-r--r--test/test-eel-image-table.c16
164 files changed, 6123 insertions, 9759 deletions
diff --git a/configure.in b/configure.in
index e6cd690d..8d3a0f02 100644
--- a/configure.in
+++ b/configure.in
@@ -6,7 +6,7 @@ m4_define(glib_minver, 2.25.12)
m4_define(gio_minver, 2.25.0)
m4_define(mate_desktop_minver, 1.5.0)
m4_define(pango_minver, 1.1.2)
-m4_define(gtk_minver, 2.22.0)
+m4_define(gtk_minver, 2.24.0)
m4_define(xml_minver, 2.4.7)
m4_define(exif_minver, 0.5.12)
m4_define(exempi_minver, 1.99.2)
@@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
dnl GTK library version
dnl ---------------------------------------------------------------------------
GTK_API_VERSION=2.0
-GTK_REQUIRED=2.22.0
+GTK_REQUIRED=2.24.0
AC_MSG_CHECKING([which gtk+ version to compile against])
AC_ARG_WITH([gtk],
@@ -42,7 +42,7 @@ AC_MSG_RESULT([$with_gtk])
case "$with_gtk" in
2.0) GTK_API_VERSION=2.0
- GTK_REQUIRED=2.18.0
+ GTK_REQUIRED=2.24.0
;;
3.0) GTK_API_VERSION=3.0
GTK_REQUIRED=3.0.0
diff --git a/eel/Makefile.am b/eel/Makefile.am
index a973fee8..831ab7d5 100644
--- a/eel/Makefile.am
+++ b/eel/Makefile.am
@@ -4,15 +4,18 @@ noinst_LTLIBRARIES=libeel-2.la
INCLUDES = \
-DG_LOG_DOMAIN=\"Eel\" \
- -I$(top_srcdir) \
+ -I$(top_builddir) \
$(CORE_CFLAGS) \
$(WARNING_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \
-DSOURCE_DATADIR=\""$(top_srcdir)/data"\" \
-DMATELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \
- -DG_DISABLE_DEPRECATED \
- -DGDK_PIXBUF_DISABLE_DEPRECATED \
- -DMATEMENU_I_KNOW_THIS_IS_UNSTABLE \
+ $(NULL)
+
+BUILT_SOURCES = \
+ eel-marshal.c \
+ eel-marshal.h \
$(NULL)
libeel_2_la_LDFLAGS = \
@@ -26,44 +29,8 @@ libeel_2_la_LIBADD = \
$(X_LIBS) \
$(NULL)
-libeel_2_la_SOURCES = \
- eel-accessibility.c \
- eel-alert-dialog.c \
- eel-art-extensions.c \
- eel-art-gtk-extensions.c \
- eel-background.c \
- eel-background-box.c \
- eel-canvas.c \
- eel-canvas-util.c \
- eel-canvas-rect-ellipse.c \
- eel-debug-drawing.c \
- eel-debug.c \
- eel-editable-label.c \
- eel-gdk-extensions.c \
- eel-gdk-pixbuf-extensions.c \
- eel-glib-extensions.c \
- eel-mate-extensions.c \
- eel-graphic-effects.c \
- eel-gtk-container.c \
- eel-gtk-extensions.c \
- eel-i18n.c \
- eel-image-table.c \
- eel-labeled-image.c \
- eel-lib-self-check-functions.c \
- eel-pango-extensions.c \
- eel-self-checks.c \
- eel-stock-dialogs.c \
- eel-string.c \
- eel-types.c \
- eel-vfs-extensions.c \
- eel-wrap-table.c \
- eel-xml-extensions.c \
- eel-lib-self-check-functions.h \
- $(NULL)
-
eel_headers = \
eel-accessibility.h \
- eel-alert-dialog.h \
eel-art-extensions.h \
eel-art-gtk-extensions.h \
eel-background.h \
@@ -82,64 +49,69 @@ eel_headers = \
eel-gtk-container.h \
eel-gtk-extensions.h \
eel-gtk-macros.h \
- eel-i18n.h \
eel-image-table.h \
eel-labeled-image.h \
- eel-pango-extensions.h \
eel-self-checks.h \
eel-stock-dialogs.h \
eel-string.h \
- eel-types.h \
eel-vfs-extensions.h \
eel-wrap-table.h \
eel-xml-extensions.h \
eel.h \
$(NULL)
-marshal_sources = \
- eel-marshal.h \
- eel-marshal.c \
- $(NULL)
-
-eel-marshal.h: eelmarshal.list $(GLIB_GENMARSHAL)
- $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=eel_marshal > $@
-eel-marshal.c: eelmarshal.list $(GLIB_GENMARSHAL)
- $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --body --prefix=eel_marshal > $@
-
-stamp_sources = \
- eel-enums.defs \
- eel-type-builtins-evals.c \
+libeel_2_la_SOURCES = \
+ eel-accessibility.c \
+ eel-art-extensions.c \
+ eel-art-gtk-extensions.c \
+ eel-background.c \
+ eel-background-box.c \
+ eel-canvas.c \
+ eel-canvas-util.c \
+ eel-canvas-rect-ellipse.c \
+ eel-debug-drawing.c \
+ eel-debug.c \
+ eel-editable-label.c \
+ eel-gdk-extensions.c \
+ eel-gdk-pixbuf-extensions.c \
+ eel-glib-extensions.c \
+ eel-mate-extensions.c \
+ eel-graphic-effects.c \
+ eel-gtk-container.c \
+ eel-gtk-extensions.c \
+ eel-image-table.c \
+ eel-labeled-image.c \
+ eel-lib-self-check-functions.c \
+ eel-self-checks.c \
+ eel-stock-dialogs.c \
+ eel-string.c \
+ eel-vfs-extensions.c \
+ eel-wrap-table.c \
+ eel-xml-extensions.c \
+ eel-lib-self-check-functions.h \
$(NULL)
-stamps = \
- eel-makeenums-stamp \
- eel-stamp \
+nodist_libeel_2_la_SOURCES = \
+ $(BUILT_SOURCES) \
$(NULL)
-eel-makeenums-stamp: makeenums.pl $(eel_headers)
- $(AM_V_GEN)$(PERL) $< defs $(filter-out $<,$^) > xgen-eed \
- && (cmp -s xgen-eed eel-enums.defs || mv -f xgen-eed eel-enums.defs) \
- && rm -f xgen-eed \
- && $(PERL) $< arrays $(filter-out $<,$^) > xgen-etbe \
- && (cmp -s xgen-etbe eel-type-builtins-evals.c || mv -f xgen-etbe eel-type-builtins-evals.c) \
- && rm -f xgen-etbe \
- && echo timestamp > $@
-
-maketypes_sources = \
- eel-type-builtins.h \
- eel-type-builtins-ids.c \
- eel-type-builtins-vars.c \
- $(NULL)
+eel-marshal.list: $(libeel_2_la_SOURCES) Makefile.am
+ $(AM_V_GEN)( cd $(srcdir) && \
+ sed -n -e 's/.*eel_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \
+ $(libeel_2_la_SOURCES) ) \
+ | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > [email protected]
+ @if cmp -s [email protected] $@; then \
+ else \
+ fi
-eel-stamp: eel-makeenums-stamp $(maketypes_sources)
- echo timestamp > $@
+%-marshal.c: %-marshal.list Makefile
+ $(AM_V_GEN)echo "#include \"eel-marshal.h\"" > $@ && \
+ $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c
-eel-type-builtins.h: eel-enums.defs maketypes.awk eel-makeenums-stamp
- LC_ALL=C $(AWK) -f $(srcdir)/maketypes.awk $< macros > $@
-eel-type-builtins-vars.c: eel-enums.defs maketypes.awk eel-makeenums-stamp
- LC_ALL=C $(AWK) -f $(srcdir)/maketypes.awk $< variables > $@
-eel-type-builtins-ids.c: eel-enums.defs maketypes.awk eel-makeenums-stamp
- LC_ALL=C $(AWK) -f $(srcdir)/maketypes.awk $< entries > $@
+%-marshal.h: %-marshal.list Makefile
+ $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
noinst_PROGRAMS = check-program
@@ -151,29 +123,11 @@ check_program_LDFLAGS = $(check_program_DEPENDENCIES) -lm
TESTS = check-eel
EXTRA_DIST = \
- $(eel_headers) \
- eel-type-builtins.h \
- eel-marshal.h \
check-eel \
- eelmarshal.list \
- makeenums.pl \
- maketypes.awk \
+ eel-marshal.list \
$(NULL)
-$(libeel_2_la_OBJECTS): $(marshal_sources)
-
-# This trick causes the stamp file to be built first.
-Makefile: eel-stamp
-
-# This trick causes the generated files to be built the first time.
-$(stamp_sources): # never add any dependencies
- test -f $@ || touch $@
-
-built_sources = $(stamps) $(stamp_sources) $(maketypes_sources) $(marshal_sources)
-CLEANFILES = $(built_sources)
-DONT_DIST_FILES = $(built_sources)
-
-dist-hook:
- for file in $(DONT_DIST_FILES) ; do \
- rm -f $(distdir)/$$file ; \
- done
+CLEANFILES = \
+ eel-marshal.list \
+ $(BUILT_SOURCES) \
+ $(NULL)
diff --git a/eel/eel-alert-dialog.c b/eel/eel-alert-dialog.c
deleted file mode 100644
index 726e4c67..00000000
--- a/eel/eel-alert-dialog.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-alert-dialog.c: An HIG compliant alert dialog.
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
-*/
-#include <config.h>
-
-#include "eel-alert-dialog.h"
-#include "eel-i18n.h"
-#include "eel-gtk-macros.h"
-#include <gtk/gtk.h>
-#include <string.h>
-
-enum
-{
- PROP_0,
- PROP_ALERT_TYPE,
- PROP_BUTTONS
-};
-
-struct _EelAlertDialogDetails
-{
- GtkWidget *image;
- GtkWidget *primary_label;
- GtkWidget *secondary_label;
- GtkWidget *details_expander;
- GtkWidget *details_label;
- GtkMessageType type;
-};
-
-
-static gpointer parent_class;
-
-static void eel_alert_dialog_finalize (GObject *object);
-static void eel_alert_dialog_class_init (EelAlertDialogClass *klass);
-static void eel_alert_dialog_init (EelAlertDialog *dialog);
-static void eel_alert_dialog_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
-static void eel_alert_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void eel_alert_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void eel_alert_dialog_add_buttons (EelAlertDialog *alert_dialog,
- GtkButtonsType buttons);
-
-GType
-eel_alert_dialog_get_type (void)
-{
- static GType dialog_type = 0;
-
- if (!dialog_type)
- {
-
- const GTypeInfo dialog_info =
- {
- sizeof (EelAlertDialogClass),
- NULL,
- NULL,
- (GClassInitFunc) eel_alert_dialog_class_init,
- NULL,
- NULL,
- sizeof (EelAlertDialog),
- 0,
- (GInstanceInitFunc) eel_alert_dialog_init,
- };
-
- dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "EelAlertDialog",
- &dialog_info, 0);
- }
- return dialog_type;
-}
-
-static void
-eel_alert_dialog_class_init (EelAlertDialogClass *class)
-{
- GtkWidgetClass *widget_class;
- GObjectClass *gobject_class;
-
- widget_class = GTK_WIDGET_CLASS (class);
- gobject_class = G_OBJECT_CLASS (class);
-
- parent_class = g_type_class_peek_parent (class);
-
- G_OBJECT_CLASS (class)->finalize = eel_alert_dialog_finalize;
-
- widget_class->style_set = eel_alert_dialog_style_set;
-
- gobject_class->set_property = eel_alert_dialog_set_property;
- gobject_class->get_property = eel_alert_dialog_get_property;
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("alert_border",
- _("Image/label border"),
- _("Width of border around the label and image in the alert dialog"),
- 0,
- G_MAXINT,
- 5,
- G_PARAM_READABLE));
-
- g_object_class_install_property (gobject_class,
- PROP_ALERT_TYPE,
- g_param_spec_enum ("alert_type",
- _("Alert Type"),
- _("The type of alert"),
- GTK_TYPE_MESSAGE_TYPE,
- GTK_MESSAGE_INFO,
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (gobject_class,
- PROP_BUTTONS,
- g_param_spec_enum ("buttons",
- _("Alert Buttons"),
- _("The buttons shown in the alert dialog"),
- GTK_TYPE_BUTTONS_TYPE,
- GTK_BUTTONS_NONE,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-eel_alert_dialog_finalize (GObject *object)
-{
- EelAlertDialog *dialog;
-
- dialog = EEL_ALERT_DIALOG (object);
-
- g_free (dialog->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-
-static void
-eel_alert_dialog_init (EelAlertDialog *dialog)
-{
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *expander;
-
- dialog->details = g_new0 (EelAlertDialogDetails, 1);
-
- dialog->details->primary_label = gtk_label_new (NULL);
- dialog->details->secondary_label = gtk_label_new (NULL);
- dialog->details->details_label = gtk_label_new (NULL);
- dialog->details->image = gtk_image_new_from_stock (NULL, GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (dialog->details->image), 0.5, 0.0);
-
- gtk_label_set_line_wrap (GTK_LABEL (dialog->details->primary_label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (dialog->details->primary_label), TRUE);
- gtk_label_set_use_markup (GTK_LABEL (dialog->details->primary_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (dialog->details->primary_label), 0.0, 0.5);
-
- gtk_label_set_line_wrap (GTK_LABEL (dialog->details->secondary_label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (dialog->details->secondary_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (dialog->details->secondary_label), 0.0, 0.5);
-
- gtk_label_set_line_wrap (GTK_LABEL (dialog->details->details_label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (dialog->details->details_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (dialog->details->details_label), 0.0, 0.5);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
-
- gtk_box_pack_start (GTK_BOX (hbox), dialog->details->image,
- FALSE, FALSE, 0);
-
- vbox = gtk_vbox_new (FALSE, 12);
-
- gtk_box_pack_start (GTK_BOX (hbox), vbox,
- FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (vbox), dialog->details->primary_label,
- FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (vbox), dialog->details->secondary_label,
- FALSE, FALSE, 0);
-
- expander = gtk_expander_new_with_mnemonic (_("Show more _details"));
- dialog->details->details_expander = expander;
- gtk_expander_set_spacing (GTK_EXPANDER (expander), 6);
- gtk_container_add (GTK_CONTAINER (expander), dialog->details->details_label);
-
- gtk_box_pack_start (GTK_BOX (vbox), expander,
- FALSE, FALSE, 0);
-
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox,
- FALSE, FALSE, 0);
-
- gtk_widget_show_all (hbox);
- gtk_widget_hide (expander);
-
-}
-
-static void
-setup_type (EelAlertDialog *dialog,
- GtkMessageType type)
-{
- const gchar *stock_id = NULL;
- GtkStockItem item;
-
- switch (type)
- {
- case GTK_MESSAGE_INFO:
- stock_id = GTK_STOCK_DIALOG_INFO;
- break;
- case GTK_MESSAGE_QUESTION:
- stock_id = GTK_STOCK_DIALOG_QUESTION;
- break;
- case GTK_MESSAGE_WARNING:
- stock_id = GTK_STOCK_DIALOG_WARNING;
- break;
- case GTK_MESSAGE_ERROR:
- stock_id = GTK_STOCK_DIALOG_ERROR;
- break;
- default:
- g_warning ("Unknown GtkMessageType %d", type);
- break;
- }
-
- if (stock_id == NULL)
- {
- stock_id = GTK_STOCK_DIALOG_INFO;
- }
-
- if (gtk_stock_lookup (stock_id, &item))
- {
- gtk_image_set_from_stock (GTK_IMAGE (dialog->details->image), stock_id,
- GTK_ICON_SIZE_DIALOG);
- }
- else
- {
- g_warning ("Stock dialog ID doesn't exist?");
- }
-}
-
-static void
-eel_alert_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EelAlertDialog *dialog;
-
- dialog = EEL_ALERT_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_ALERT_TYPE:
- dialog->details->type = g_value_get_enum (value);
- setup_type (dialog, dialog->details->type);
- break;
- case PROP_BUTTONS:
- eel_alert_dialog_add_buttons (dialog, g_value_get_enum (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-eel_alert_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EelAlertDialog *dialog;
-
- dialog = EEL_ALERT_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_ALERT_TYPE:
- g_value_set_enum (value, dialog->details->type);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-void
-eel_alert_dialog_set_primary_label (EelAlertDialog *dialog,
- const gchar *message)
-{
- gchar *markup_str;
- char *escaped_message;
-
- if (message != NULL)
- {
- escaped_message = g_markup_escape_text (message, -1);
- markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", escaped_message, "</span>", NULL);
- gtk_label_set_markup (GTK_LABEL (EEL_ALERT_DIALOG (dialog)->details->primary_label),
- markup_str);
- g_free (markup_str);
- g_free (escaped_message);
- }
-}
-
-void
-eel_alert_dialog_set_secondary_label (EelAlertDialog *dialog,
- const gchar *message)
-{
- if (message != NULL)
- {
- gtk_label_set_text (GTK_LABEL (EEL_ALERT_DIALOG (dialog)->details->secondary_label),
- message);
- }
- else
- {
- gtk_widget_hide (EEL_ALERT_DIALOG (dialog)->details->secondary_label);
- }
-}
-
-void
-eel_alert_dialog_set_details_label (EelAlertDialog *dialog,
- const gchar *message)
-{
- if (message != NULL)
- {
- gtk_widget_show (dialog->details->details_expander);
- gtk_label_set_text (GTK_LABEL (dialog->details->details_label), message);
- }
- else
- {
- gtk_widget_hide (dialog->details->details_expander);
- }
-}
-
-
-GtkWidget*
-eel_alert_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- GtkMessageType type,
- GtkButtonsType buttons,
- const gchar *primary_message,
- const gchar *secondary_message)
-{
- GtkWidget *widget;
- GtkDialog *dialog;
-
- g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
-
- widget = g_object_new (EEL_TYPE_ALERT_DIALOG,
- "alert_type", type,
- "buttons", buttons,
- NULL);
- atk_object_set_role (gtk_widget_get_accessible (widget), ATK_ROLE_ALERT);
-
- dialog = GTK_DIALOG (widget);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 14);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_dialog_set_has_separator (dialog, FALSE);
-
- /* Make sure we don't get a window title.
- * HIG says that alert dialogs should not have window title
- */
- gtk_window_set_title (GTK_WINDOW (dialog), "");
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
-
- eel_alert_dialog_set_primary_label (EEL_ALERT_DIALOG (dialog),
- primary_message);
-
- eel_alert_dialog_set_secondary_label (EEL_ALERT_DIALOG (dialog),
- secondary_message);
-
- if (parent != NULL)
- {
- gtk_window_set_transient_for (GTK_WINDOW (widget),
- GTK_WINDOW (parent));
- }
-
- if (flags & GTK_DIALOG_MODAL)
- {
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- }
-
- if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
- {
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- }
- return widget;
-}
-
-static void
-eel_alert_dialog_add_buttons (EelAlertDialog* alert_dialog,
- GtkButtonsType buttons)
-{
- GtkDialog* dialog;
-
- dialog = GTK_DIALOG (alert_dialog);
-
- switch (buttons)
- {
- case GTK_BUTTONS_NONE:
- break;
- case GTK_BUTTONS_OK:
- gtk_dialog_add_button (dialog,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK);
- gtk_dialog_set_default_response (dialog,
- GTK_RESPONSE_OK);
- break;
- case GTK_BUTTONS_CLOSE:
- gtk_dialog_add_button (dialog,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE);
- gtk_dialog_set_default_response (dialog,
- GTK_RESPONSE_CLOSE);
- break;
- case GTK_BUTTONS_CANCEL:
- gtk_dialog_add_button (dialog,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
- gtk_dialog_set_default_response (dialog,
- GTK_RESPONSE_CANCEL);
- break;
- case GTK_BUTTONS_YES_NO:
- gtk_dialog_add_button (dialog,
- GTK_STOCK_NO,
- GTK_RESPONSE_NO);
- gtk_dialog_add_button (dialog,
- GTK_STOCK_YES,
- GTK_RESPONSE_YES);
- gtk_dialog_set_default_response (dialog,
- GTK_RESPONSE_YES);
- break;
- case GTK_BUTTONS_OK_CANCEL:
- gtk_dialog_add_button (dialog,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (dialog,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK);
- gtk_dialog_set_default_response (dialog,
- GTK_RESPONSE_OK);
- break;
- default:
- g_warning ("Unknown GtkButtonsType");
- break;
- }
- g_object_notify (G_OBJECT (alert_dialog), "buttons");
-}
-
-static void
-eel_alert_dialog_style_set (GtkWidget *widget,
- GtkStyle *prev_style)
-{
- GtkWidget *parent;
- gint border_width;
-
- border_width = 0;
-
- parent = GTK_WIDGET (gtk_widget_get_parent (EEL_ALERT_DIALOG (widget)->details->image));
-
- if (parent != NULL)
- {
- gtk_widget_style_get (widget, "alert_border",
- &border_width, NULL);
-
- gtk_container_set_border_width (GTK_CONTAINER (parent),
- border_width);
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->style_set)
- {
- (GTK_WIDGET_CLASS (parent_class)->style_set) (widget, prev_style);
- }
-}
diff --git a/eel/eel-alert-dialog.h b/eel/eel-alert-dialog.h
deleted file mode 100644
index b1bbebe0..00000000
--- a/eel/eel-alert-dialog.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-alert-dialog.h: An HIG compliant alert dialog.
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
-*/
-
-#ifndef EEL_ALERT_DIALOG_H
-#define EEL_ALERT_DIALOG_H
-
-#include <gtk/gtk.h>
-
-#define EEL_TYPE_ALERT_DIALOG (eel_alert_dialog_get_type ())
-#define EEL_ALERT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_ALERT_DIALOG, EelAlertDialog))
-
-typedef struct _EelAlertDialog EelAlertDialog;
-typedef struct _EelAlertDialogClass EelAlertDialogClass;
-typedef struct _EelAlertDialogDetails EelAlertDialogDetails;
-
-struct _EelAlertDialog
-{
- GtkDialog parent_instance;
- EelAlertDialogDetails *details;
-};
-
-struct _EelAlertDialogClass
-{
- GtkDialogClass parent_class;
-};
-
-GType eel_alert_dialog_get_type (void);
-
-GtkWidget* eel_alert_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- GtkMessageType type,
- GtkButtonsType buttons,
- const gchar *primary_message,
- const gchar *secondary_message);
-void eel_alert_dialog_set_primary_label (EelAlertDialog *dialog,
- const gchar *message);
-void eel_alert_dialog_set_secondary_label (EelAlertDialog *dialog,
- const gchar *message);
-void eel_alert_dialog_set_details_label (EelAlertDialog *dialog,
- const gchar *message);
-
-#endif /* EEL_ALERT_DIALOG_H */
diff --git a/eel/eel-background-box.c b/eel/eel-background-box.c
index a3e98ed1..6e25cc62 100644
--- a/eel/eel-background-box.c
+++ b/eel/eel-background-box.c
@@ -25,13 +25,12 @@
#include <config.h>
#include "eel-background-box.h"
-#include "eel-gtk-macros.h"
#include "eel-background.h"
static void eel_background_box_class_init (EelBackgroundBoxClass *background_box_class);
static void eel_background_box_init (EelBackgroundBox *background);
-EEL_CLASS_BOILERPLATE (EelBackgroundBox, eel_background_box, GTK_TYPE_EVENT_BOX)
+G_DEFINE_TYPE (EelBackgroundBox, eel_background_box, GTK_TYPE_EVENT_BOX)
static gboolean
eel_background_box_expose_event (GtkWidget *widget,
diff --git a/eel/eel-background.c b/eel/eel-background.c
index 33803f58..bc2be2f1 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -25,15 +25,8 @@
#include <config.h>
#include "eel-background.h"
#include "eel-gdk-extensions.h"
-#include "eel-gdk-pixbuf-extensions.h"
#include "eel-glib-extensions.h"
-#include "eel-mate-extensions.h"
-#include "eel-gtk-macros.h"
#include "eel-lib-self-check-functions.h"
-#include "eel-string.h"
-#include "eel-marshal.h"
-#include "eel-types.h"
-#include "eel-type-builtins.h"
#include <gtk/gtk.h>
#include <eel/eel-canvas.h>
#include <eel/eel-canvas-util.h>
@@ -44,10 +37,6 @@
#define MATE_DESKTOP_USE_UNSTABLE_API
#include <libmateui/mate-bg.h>
-static void eel_background_class_init (gpointer klass);
-static void eel_background_init (gpointer object,
- gpointer klass);
-static void eel_background_finalize (GObject *object);
static GdkPixmap *eel_background_get_pixmap_and_color (EelBackground *background,
GdkWindow *window,
GdkColor *color);
@@ -57,7 +46,7 @@ static void set_image_properties (EelBackground *background);
static void init_fade (EelBackground *background, GtkWidget *widget);
static void free_fade (EelBackground *background);
-EEL_CLASS_BOILERPLATE (EelBackground, eel_background, GTK_TYPE_OBJECT)
+G_DEFINE_TYPE (EelBackground, eel_background, G_TYPE_OBJECT);
enum
{
@@ -106,49 +95,6 @@ struct EelBackgroundDetails
};
static void
-eel_background_class_init (gpointer klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
-
- eel_type_init ();
-
- signals[APPEARANCE_CHANGED] =
- g_signal_new ("appearance_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EelBackgroundClass,
- appearance_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals[SETTINGS_CHANGED] =
- g_signal_new ("settings_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EelBackgroundClass,
- settings_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1, G_TYPE_INT);
- signals[RESET] =
- g_signal_new ("reset",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EelBackgroundClass,
- reset),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- object_class->finalize = eel_background_finalize;
-}
-
-static void
on_bg_changed (MateBG *bg, EelBackground *background)
{
init_fade (background, background->details->widget);
@@ -165,13 +111,13 @@ on_bg_transitioned (MateBG *bg, EelBackground *background)
}
static void
-eel_background_init (gpointer object, gpointer klass)
+eel_background_init (EelBackground *background)
{
- EelBackground *background;
-
- background = EEL_BACKGROUND (object);
+ background->details =
+ G_TYPE_INSTANCE_GET_PRIVATE (background,
+ EEL_TYPE_BACKGROUND,
+ EelBackgroundDetails);
- background->details = g_new0 (EelBackgroundDetails, 1);
background->details->default_color.red = 0xffff;
background->details->default_color.green = 0xffff;
background->details->default_color.blue = 0xffff;
@@ -235,25 +181,6 @@ free_background_pixmap (EelBackground *background)
}
-static void
-eel_background_finalize (GObject *object)
-{
- EelBackground *background;
-
- background = EEL_BACKGROUND (object);
-
- g_free (background->details->color);
- eel_background_remove_current_image (background);
-
- free_background_pixmap (background);
-
- free_fade (background);
-
- g_free (background->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
static EelBackgroundImagePlacement
placement_mate_to_eel (MateBGPlacement p)
{
@@ -316,6 +243,67 @@ eel_background_set_image_placement (EelBackground *background,
placement_eel_to_mate (new_placement));
}
+
+static void
+eel_background_finalize (GObject *object)
+{
+ EelBackground *background;
+
+ background = EEL_BACKGROUND (object);
+
+ g_free (background->details->color);
+ eel_background_remove_current_image (background);
+
+ free_background_pixmap (background);
+
+ free_fade (background);
+
+ G_OBJECT_CLASS (eel_background_parent_class)->finalize (object);
+}
+
+static void
+eel_background_class_init (EelBackgroundClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ signals[APPEARANCE_CHANGED] =
+ g_signal_new ("appearance_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (EelBackgroundClass,
+ appearance_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals[SETTINGS_CHANGED] =
+ g_signal_new ("settings_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (EelBackgroundClass,
+ settings_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1, G_TYPE_INT);
+ signals[RESET] =
+ g_signal_new ("reset",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (EelBackgroundClass,
+ reset),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ object_class->finalize = eel_background_finalize;
+
+ g_type_class_add_private (klass, sizeof (EelBackgroundDetails));
+}
+
EelBackground *
eel_background_new (void)
{
@@ -390,7 +378,6 @@ eel_background_ensure_realized (EelBackground *background, GdkWindow *window)
background->details->default_color = style->bg[GTK_STATE_NORMAL];
}
- gdk_rgb_find_color (style->colormap, &(background->details->default_color));
}
/* If the window size is the same as last time, don't update */
@@ -491,10 +478,8 @@ eel_background_expose (GtkWidget *widget,
int window_width;
int window_height;
GdkPixmap *pixmap;
- GdkGC *gc;
- GdkGCValues gc_values;
- GdkGCValuesMask value_mask;
GdkWindow *widget_window;
+ cairo_t *cr;
EelBackground *background;
@@ -511,30 +496,22 @@ eel_background_expose (GtkWidget *widget,
pixmap = eel_background_get_pixmap_and_color (background,
widget_window,
&color);
+ cr = gdk_cairo_create (widget_window);
- if (pixmap)
- {
- gc_values.tile = pixmap;
- gc_values.ts_x_origin = 0;
- gc_values.ts_y_origin = 0;
- gc_values.fill = GDK_TILED;
- value_mask = GDK_GC_FILL | GDK_GC_TILE | GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN;
- }
- else
- {
- gdk_rgb_find_color (gtk_widget_get_colormap (widget), &color);
- gc_values.foreground = color;
- gc_values.fill = GDK_SOLID;
- value_mask = GDK_GC_FILL | GDK_GC_FOREGROUND;
+ if (pixmap) {
+ gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+ } else {
+ gdk_cairo_set_source_color (cr, &color);
}
- gc = gdk_gc_new_with_values (widget_window, &gc_values, value_mask);
+ gdk_cairo_rectangle (cr, &event->area);
+ cairo_clip (cr);
- gdk_gc_set_clip_rectangle (gc, &event->area);
+ cairo_rectangle (cr, 0, 0, window_width, window_height);
+ cairo_fill (cr);
- gdk_draw_rectangle (widget_window, gc, TRUE, 0, 0, window_width, window_height);
-
- g_object_unref (gc);
+ cairo_destroy (cr);
if (pixmap)
{
@@ -618,7 +595,7 @@ void
eel_background_set_color (EelBackground *background,
const char *color)
{
- if (eel_strcmp (background->details->color, color) != 0)
+ if (g_strcmp0 (background->details->color, color) != 0)
{
g_free (background->details->color);
background->details->color = g_strdup (color);
@@ -647,7 +624,7 @@ eel_background_set_image_uri_helper (EelBackground *background,
if (emit_signal)
{
- g_signal_emit (GTK_OBJECT (background), signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY);
+ g_signal_emit (background, signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY);
}
set_image_properties (background);
@@ -722,7 +699,7 @@ eel_background_reset (EelBackground *background)
{
g_return_if_fail (EEL_IS_BACKGROUND (background));
- g_signal_emit (GTK_OBJECT (background), signals[RESET], 0);
+ g_signal_emit (background, signals[RESET], 0);
}
static void
@@ -814,8 +791,6 @@ eel_background_set_up_widget (EelBackground *background, GtkWidget *widget)
style = gtk_widget_get_style (widget);
- gdk_rgb_find_color (style->colormap, &color);
-
if (EEL_IS_CANVAS (widget))
{
window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
@@ -1118,7 +1093,6 @@ eel_get_widget_background (GtkWidget *widget)
/* Store the background in the widget's data. */
background = eel_background_new ();
- g_object_ref_sink (background);
g_object_set_data_full (G_OBJECT (widget), "eel_background",
background, g_object_unref);
background->details->widget = widget;
diff --git a/eel/eel-background.h b/eel/eel-background.h
index 1604b537..cfccf2a1 100644
--- a/eel/eel-background.h
+++ b/eel/eel-background.h
@@ -128,13 +128,13 @@ typedef struct EelBackgroundDetails EelBackgroundDetails;
struct EelBackground
{
- GtkObject object;
+ GObject object;
EelBackgroundDetails *details;
};
struct EelBackgroundClass
{
- GtkObjectClass parent_class;
+ GObjectClass parent_class;
/* This signal is emitted whenever the background settings are
* changed.
diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c
index c637769d..d0e4a592 100644
--- a/eel/eel-canvas-rect-ellipse.c
+++ b/eel/eel-canvas-rect-ellipse.c
@@ -60,8 +60,7 @@ enum
PROP_OUTLINE_COLOR,
PROP_OUTLINE_COLOR_GDK,
PROP_OUTLINE_COLOR_RGBA,
- PROP_FILL_STIPPLE,
- PROP_OUTLINE_STIPPLE,
+ PROP_OUTLINE_STIPPLING,
PROP_WIDTH_PIXELS,
PROP_WIDTH_UNITS
};
@@ -69,7 +68,6 @@ enum
static void eel_canvas_re_class_init (EelCanvasREClass *klass);
static void eel_canvas_re_init (EelCanvasRE *re);
-static void eel_canvas_re_destroy (GtkObject *object);
static void eel_canvas_re_set_property (GObject *object,
guint param_id,
const GValue *value,
@@ -134,11 +132,9 @@ static void
eel_canvas_re_class_init (EelCanvasREClass *klass)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
EelCanvasItemClass *item_class;
gobject_class = (GObjectClass *) klass;
- object_class = (GtkObjectClass *) klass;
item_class = (EelCanvasItemClass *) klass;
re_parent_class = g_type_class_peek_parent (klass);
@@ -190,12 +186,6 @@ eel_canvas_re_class_init (EelCanvasREClass *klass)
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
- PROP_FILL_STIPPLE,
- g_param_spec_object ("fill-stipple", NULL, NULL,
- GDK_TYPE_DRAWABLE,
- G_PARAM_READWRITE));
- g_object_class_install_property
- (gobject_class,
PROP_OUTLINE_COLOR,
g_param_spec_string ("outline-color", NULL, NULL,
NULL,
@@ -212,12 +202,11 @@ eel_canvas_re_class_init (EelCanvasREClass *klass)
g_param_spec_uint ("outline-color-rgba", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
- g_object_class_install_property
- (gobject_class,
- PROP_OUTLINE_STIPPLE,
- g_param_spec_object ("outline-stipple", NULL, NULL,
- GDK_TYPE_DRAWABLE,
- G_PARAM_READWRITE));
+ g_object_class_install_property
+ (gobject_class,
+ PROP_OUTLINE_STIPPLING,
+ g_param_spec_boolean ("outline-stippling", NULL, NULL,
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_WIDTH_PIXELS,
@@ -231,8 +220,6 @@ eel_canvas_re_class_init (EelCanvasREClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
- object_class->destroy = eel_canvas_re_destroy;
-
item_class->realize = eel_canvas_re_realize;
item_class->unrealize = eel_canvas_re_unrealize;
item_class->translate = eel_canvas_re_translate;
@@ -249,30 +236,6 @@ eel_canvas_re_init (EelCanvasRE *re)
re->width = 0.0;
}
-static void
-eel_canvas_re_destroy (GtkObject *object)
-{
- EelCanvasRE *re;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (EEL_IS_CANVAS_RE (object));
-
- re = EEL_CANVAS_RE (object);
-
- /* remember, destroy can be run multiple times! */
-
- if (re->fill_stipple)
- g_object_unref (re->fill_stipple);
- re->fill_stipple = NULL;
-
- if (re->outline_stipple)
- g_object_unref (re->outline_stipple);
- re->outline_stipple = NULL;
-
- if (GTK_OBJECT_CLASS (re_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (re_parent_class)->destroy) (object);
-}
-
static void get_bounds (EelCanvasRE *re, double *px1, double *py1, double *px2, double *py2)
{
EelCanvasItem *item;
@@ -312,60 +275,6 @@ static void get_bounds (EelCanvasRE *re, double *px1, double *py1, double *px2,
*py2 += 2;
}
-/* Convenience function to set a GC's foreground color to the specified pixel value */
-static void
-set_gc_foreground (GdkGC *gc, gulong pixel)
-{
- GdkColor c;
-
- if (!gc)
- return;
-
- c.pixel = pixel;
- gdk_gc_set_foreground (gc, &c);
-}
-
-/* Sets the stipple pattern for the specified gc */
-static void
-set_stipple (GdkGC *gc, GdkBitmap **internal_stipple, GdkBitmap *stipple, int reconfigure)
-{
- if (*internal_stipple && !reconfigure)
- g_object_unref (*internal_stipple);
-
- *internal_stipple = stipple;
- if (stipple && !reconfigure)
- g_object_ref (stipple);
-
- if (gc)
- {
- if (stipple)
- {
- gdk_gc_set_stipple (gc, stipple);
- gdk_gc_set_fill (gc, GDK_STIPPLED);
- }
- else
- gdk_gc_set_fill (gc, GDK_SOLID);
- }
-}
-
-/* Recalculate the outline width of the rectangle/ellipse and set it in its GC */
-static void
-set_outline_gc_width (EelCanvasRE *re)
-{
- int width;
-
- if (!re->outline_gc)
- return;
-
- if (re->width_pixels)
- width = (int) re->width;
- else
- width = (int) (re->width * re->item.canvas->pixels_per_unit + 0.5);
-
- gdk_gc_set_line_attributes (re->outline_gc, width,
- GDK_LINE_SOLID, GDK_CAP_PROJECTING, GDK_JOIN_MITER);
-}
-
static void
eel_canvas_re_set_fill (EelCanvasRE *re, gboolean fill_set)
{
@@ -396,14 +305,12 @@ eel_canvas_re_set_property (GObject *object,
EelCanvasRE *re;
GdkColor color = { 0, 0, 0, 0, };
GdkColor *pcolor;
- int have_pixel;
g_return_if_fail (object != NULL);
g_return_if_fail (EEL_IS_CANVAS_RE (object));
item = EEL_CANVAS_ITEM (object);
re = EEL_CANVAS_RE (object);
- have_pixel = FALSE;
switch (param_id)
{
@@ -455,12 +362,7 @@ eel_canvas_re_set_property (GObject *object,
if (pcolor)
{
- GdkColormap *colormap;
-
color = *pcolor;
- colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas));
- gdk_rgb_find_color (colormap, &color);
- have_pixel = TRUE;
}
re->fill_color = ((color.red & 0xff00) << 16 |
@@ -477,13 +379,6 @@ eel_canvas_re_set_property (GObject *object,
#ifdef VERBOSE
g_print ("re fill color = %08x\n", re->fill_color);
#endif
- if (have_pixel)
- re->fill_pixel = color.pixel;
- else
- re->fill_pixel = eel_canvas_get_color_pixel (item->canvas, re->fill_color);
-
- set_gc_foreground (re->fill_gc, re->fill_pixel);
-
eel_canvas_item_request_redraw (item);
break;
@@ -511,13 +406,7 @@ eel_canvas_re_set_property (GObject *object,
if (pcolor)
{
- GdkColormap *colormap;
-
color = *pcolor;
- colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas));
- gdk_rgb_find_color (colormap, &color);
-
- have_pixel = TRUE;
}
re->outline_color = ((color.red & 0xff00) << 16 |
@@ -534,30 +423,18 @@ eel_canvas_re_set_property (GObject *object,
#ifdef VERBOSE
g_print ("re outline color %x %x %x\n", color.red, color.green, color.blue);
#endif
- if (have_pixel)
- re->outline_pixel = color.pixel;
- else
- re->outline_pixel = eel_canvas_get_color_pixel (item->canvas,
- re->outline_color);
-
- set_gc_foreground (re->outline_gc, re->outline_pixel);
-
eel_canvas_item_request_redraw (item);
break;
- case PROP_FILL_STIPPLE:
- set_stipple (re->fill_gc, &re->fill_stipple, (GdkBitmap *) g_value_get_object (value), FALSE);
+ case PROP_OUTLINE_STIPPLING:
+ re->outline_stippling = g_value_get_boolean (value);
- break;
-
- case PROP_OUTLINE_STIPPLE:
- set_stipple (re->outline_gc, &re->outline_stipple, (GdkBitmap *) g_value_get_object (value), FALSE);
- break;
+ eel_canvas_item_request_redraw (item);
+ break;
case PROP_WIDTH_PIXELS:
re->width = g_value_get_uint (value);
re->width_pixels = TRUE;
- set_outline_gc_width (re);
eel_canvas_item_request_update (item);
break;
@@ -565,7 +442,6 @@ eel_canvas_re_set_property (GObject *object,
case PROP_WIDTH_UNITS:
re->width = fabs (g_value_get_double (value));
re->width_pixels = FALSE;
- set_outline_gc_width (re);
eel_canvas_item_request_update (item);
break;
@@ -583,10 +459,14 @@ static void
get_color_value (EelCanvasRE *re, gulong pixel, GValue *value)
{
GdkColor color;
- EelCanvasItem *item = (EelCanvasItem *) re;
- GdkColormap *colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas));
- gdk_colormap_query_color (colormap, pixel, &color);
+ color.red = (pixel >> 16) & 0xFF;
+ color.green = (pixel >> 8) & 0xFF;
+ color.blue = pixel & 0xFF;
+ color.red |= color.red << 8;
+ color.green |= color.green << 8;
+ color.blue |= color.blue << 8;
+
g_value_set_boxed (value, &color);
}
@@ -622,11 +502,11 @@ eel_canvas_re_get_property (GObject *object,
break;
case PROP_FILL_COLOR_GDK:
- get_color_value (re, re->fill_pixel, value);
+ get_color_value (re, re->fill_color, value);
break;
case PROP_OUTLINE_COLOR_GDK:
- get_color_value (re, re->outline_pixel, value);
+ get_color_value (re, re->outline_color, value);
break;
case PROP_FILL_COLOR_RGBA:
@@ -637,13 +517,9 @@ eel_canvas_re_get_property (GObject *object,
g_value_set_uint (value, re->outline_color);
break;
- case PROP_FILL_STIPPLE:
- g_value_set_object (value, (GObject *) re->fill_stipple);
- break;
-
- case PROP_OUTLINE_STIPPLE:
- g_value_set_object (value, (GObject *) re->outline_stipple);
- break;
+ case PROP_OUTLINE_STIPPLING:
+ g_value_set_boolean (value, re->outline_stippling);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -652,16 +528,6 @@ eel_canvas_re_get_property (GObject *object,
}
static void
-set_colors_and_stipples (EelCanvasRE *re)
-{
- set_gc_foreground (re->fill_gc, re->fill_pixel);
- set_gc_foreground (re->outline_gc, re->outline_pixel);
- set_stipple (re->fill_gc, &re->fill_stipple, re->fill_stipple, TRUE);
- set_stipple (re->outline_gc, &re->outline_stipple, re->outline_stipple, TRUE);
- set_outline_gc_width (re);
-}
-
-static void
eel_canvas_re_update_shared (EelCanvasItem *item, double i2w_dx, double i2w_dy, int flags)
{
EelCanvasRE *re;
@@ -674,8 +540,6 @@ eel_canvas_re_update_shared (EelCanvasItem *item, double i2w_dx, double i2w_dy,
if (re_parent_class->update)
(* re_parent_class->update) (item, i2w_dx, i2w_dy, flags);
- set_colors_and_stipples (re);
-
#ifdef OLD_XFORM
recalc_bounds (re);
#endif
@@ -694,12 +558,6 @@ eel_canvas_re_realize (EelCanvasItem *item)
if (re_parent_class->realize)
(* re_parent_class->realize) (item);
- re->fill_gc = gdk_gc_new (gtk_layout_get_bin_window (&item->canvas->layout));
- re->fill_pixel = eel_canvas_get_color_pixel (item->canvas, re->fill_color);
- re->outline_gc = gdk_gc_new (gtk_layout_get_bin_window (&item->canvas->layout));
- re->outline_pixel = eel_canvas_get_color_pixel (item->canvas, re->outline_color);
- set_colors_and_stipples (re);
-
#ifdef OLD_XFORM
(* EEL_CANVAS_ITEM_CLASS (item->object.klass)->update) (item, NULL, NULL, 0);
#endif
@@ -712,11 +570,6 @@ eel_canvas_re_unrealize (EelCanvasItem *item)
re = EEL_CANVAS_RE (item);
- g_object_unref (re->fill_gc);
- re->fill_gc = NULL;
- g_object_unref (re->outline_gc);
- re->outline_gc = NULL;
-
if (re_parent_class->unrealize)
(* re_parent_class->unrealize) (item);
}
@@ -768,7 +621,11 @@ static void eel_canvas_rect_init (EelCanvasRect *rect);
static void eel_canvas_rect_finalize (GObject *object);
static void eel_canvas_rect_realize (EelCanvasItem *item);
+#if GTK_CHECK_VERSION(3,0,0)
+static void eel_canvas_rect_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region);
+#else
static void eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose);
+#endif
static double eel_canvas_rect_point (EelCanvasItem *item, double x, double y, int cx, int cy,
EelCanvasItem **actual_item);
@@ -883,110 +740,24 @@ eel_canvas_rect_realize (EelCanvasItem *item)
static void
-render_rect_alpha (EelCanvasRect *rect,
- GdkDrawable *drawable,
- int x, int y,
- int width, int height,
- guint32 rgba)
+eel_canvas_set_source_color (cairo_t *cr,
+ guint rgba)
{
- GdkPixbuf *pixbuf;
- guchar *data;
- int rowstride, i;
- guchar r, g, b, a;
- EelCanvasRectPrivate *priv;
-
- if (width <= 0 || height <= 0 )
- {
- return;
- }
-
- priv = rect->priv;
-
- r = (rgba >> 24) & 0xff;
- g = (rgba >> 16) & 0xff;
- b = (rgba >> 8) & 0xff;
- a = (rgba >> 0) & 0xff;
-
-#ifdef HAVE_RENDER
- /* Every visual is not guaranteed to have a matching
- * XRenderPictFormat. So make sure that format is not null before
- * trying to render using Xrender calls.
- */
- if (priv->use_render && (priv->format != NULL))
- {
- GdkDrawable *real_drawable;
- int x_offset, y_offset;
-
- Display *dpy;
- Picture pict;
- XRenderPictureAttributes attributes;
- XRenderColor color;
-
- gdk_window_get_internal_paint_info (drawable, &real_drawable,
- &x_offset, &y_offset);
-
- dpy = gdk_x11_drawable_get_xdisplay (real_drawable);
-
- pict = XRenderCreatePicture (dpy,
- gdk_x11_drawable_get_xid (real_drawable),
- priv->format,
- 0,
- &attributes);
-
-
- /* Convert to premultiplied alpha: */
- r = r * a / 255;
- g = g * a / 255;
- b = b * a / 255;
-
- color.red = (r << 8) + r;
- color.green = (g << 8) + g;
- color.blue = (b << 8) + b;
- color.alpha = (a << 8) + a;
-
- XRenderFillRectangle (dpy,
- PictOpOver,
- pict,
- &color,
- x - x_offset, y - y_offset,
- width, height);
-
- XRenderFreePicture (dpy, pict);
-
- return;
- }
-#endif
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- data = gdk_pixbuf_get_pixels (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
-
- r = (rgba >> 24) & 0xff;
- g = (rgba >> 16) & 0xff;
- b = (rgba >> 8) & 0xff;
- a = (rgba >> 0) & 0xff;
-
- for (i = 0; i < width*4; )
- {
- data[i++] = r;
- data[i++] = g;
- data[i++] = b;
- data[i++] = a;
- }
-
- for (i = 1; i < height; i++)
- {
- memcpy (data + i*rowstride, data, width*4);
- }
-
- gdk_draw_pixbuf (drawable, NULL, pixbuf,
- 0, 0, x, y, width, height,
- GDK_RGB_DITHER_NONE, 0, 0);
- g_object_unref (pixbuf);
+ cairo_set_source_rgba (cr,
+ ((rgba >> 24) & 0xff) / 255.,
+ ((rgba >> 16) & 0xff) / 255.,
+ ((rgba >> 8) & 0xff) / 255.,
+ ((rgba >> 0) & 0xff) / 255.);
}
-
+#define DASH_ON 0.8
+#define DASH_OFF 1.7
static void
+#if GTK_CHECK_VERSION(3,0,0)
+eel_canvas_rect_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region)
+#else
eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
+#endif
{
EelCanvasRE *re;
double x1, y1, x2, y2;
@@ -1008,69 +779,55 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose
eel_canvas_w2c (item->canvas, x1, y1, &cx1, &cy1);
eel_canvas_w2c (item->canvas, x2, y2, &cx2, &cy2);
+ if (cx2 <= cx1 || cy2 <= cy1 ) {
+ return;
+ }
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (drawable);
+ gdk_cairo_region (cr, expose->region);
+ cairo_clip (cr);
+#endif
+
if (re->fill_set)
{
- if ((re->fill_color & 0xff) != 255)
- {
- GdkRectangle *rectangles;
- gint i, n_rectangles;
- GdkRectangle draw_rect;
- GdkRectangle part;
-
- draw_rect.x = cx1;
- draw_rect.y = cy1;
- draw_rect.width = cx2 - cx1 + 1;
- draw_rect.height = cy2 - cy1 + 1;
-
- /* For alpha mode, only render the parts of the region
- that are actually exposed */
- gdk_region_get_rectangles (expose->region,
- &rectangles,
- &n_rectangles);
-
- for (i = 0; i < n_rectangles; i++)
- {
- if (gdk_rectangle_intersect (&rectangles[i],
- &draw_rect,
- &part))
- {
- render_rect_alpha (EEL_CANVAS_RECT (item),
- drawable,
- part.x, part.y,
- part.width, part.height,
- re->fill_color);
- }
- }
-
- g_free (rectangles);
- }
- else
- {
- if (re->fill_stipple)
- eel_canvas_set_stipple_origin (item->canvas, re->fill_gc);
-
- gdk_draw_rectangle (drawable,
- re->fill_gc,
- TRUE,
- cx1, cy1,
- cx2 - cx1 + 1,
- cy2 - cy1 + 1);
- }
+ eel_canvas_set_source_color (cr, re->fill_color);
+ cairo_rectangle (cr,
+ cx1, cy1,
+ cx2 - cx1 + 1,
+ cy2 - cy1 + 1);
+ cairo_fill (cr);
}
if (re->outline_set)
{
- if (re->outline_stipple)
- eel_canvas_set_stipple_origin (item->canvas, re->outline_gc);
-
- gdk_draw_rectangle (drawable,
- re->outline_gc,
- FALSE,
- cx1,
- cy1,
- cx2 - cx1,
- cy2 - cy1);
+ eel_canvas_set_source_color (cr, re->outline_color);
+ if (re->width_pixels) {
+ cairo_set_line_width (cr, (int) re->width);
+ } else {
+ cairo_set_line_width (cr, (int) (re->width * re->item.canvas->pixels_per_unit + 0.5));
+ }
+
+ if (re->outline_stippling) {
+ double dash[2] = { DASH_ON, DASH_OFF };
+
+ cairo_set_dash (cr, dash, G_N_ELEMENTS (dash), 0);
+ }
+
+ cairo_rectangle (cr,
+ cx1 + 0.5, cy1 + 0.5,
+ cx2 - cx1,
+ cy2 - cy1);
+ cairo_stroke (cr);
}
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
+ cairo_destroy (cr);
+#endif
}
static double
@@ -1266,7 +1023,11 @@ eel_canvas_rect_update (EelCanvasItem *item, double i2w_dx, double i2w_dy, gint
static void eel_canvas_ellipse_class_init (EelCanvasEllipseClass *klass);
+#if GTK_CHECK_VERSION(3,0,0)
+static void eel_canvas_ellipse_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region);
+#else
static void eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose);
+#endif
static double eel_canvas_ellipse_point (EelCanvasItem *item, double x, double y, int cx, int cy,
EelCanvasItem **actual_item);
@@ -1314,7 +1075,11 @@ eel_canvas_ellipse_class_init (EelCanvasEllipseClass *klass)
}
static void
+#if GTK_CHECK_VERSION(3,0,0)
+eel_canvas_ellipse_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region)
+#else
eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
+#endif
{
EelCanvasRE *re;
int x1, y1, x2, y2;
@@ -1337,37 +1102,43 @@ eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExp
re->y2 + i2w_dy,
&x2, &y2);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (drawable);
+ gdk_cairo_region (cr, expose->region);
+ cairo_clip (cr);
+#endif
+
+ cairo_save (cr);
+ cairo_translate (cr, (x1 + x2) / 2., (y1 + y2) / 2.);
+ cairo_scale (cr, (x2 - x1), (y2 - y1));
+ cairo_arc (cr, 0, 0, 1, 0, 2 * G_PI);
+ cairo_restore (cr);
+
if (re->fill_set)
{
- if (re->fill_stipple)
- eel_canvas_set_stipple_origin (item->canvas, re->fill_gc);
-
- gdk_draw_arc (drawable,
- re->fill_gc,
- TRUE,
- x1,
- y1,
- x2 - x1,
- y2 - y1,
- 0 * 64,
- 360 * 64);
+ eel_canvas_set_source_color (cr, re->fill_color);
+ cairo_fill_preserve (cr);
}
if (re->outline_set)
{
- if (re->outline_stipple)
- eel_canvas_set_stipple_origin (item->canvas, re->outline_gc);
-
- gdk_draw_arc (drawable,
- re->outline_gc,
- FALSE,
- x1,
- y1,
- x2 - x1,
- y2 - y1,
- 0 * 64,
- 360 * 64);
+ eel_canvas_set_source_color (cr, re->outline_color);
+ if (re->width_pixels) {
+ cairo_set_line_width (cr, (int) re->width);
+ } else {
+ cairo_set_line_width (cr, (int) (re->width * re->item.canvas->pixels_per_unit + 0.5));
+ }
+
+ cairo_stroke_preserve (cr);
}
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
+ cairo_destroy (cr);
+#endif
}
static double
diff --git a/eel/eel-canvas-rect-ellipse.h b/eel/eel-canvas-rect-ellipse.h
index eb78bf1a..aaccf560 100644
--- a/eel/eel-canvas-rect-ellipse.h
+++ b/eel/eel-canvas-rect-ellipse.h
@@ -81,21 +81,14 @@ extern "C" {
{
EelCanvasItem item;
- GdkBitmap *fill_stipple; /* Stipple for fill */
- GdkBitmap *outline_stipple; /* Stipple for outline */
-
- GdkGC *fill_gc; /* GC for filling */
- GdkGC *outline_gc; /* GC for outline */
-
- gulong fill_pixel; /* Fill color */
- gulong outline_pixel; /* Outline color */
-
double x1, y1, x2, y2; /* Corners of item */
double width; /* Outline width */
guint fill_color; /* Fill color, RGBA */
guint outline_color; /* Outline color, RGBA */
+ gboolean outline_stippling;
+
/* Configuration flags */
unsigned int fill_set : 1; /* Is fill color set? */
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c
index a4d6612d..b3b4c482 100644
--- a/eel/eel-canvas.c
+++ b/eel/eel-canvas.c
@@ -68,11 +68,22 @@
#include <stdio.h>
#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
+#if GTK_CHECK_VERSION(3,0,0)
+# include <cairo/cairo-gobject.h>
+#endif
#include "eel-canvas.h"
-#include "eel-i18n.h"
#include "eel-marshal.h"
+#if !GTK_CHECK_VERSION(3, 0, 0)
+#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment
+#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment
+#define gtk_scrollable_set_hadjustment gtk_layout_set_hadjustment
+#define gtk_scrollable_set_vadjustment gtk_layout_set_vadjustment
+#define GTK_SCROLLABLE GTK_LAYOUT
+#endif
+
static void eel_canvas_request_update (EelCanvas *canvas);
static void group_add (EelCanvasGroup *group,
EelCanvasItem *item);
@@ -95,6 +106,7 @@ enum
enum
{
+ ITEM_DESTROY,
ITEM_EVENT,
ITEM_LAST_SIGNAL
};
@@ -105,7 +117,7 @@ static int emit_event (EelCanvas *canvas, GdkEvent *event
static guint item_signals[ITEM_LAST_SIGNAL];
-static GtkObjectClass *item_parent_class;
+static GObjectClass *item_parent_class;
static gpointer accessible_item_parent_class;
static gpointer accessible_parent_class;
@@ -139,10 +151,10 @@ eel_canvas_item_get_type (void)
(GInstanceInitFunc) eel_canvas_item_init
};
- canvas_item_type = g_type_register_static (gtk_object_get_type (),
- "EelCanvasItem",
- &canvas_item_info,
- 0);
+ canvas_item_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED,
+ "EelCanvasItem",
+ &canvas_item_info,
+ 0);
}
return canvas_item_type;
@@ -353,9 +365,21 @@ eel_canvas_item_dispose (GObject *object)
item->canvas = NULL;
}
+ g_object_set_data (object, "in-destruction", GINT_TO_POINTER (1));
+ g_signal_emit (object, item_signals[ITEM_DESTROY], 0);
+
+ g_object_set_data (object, "in-destruction", NULL);
+
G_OBJECT_CLASS (item_parent_class)->dispose (object);
}
+void
+eel_canvas_item_destroy (EelCanvasItem *item)
+{
+ if (g_object_get_data (G_OBJECT (item), "in-destruction") == NULL) {
+ g_object_run_dispose (G_OBJECT (item));
+ }
+}
/* Realize handler for canvas items */
static void
@@ -1194,7 +1218,7 @@ static void eel_canvas_group_get_property(GObject *object,
GValue *value,
GParamSpec *pspec);
-static void eel_canvas_group_destroy (GtkObject *object);
+static void eel_canvas_group_destroy (EelCanvasItem *object);
static void eel_canvas_group_update (EelCanvasItem *item,
double i2w_dx,
@@ -1203,8 +1227,14 @@ static void eel_canvas_group_update (EelCanvasItem *item,
static void eel_canvas_group_unrealize (EelCanvasItem *item);
static void eel_canvas_group_map (EelCanvasItem *item);
static void eel_canvas_group_unmap (EelCanvasItem *item);
+#if GTK_CHECK_VERSION(3,0,0)
+static void eel_canvas_group_draw (EelCanvasItem *item,
+ cairo_t *cr,
+ cairo_region_t *region);
+#else
static void eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose);
+#endif
static double eel_canvas_group_point (EelCanvasItem *item, double x, double y,
int cx, int cy,
EelCanvasItem **actual_item);
@@ -1260,11 +1290,9 @@ static void
eel_canvas_group_class_init (EelCanvasGroupClass *klass)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
EelCanvasItemClass *item_class;
gobject_class = (GObjectClass *) klass;
- object_class = (GtkObjectClass *) klass;
item_class = (EelCanvasItemClass *) klass;
group_parent_class = g_type_class_peek_parent (klass);
@@ -1287,8 +1315,7 @@ eel_canvas_group_class_init (EelCanvasGroupClass *klass)
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
- object_class->destroy = eel_canvas_group_destroy;
-
+ item_class->destroy = eel_canvas_group_destroy;
item_class->update = eel_canvas_group_update;
item_class->unrealize = eel_canvas_group_unrealize;
item_class->map = eel_canvas_group_map;
@@ -1385,7 +1412,7 @@ eel_canvas_group_get_property (GObject *gobject, guint param_id,
/* Destroy handler for canvas groups */
static void
-eel_canvas_group_destroy (GtkObject *object)
+eel_canvas_group_destroy (EelCanvasItem *object)
{
EelCanvasGroup *group;
EelCanvasItem *child;
@@ -1401,11 +1428,11 @@ eel_canvas_group_destroy (GtkObject *object)
child = list->data;
list = list->next;
- gtk_object_destroy (GTK_OBJECT (child));
+ eel_canvas_item_destroy (child);
}
- if (GTK_OBJECT_CLASS (group_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (group_parent_class)->destroy) (object);
+ if (EEL_CANVAS_ITEM_CLASS (group_parent_class)->destroy)
+ (* EEL_CANVAS_ITEM_CLASS (group_parent_class)->destroy) (object);
}
/* Update handler for canvas groups */
@@ -1530,8 +1557,14 @@ eel_canvas_group_unmap (EelCanvasItem *item)
/* Draw handler for canvas groups */
static void
+#if GTK_CHECK_VERSION(3,0,0)
+eel_canvas_group_draw (EelCanvasItem *item,
+ cairo_t *cr,
+ cairo_region_t *region)
+#else
eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose)
+#endif
{
EelCanvasGroup *group;
GList *list;
@@ -1553,8 +1586,13 @@ eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable,
child_rect.width = child->x2 - child->x1 + 1;
child_rect.height = child->y2 - child->y1 + 1;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (cairo_region_contains_rectangle (region, &child_rect) != CAIRO_REGION_OVERLAP_OUT)
+ EEL_CANVAS_ITEM_GET_CLASS (child)->draw (child, cr, region);
+#else
if (gdk_region_rect_in (expose->region, &child_rect) != GDK_OVERLAP_RECTANGLE_OUT)
(* EEL_CANVAS_ITEM_GET_CLASS (child)->draw) (child, drawable, expose);
+#endif
}
}
}
@@ -1714,12 +1752,7 @@ eel_canvas_group_bounds (EelCanvasItem *item, double *x1, double *y1, double *x2
static void
group_add (EelCanvasGroup *group, EelCanvasItem *item)
{
-#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14)
g_object_ref_sink (item);
-#else
- g_object_ref (item);
- gtk_object_sink (GTK_OBJECT (item));
-#endif
if (!group->item_list)
{
@@ -1787,7 +1820,11 @@ enum
static void eel_canvas_class_init (EelCanvasClass *klass);
static void eel_canvas_init (EelCanvas *canvas);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void eel_canvas_destroy (GtkWidget *object);
+#else
static void eel_canvas_destroy (GtkObject *object);
+#endif
static void eel_canvas_map (GtkWidget *widget);
static void eel_canvas_unmap (GtkWidget *widget);
static void eel_canvas_realize (GtkWidget *widget);
@@ -1798,8 +1835,13 @@ static gint eel_canvas_button (GtkWidget *widget,
GdkEventButton *event);
static gint eel_canvas_motion (GtkWidget *widget,
GdkEventMotion *event);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gint eel_canvas_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
static gint eel_canvas_expose (GtkWidget *widget,
GdkEventExpose *event);
+#endif
static gint eel_canvas_key (GtkWidget *widget,
GdkEventKey *event);
static gint eel_canvas_crossing (GtkWidget *widget,
@@ -1810,11 +1852,14 @@ static gint eel_canvas_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static void eel_canvas_request_update_real (EelCanvas *canvas);
static void eel_canvas_draw_background (EelCanvas *canvas,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr);
+#else
int x,
int y,
int width,
int height);
-
+#endif
static GtkLayoutClass *canvas_parent_class;
@@ -1907,11 +1952,11 @@ eel_canvas_accessible_initialize (AtkObject *obj,
ATK_OBJECT_CLASS (accessible_parent_class)->initialize (obj, data);
canvas = EEL_CANVAS (data);
- g_signal_connect (gtk_layout_get_hadjustment (&canvas->layout),
+ g_signal_connect (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)),
"value_changed",
G_CALLBACK (eel_canvas_accessible_adjustment_changed),
obj);
- g_signal_connect (gtk_layout_get_vadjustment (&canvas->layout),
+ g_signal_connect (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)),
"value_changed",
G_CALLBACK (eel_canvas_accessible_adjustment_changed),
obj);
@@ -2102,11 +2147,9 @@ static void
eel_canvas_class_init (EelCanvasClass *klass)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
gobject_class = (GObjectClass *)klass;
- object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
canvas_parent_class = g_type_class_peek_parent (klass);
@@ -2114,8 +2157,11 @@ eel_canvas_class_init (EelCanvasClass *klass)
gobject_class->set_property = eel_canvas_set_property;
gobject_class->get_property = eel_canvas_get_property;
- object_class->destroy = eel_canvas_destroy;
-
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GTK_OBJECT_CLASS (klass)->destroy = eel_canvas_destroy;
+#else
+ widget_class->destroy = eel_canvas_destroy;
+#endif
widget_class->map = eel_canvas_map;
widget_class->unmap = eel_canvas_unmap;
widget_class->realize = eel_canvas_realize;
@@ -2124,7 +2170,11 @@ eel_canvas_class_init (EelCanvasClass *klass)
widget_class->button_press_event = eel_canvas_button;
widget_class->button_release_event = eel_canvas_button;
widget_class->motion_notify_event = eel_canvas_motion;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = eel_canvas_draw;
+#else
widget_class->expose_event = eel_canvas_expose;
+#endif
widget_class->key_press_event = eel_canvas_key;
widget_class->key_release_event = eel_canvas_key;
widget_class->enter_notify_event = eel_canvas_crossing;
@@ -2137,13 +2187,19 @@ eel_canvas_class_init (EelCanvasClass *klass)
canvas_signals[DRAW_BACKGROUND] =
g_signal_new ("draw_background",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EelCanvasClass, draw_background),
NULL, NULL,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ CAIRO_GOBJECT_TYPE_CONTEXT);
+#else
eel_marshal_VOID__INT_INT_INT_INT,
G_TYPE_NONE, 4,
G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
+#endif
atk_registry_set_factory_type (atk_get_default_registry (),
EEL_TYPE_CANVAS,
@@ -2154,7 +2210,7 @@ eel_canvas_class_init (EelCanvasClass *klass)
* never ever do this, so we panic if this happens.
*/
static void
-panic_root_destroyed (GtkObject *object, gpointer data)
+panic_root_destroyed (GtkWidget *object, gpointer data)
{
g_error ("Eeeek, root item %p of canvas %p was destroyed!", object, data);
}
@@ -2170,7 +2226,7 @@ eel_canvas_init (EelCanvas *canvas)
canvas->scroll_x1 = 0.0;
canvas->scroll_y1 = 0.0;
- gtk_layout_get_size (&canvas->layout,
+ gtk_layout_get_size (GTK_LAYOUT (canvas),
&width, &height);
canvas->scroll_x2 = width;
canvas->scroll_y2 = height;
@@ -2181,20 +2237,15 @@ eel_canvas_init (EelCanvas *canvas)
canvas->pick_event.crossing.x = 0;
canvas->pick_event.crossing.y = 0;
- gtk_layout_set_hadjustment (GTK_LAYOUT (canvas), NULL);
- gtk_layout_set_vadjustment (GTK_LAYOUT (canvas), NULL);
+ gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (canvas), NULL);
+ gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (canvas), NULL);
/* Create the root item as a special case */
canvas->root = EEL_CANVAS_ITEM (g_object_new (eel_canvas_group_get_type (), NULL));
canvas->root->canvas = canvas;
-#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14)
g_object_ref_sink (canvas->root);
-#else
- g_object_ref (canvas->root);
- gtk_object_sink (GTK_OBJECT (canvas->root));
-#endif
canvas->root_destroy_id = g_signal_connect (G_OBJECT (canvas->root),
"destroy", G_CALLBACK (panic_root_destroyed), canvas);
@@ -2240,7 +2291,11 @@ shutdown_transients (EelCanvas *canvas)
/* Destroy handler for EelCanvas */
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+eel_canvas_destroy (GtkWidget *object)
+#else
eel_canvas_destroy (GtkObject *object)
+#endif
{
EelCanvas *canvas;
@@ -2259,14 +2314,19 @@ eel_canvas_destroy (GtkObject *object)
{
EelCanvasItem *root = canvas->root;
canvas->root = NULL;
- gtk_object_destroy (GTK_OBJECT (root));
+ eel_canvas_item_destroy (root);
g_object_unref (root);
}
shutdown_transients (canvas);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (GTK_WIDGET_CLASS (canvas_parent_class)->destroy)
+ (* GTK_WIDGET_CLASS (canvas_parent_class)->destroy) (object);
+#else
if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy)
(* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object);
+#endif
}
/**
@@ -2347,8 +2407,8 @@ eel_canvas_realize (GtkWidget *widget)
canvas = EEL_CANVAS (widget);
- gdk_window_set_events (gtk_layout_get_bin_window (&canvas->layout),
- (gdk_window_get_events (gtk_layout_get_bin_window (&canvas->layout))
+ gdk_window_set_events (gtk_layout_get_bin_window (GTK_LAYOUT (canvas)),
+ (gdk_window_get_events (gtk_layout_get_bin_window (GTK_LAYOUT (canvas)))
| GDK_EXPOSURE_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
@@ -2361,8 +2421,6 @@ eel_canvas_realize (GtkWidget *widget)
/* Create our own temporary pixmap gc and realize all the items */
- canvas->pixmap_gc = gdk_gc_new (gtk_layout_get_bin_window (&canvas->layout));
-
(* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->realize) (canvas->root);
}
@@ -2382,9 +2440,6 @@ eel_canvas_unrealize (GtkWidget *widget)
(* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->unrealize) (canvas->root);
- g_object_unref (canvas->pixmap_gc);
- canvas->pixmap_gc = NULL;
-
if (GTK_WIDGET_CLASS (canvas_parent_class)->unrealize)
(* GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (widget);
}
@@ -2482,8 +2537,8 @@ scroll_to (EelCanvas *canvas, int cx, int cy)
gtk_widget_queue_draw (GTK_WIDGET (canvas));
}
- hadjustment = gtk_layout_get_hadjustment (&canvas->layout);
- vadjustment = gtk_layout_get_vadjustment (&canvas->layout);
+ hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
if (((int) gtk_adjustment_get_value (hadjustment)) != cx)
{
@@ -2527,8 +2582,8 @@ eel_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
/* Recenter the view, if appropriate */
- hadjustment = gtk_layout_get_hadjustment (&canvas->layout);
- vadjustment = gtk_layout_get_vadjustment (&canvas->layout);
+ hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
gtk_adjustment_set_page_size (hadjustment, allocation->width);
gtk_adjustment_set_page_increment (hadjustment, allocation->width / 2);
@@ -2672,14 +2727,14 @@ emit_event (EelCanvas *canvas, GdkEvent *event)
while (item && !finished)
{
- g_object_ref (GTK_OBJECT (item));
+ g_object_ref (item);
g_signal_emit (
G_OBJECT (item), item_signals[ITEM_EVENT], 0,
&ev, &finished);
parent = item->parent;
- g_object_unref (GTK_OBJECT (item));
+ g_object_unref (item);
item = parent;
}
@@ -2861,7 +2916,7 @@ eel_canvas_button (GtkWidget *widget, GdkEventButton *event)
* dispatch normally regardless of the event's window if an item has
* has a pointer grab in effect
*/
- if (!canvas->grabbed_item && event->window != gtk_layout_get_bin_window (&canvas->layout))
+ if (!canvas->grabbed_item && event->window != gtk_layout_get_bin_window (GTK_LAYOUT (canvas)))
return retval;
switch (event->button)
@@ -2929,7 +2984,7 @@ eel_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
canvas = EEL_CANVAS (widget);
- if (event->window != gtk_layout_get_bin_window (&canvas->layout))
+ if (event->window != gtk_layout_get_bin_window (GTK_LAYOUT (canvas)))
return FALSE;
canvas->state = event->state;
@@ -2968,7 +3023,7 @@ eel_canvas_crossing (GtkWidget *widget, GdkEventCrossing *event)
canvas = EEL_CANVAS (widget);
- if (event->window != gtk_layout_get_bin_window (&canvas->layout))
+ if (event->window != gtk_layout_get_bin_window (GTK_LAYOUT (canvas)))
return FALSE;
canvas->state = event->state;
@@ -3003,18 +3058,80 @@ eel_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event)
return FALSE;
}
+
+#if GTK_CHECK_VERSION(3,0,0)
+static cairo_region_t *
+eel_cairo_get_clip_region (cairo_t *cr)
+{
+ cairo_rectangle_list_t *list;
+ cairo_region_t *region;
+ int i;
+
+ list = cairo_copy_clip_rectangle_list (cr);
+ if (list->status == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE) {
+ cairo_rectangle_int_t clip_rect;
+
+ cairo_rectangle_list_destroy (list);
+
+ if (!gdk_cairo_get_clip_rectangle (cr, &clip_rect))
+ return NULL;
+ return cairo_region_create_rectangle (&clip_rect);
+ }
+
+
+ region = cairo_region_create ();
+ for (i = list->num_rectangles - 1; i >= 0; --i) {
+ cairo_rectangle_t *rect = &list->rectangles[i];
+ cairo_rectangle_int_t clip_rect;
+
+ clip_rect.x = floor (rect->x);
+ clip_rect.y = floor (rect->y);
+ clip_rect.width = ceil (rect->x + rect->width) - clip_rect.x;
+ clip_rect.height = ceil (rect->y + rect->height) - clip_rect.y;
+
+ if (cairo_region_union_rectangle (region, &clip_rect) != CAIRO_STATUS_SUCCESS) {
+ cairo_region_destroy (region);
+ region = NULL;
+ break;
+ }
+ }
+
+ cairo_rectangle_list_destroy (list);
+ return region;
+}
+#endif
+
/* Expose handler for the canvas */
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean
+eel_canvas_draw (GtkWidget *widget, cairo_t *cr)
+#else
static gint
eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event)
+#endif
{
- EelCanvas *canvas;
+ EelCanvas *canvas = EEL_CANVAS (widget);
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkWindow *bin_window;
+ cairo_region_t *region;
- canvas = EEL_CANVAS (widget);
+ if (!gdk_cairo_get_clip_rectangle (cr, NULL))
+ return FALSE;
+
+ bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
+ gtk_cairo_transform_to_window (cr, widget, bin_window);
+ region = eel_cairo_get_clip_region (cr);
+ if (region == NULL)
+ return FALSE;
+#else
if (!gtk_widget_is_drawable (widget) || (event->window != gtk_layout_get_bin_window (&canvas->layout))) return FALSE;
+#endif
-#ifdef VERBOSE
- g_print ("Expose\n");
+#if defined VERBOSE && GTK_CHECK_VERSION(3,0,0)
+ g_print ("Draw\n");
+#elif defined VERBOSE
+ g_print ("Expose\n");
#endif
/* If there are any outstanding items that need updating, do them now */
if (canvas->idle_id)
@@ -3039,37 +3156,68 @@ eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event)
/* Hmmm. Would like to queue antiexposes if the update marked
anything that is gonna get redrawn as invalid */
-
g_signal_emit (G_OBJECT (canvas), canvas_signals[DRAW_BACKGROUND], 0,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr);
+#else
event->area.x, event->area.y,
event->area.width, event->area.height);
+#endif
if (canvas->root->flags & EEL_CANVAS_ITEM_MAPPED)
- (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->draw) (canvas->root,
- gtk_layout_get_bin_window (&canvas->layout),
- event);
-
-
+ EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->draw (canvas->root,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr, region);
+#else
+ gtk_layout_get_bin_window (&canvas->layout),
+ event);
+#endif
/* Chain up to get exposes on child widgets */
+#if !GTK_CHECK_VERSION(3,0,0)
GTK_WIDGET_CLASS (canvas_parent_class)->expose_event (widget, event);
+#else
+ if (GTK_WIDGET_CLASS (canvas_parent_class)->draw)
+ GTK_WIDGET_CLASS (canvas_parent_class)->draw (widget, cr);
+ cairo_region_destroy (region);
+#endif
return FALSE;
}
+
+#if GTK_CHECK_VERSION(3,0,0)
+static void
+eel_canvas_draw_background (EelCanvas *canvas,
+ cairo_t *cr)
+{
+ cairo_rectangle_int_t rect;
+
+ if (!gdk_cairo_get_clip_rectangle (cr, &rect))
+ return;
+
+ cairo_save (cr);
+ /* By default, we use the style background. */
+ gdk_cairo_set_source_color (cr, &gtk_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]);
+ gdk_cairo_rectangle (cr, &rect);
+ cairo_fill (cr);
+ cairo_restore (cr);
+}
+#else /* GTK_CHECK_VERSION(3,0,0) */
static void
eel_canvas_draw_background (EelCanvas *canvas,
int x, int y, int width, int height)
{
+ cairo_t *cr = gdk_cairo_create (gtk_layout_get_bin_window (&canvas->layout));
+
/* By default, we use the style background. */
- gdk_gc_set_foreground (canvas->pixmap_gc,
- &gtk_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]);
- gdk_draw_rectangle (gtk_layout_get_bin_window (&canvas->layout),
- canvas->pixmap_gc,
- TRUE,
- x, y,
- width, height);
+ gdk_cairo_set_source_color (cr, &gtk_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
}
+#endif /* GTK_CHECK_VERSION(3,0,0) */
static void
do_update (EelCanvas *canvas)
@@ -3193,8 +3341,8 @@ eel_canvas_set_scroll_region (EelCanvas *canvas, double x1, double y1, double x2
* Set the new scrolling region. If possible, do not move the visible contents of the
* canvas.
*/
- hadjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (canvas));
- vadjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (canvas));
+ hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
eel_canvas_c2w (canvas,
gtk_adjustment_get_value (hadjustment) + canvas->zoom_xofs,
@@ -3260,8 +3408,8 @@ eel_canvas_set_center_scroll_region (EelCanvas *canvas,
canvas->center_scroll_region = center_scroll_region != 0;
- hadjustment = gtk_layout_get_hadjustment (&canvas->layout);
- vadjustment = gtk_layout_get_vadjustment (&canvas->layout);
+ hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (&canvas->layout));
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (&canvas->layout));
scroll_to (canvas,
gtk_adjustment_get_value (hadjustment),
@@ -3300,8 +3448,8 @@ eel_canvas_set_pixels_per_unit (EelCanvas *canvas, double n)
center_y = allocation.height / 2;
/* Find the coordinates of the screen center in units. */
- hadjustment = gtk_layout_get_hadjustment (&canvas->layout);
- vadjustment = gtk_layout_get_vadjustment (&canvas->layout);
+ hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
cx = (gtk_adjustment_get_value (hadjustment) + center_x) / canvas->pixels_per_unit + canvas->scroll_x1 + canvas->zoom_xofs;
cy = (gtk_adjustment_get_value (vadjustment) + center_y) / canvas->pixels_per_unit + canvas->scroll_y1 + canvas->zoom_yofs;
@@ -3332,14 +3480,20 @@ eel_canvas_set_pixels_per_unit (EelCanvas *canvas, double n)
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
+#if GTK_CHECK_VERSION(3,0,0)
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+#else
+ attributes.colormap = gtk_widget_get_colormap (widget);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+#endif
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
+#if !GTK_CHECK_VERSION(3,0,0)
gdk_window_set_back_pixmap (window, NULL, FALSE);
+#endif
gdk_window_set_user_data (window, widget);
gdk_window_show (window);
@@ -3399,8 +3553,8 @@ eel_canvas_get_scroll_offsets (EelCanvas *canvas, int *cx, int *cy)
g_return_if_fail (EEL_IS_CANVAS (canvas));
- hadjustment = gtk_layout_get_hadjustment (&canvas->layout);
- vadjustment = gtk_layout_get_vadjustment (&canvas->layout);
+ hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
if (cx)
*cx = gtk_adjustment_get_value (hadjustment);
@@ -3500,7 +3654,7 @@ eel_canvas_request_redraw (EelCanvas *canvas, int x1, int y1, int x2, int y2)
bbox.width = x2 - x1;
bbox.height = y2 - y1;
- gdk_window_invalidate_rect (gtk_layout_get_bin_window (&canvas->layout),
+ gdk_window_invalidate_rect (gtk_layout_get_bin_window (GTK_LAYOUT (canvas)),
&bbox, FALSE);
}
@@ -3679,8 +3833,6 @@ eel_canvas_world_to_window (EelCanvas *canvas, double worldx, double worldy,
int
eel_canvas_get_color (EelCanvas *canvas, const char *spec, GdkColor *color)
{
- GdkColormap *colormap;
-
g_return_val_if_fail (EEL_IS_CANVAS (canvas), FALSE);
g_return_val_if_fail (color != NULL, FALSE);
@@ -3695,63 +3847,9 @@ eel_canvas_get_color (EelCanvas *canvas, const char *spec, GdkColor *color)
gdk_color_parse (spec, color);
- colormap = gtk_widget_get_colormap (GTK_WIDGET (canvas));
-
- gdk_rgb_find_color (colormap, color);
-
return TRUE;
}
-/**
- * eel_canvas_get_color_pixel:
- * @canvas: A canvas.
- * @rgba: RGBA color specification.
- *
- * Allocates a color from the RGBA value passed into this function. The alpha
- * opacity value is discarded, since normal X colors do not support it.
- *
- * Return value: Allocated pixel value corresponding to the specified color.
- **/
-gulong
-eel_canvas_get_color_pixel (EelCanvas *canvas, guint rgba)
-{
- GdkColormap *colormap;
- GdkColor color;
-
- g_return_val_if_fail (EEL_IS_CANVAS (canvas), 0);
-
- color.red = ((rgba & 0xff000000) >> 16) + ((rgba & 0xff000000) >> 24);
- color.green = ((rgba & 0x00ff0000) >> 8) + ((rgba & 0x00ff0000) >> 16);
- color.blue = (rgba & 0x0000ff00) + ((rgba & 0x0000ff00) >> 8);
- color.pixel = 0;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (canvas));
-
- gdk_rgb_find_color (colormap, &color);
-
- return color.pixel;
-}
-
-
-/* FIXME: This function is not useful anymore */
-/**
- * eel_canvas_set_stipple_origin:
- * @canvas: A canvas.
- * @gc: GC on which to set the stipple origin.
- *
- * Sets the stipple origin of the specified GC as is appropriate for the canvas,
- * so that it will be aligned with other stipple patterns used by canvas items.
- * This is typically only needed by item implementations.
- **/
-void
-eel_canvas_set_stipple_origin (EelCanvas *canvas, GdkGC *gc)
-{
- g_return_if_fail (EEL_IS_CANVAS (canvas));
- g_return_if_fail (GDK_IS_GC (gc));
-
- gdk_gc_set_ts_origin (gc, 0, 0);
-}
-
static gboolean
boolean_handled_accumulator (GSignalInvocationHint *ihint,
GValue *return_accu,
@@ -4068,7 +4166,7 @@ eel_canvas_item_accessible_get_type (void)
GTypeInfo tinfo = { 0 };
factory = atk_registry_get_factory (atk_get_default_registry(),
- GTK_TYPE_OBJECT);
+ G_TYPE_INITIALLY_UNOWNED);
if (!factory)
{
return G_TYPE_INVALID;
@@ -4201,6 +4299,15 @@ eel_canvas_item_class_init (EelCanvasItemClass *klass)
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ item_signals[ITEM_DESTROY] =
+ g_signal_new ("destroy",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (EelCanvasItemClass, destroy),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
klass->realize = eel_canvas_item_realize;
klass->unrealize = eel_canvas_item_unrealize;
klass->map = eel_canvas_item_map;
diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h
index 2f799c39..8f49141a 100644
--- a/eel/eel-canvas.h
+++ b/eel/eel-canvas.h
@@ -115,7 +115,7 @@ extern "C" {
struct _EelCanvasItem
{
- GtkObject object;
+ GInitiallyUnowned object;
/* Parent canvas for this item */
EelCanvas *canvas;
@@ -132,7 +132,9 @@ extern "C" {
struct _EelCanvasItemClass
{
- GtkObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
+
+ void (* destroy) (EelCanvasItem *item);
/* Tell the item to update itself. The flags are from the update flags
* defined above. The item should update its internal state from its
@@ -157,7 +159,11 @@ extern "C" {
* coordinates of the drawable, a temporary pixmap, where things get
* drawn. (width, height) are the dimensions of the drawable.
*/
+#if GTK_CHECK_VERSION(3,0,0)
+ void (* draw) (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region);
+#else
void (* draw) (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose);
+#endif
/* Calculate the distance from an item to the specified point. It also
* returns a canvas item which is the item itself in the case of the
@@ -195,6 +201,8 @@ extern "C" {
EelCanvasItem *eel_canvas_item_new (EelCanvasGroup *parent, GType type,
const gchar *first_arg_name, ...);
+ void eel_canvas_item_destroy (EelCanvasItem *item);
+
/* Constructors for use in derived classes and language wrappers */
void eel_canvas_item_construct (EelCanvasItem *item, EelCanvasGroup *parent,
const gchar *first_arg_name, va_list args);
@@ -372,9 +380,6 @@ extern "C" {
/* If non-NULL, the currently focused item */
EelCanvasItem *focused_item;
- /* GC for temporary draw pixmap */
- GdkGC *pixmap_gc;
-
/* Event on which selection of current item is based */
GdkEvent pick_event;
@@ -433,7 +438,11 @@ extern "C" {
/* Draw the background for the area given.
*/
void (* draw_background) (EelCanvas *canvas,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr);
+#else
int x, int y, int width, int height);
+#endif
/* Private Virtual methods for groping the canvas inside matecomponent */
void (* request_update) (EelCanvas *canvas);
@@ -527,16 +536,6 @@ extern "C" {
*/
int eel_canvas_get_color (EelCanvas *canvas, const char *spec, GdkColor *color);
- /* Allocates a color from the RGB value passed into this function. */
- gulong eel_canvas_get_color_pixel (EelCanvas *canvas,
- guint rgba);
-
-
- /* Sets the stipple origin of the specified gc so that it will be aligned with
- * all the stipples used in the specified canvas. This is intended for use only
- * by canvas item implementations.
- */
- void eel_canvas_set_stipple_origin (EelCanvas *canvas, GdkGC *gc);
#ifdef __cplusplus
}
diff --git a/eel/eel-debug-drawing.c b/eel/eel-debug-drawing.c
index 50ea70a4..63706829 100644
--- a/eel/eel-debug-drawing.c
+++ b/eel/eel-debug-drawing.c
@@ -32,7 +32,6 @@
#include "eel-gdk-pixbuf-extensions.h"
#include "eel-gtk-extensions.h"
#include "eel-gtk-extensions.h"
-#include "eel-gtk-macros.h"
#include <gtk/gtk.h>
@@ -73,29 +72,7 @@ struct DebugPixbufViewerClass
GtkWidgetClass parent_class;
};
-/* GtkObjectClass methods */
-static void debug_pixbuf_viewer_class_init (DebugPixbufViewerClass *pixbuf_viewer_class);
-static void debug_pixbuf_viewer_init (DebugPixbufViewer *pixbuf_viewer);
-static void debug_pixbuf_viewer_finalize (GObject *object);
-
-/* GtkWidgetClass methods */
-static void debug_pixbuf_viewer_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static int debug_pixbuf_viewer_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-
-EEL_CLASS_BOILERPLATE (DebugPixbufViewer, debug_pixbuf_viewer, GTK_TYPE_WIDGET)
-
-static void
-debug_pixbuf_viewer_class_init (DebugPixbufViewerClass *pixbuf_viewer_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (pixbuf_viewer_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (pixbuf_viewer_class);
-
- object_class->finalize = debug_pixbuf_viewer_finalize;
- widget_class->size_request = debug_pixbuf_viewer_size_request;
- widget_class->expose_event = debug_pixbuf_viewer_expose_event;
-}
+G_DEFINE_TYPE (DebugPixbufViewer, debug_pixbuf_viewer, GTK_TYPE_WIDGET)
static void
debug_pixbuf_viewer_init (DebugPixbufViewer *viewer)
@@ -113,7 +90,7 @@ debug_pixbuf_viewer_finalize (GObject *object)
eel_gdk_pixbuf_unref_if_not_null (viewer->pixbuf);
viewer->pixbuf = NULL;
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (debug_pixbuf_viewer_parent_class)->finalize (object);
}
static void
@@ -184,13 +161,9 @@ debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event)
eel_gdk_pixbuf_draw_to_drawable (viewer->pixbuf,
event->window,
- gtk_widget_get_style (widget)->white_gc,
clipped_bounds.x0 - bounds.x0,
clipped_bounds.y0 - bounds.y0,
- clipped_bounds,
- GDK_RGB_DITHER_NONE,
- GDK_PIXBUF_ALPHA_BILEVEL,
- EEL_STANDARD_ALPHA_THRESHHOLD);
+ clipped_bounds);
}
}
@@ -203,6 +176,17 @@ debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event)
}
static void
+debug_pixbuf_viewer_class_init (DebugPixbufViewerClass *pixbuf_viewer_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (pixbuf_viewer_class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (pixbuf_viewer_class);
+
+ object_class->finalize = debug_pixbuf_viewer_finalize;
+ widget_class->size_request = debug_pixbuf_viewer_size_request;
+ widget_class->expose_event = debug_pixbuf_viewer_expose_event;
+}
+
+static void
debug_pixbuf_viewer_set_pixbuf (DebugPixbufViewer *viewer, GdkPixbuf *pixbuf)
{
g_assert (DEBUG_IS_PIXBUF_VIEWER (viewer));
@@ -229,7 +213,7 @@ eel_debug_draw_rectangle_and_cross (GdkDrawable *drawable,
guint32 color,
gboolean draw_cross)
{
- GdkGC *gc;
+ cairo_t *cr;
GdkColor color_gdk = { 0 };
int width;
@@ -241,43 +225,32 @@ eel_debug_draw_rectangle_and_cross (GdkDrawable *drawable,
width = rectangle.x1 - rectangle.x0;
height = rectangle.y1 - rectangle.y0;
- gc = gdk_gc_new (drawable);
- gdk_gc_set_function (gc, GDK_COPY);
+ cr = gdk_cairo_create (drawable);
color_gdk.red = ((color >> 16) & 0xff) << 8;
color_gdk.green = ((color >> 8) & 0xff) << 8;
color_gdk.blue = ((color ) & 0xff) << 8;
- gdk_colormap_alloc_color (
- gdk_drawable_get_colormap (drawable),
- &color_gdk, FALSE, FALSE);
- gdk_gc_set_rgb_fg_color (gc, &color_gdk);
-
- gdk_draw_rectangle (drawable,
- gc,
- FALSE,
- rectangle.x0,
- rectangle.y0,
- width - 1,
- height - 1);
+ gdk_cairo_set_source_color (cr, &color_gdk);
+ cairo_set_line_width (cr, 1.0);
+
+ cairo_rectangle (cr,
+ rectangle.x0 + 0.5,
+ rectangle.y0 + 0.5,
+ width,
+ height);
if (draw_cross)
{
- gdk_draw_line (drawable,
- gc,
- rectangle.x0,
- rectangle.y0,
- rectangle.x0 + width - 1,
- rectangle.y0 + height - 1);
-
- gdk_draw_line (drawable,
- gc,
- rectangle.x0 + width - 1,
- rectangle.y0,
- rectangle.x0,
- rectangle.y0 + height - 1);
+ cairo_move_to (cr, rectangle.x0, rectangle.y0);
+ cairo_line_to (cr, rectangle.x0 + width, rectangle.y0 + height);
+
+ cairo_move_to (cr, rectangle.x0 + width, rectangle.y0);
+ cairo_line_to (cr, rectangle.x0, rectangle.y0 + height);
}
- g_object_unref (gc);
+ cairo_stroke (cr);
+
+ cairo_destroy (cr);
}
/**
@@ -377,8 +350,6 @@ eel_debug_show_pixbuf (GdkPixbuf *pixbuf)
gtk_box_pack_start (GTK_BOX (vbox), debug_image, TRUE, TRUE, 0);
- eel_gtk_widget_set_background_color (debug_window, "white");
-
eel_debug_call_at_shutdown (destroy_debug_window);
gtk_widget_show (debug_image);
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index 7780fe7f..f7ec2d41 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -28,15 +28,22 @@
#include <string.h>
#include "eel-editable-label.h"
-#include "eel-i18n.h"
#include "eel-marshal.h"
#include "eel-accessibility.h"
#include <libgail-util/gailmisc.h>
+#include <glib/gi18n-lib.h>
#include <pango/pango.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */
+#if !GTK_CHECK_VERSION (3, 0, 0)
+#define cairo_region_t GdkRegion
+#define cairo_region_destroy gdk_region_destroy
+#define GtkEditableInterface GtkEditableClass
+#endif
+
enum
{
MOVE_CURSOR,
@@ -61,7 +68,7 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
-static void eel_editable_label_editable_init (GtkEditableClass *iface);
+static void eel_editable_label_editable_init (GtkEditableInterface *iface);
static void eel_editable_label_class_init (EelEditableLabelClass *klass);
static void eel_editable_label_init (EelEditableLabel *label);
static void eel_editable_label_set_property (GObject *object,
@@ -73,8 +80,17 @@ static void eel_editable_label_get_property (GObject
GValue *value,
GParamSpec *pspec);
static void eel_editable_label_finalize (GObject *object);
+#if GTK_CHECK_VERSION(3,0,0)
+static void eel_editable_label_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void eel_editable_label_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+#else
static void eel_editable_label_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+ GtkRequisition *requisition);
+#endif
static void eel_editable_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void eel_editable_label_state_changed (GtkWidget *widget,
@@ -83,8 +99,13 @@ static void eel_editable_label_style_set (GtkWidget
GtkStyle *previous_style);
static void eel_editable_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
+#if GTK_CHECK_VERSION(3,0,0)
+static gint eel_editable_label_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
static gint eel_editable_label_expose (GtkWidget *widget,
- GdkEventExpose *event);
+ GdkEventExpose *event);
+#endif
static void eel_editable_label_realize (GtkWidget *widget);
static void eel_editable_label_unrealize (GtkWidget *widget);
static void eel_editable_label_map (GtkWidget *widget);
@@ -176,10 +197,6 @@ static void editable_real_set_position (GtkEditable *editable,
gint position);
static gint editable_get_position (GtkEditable *editable);
-static GdkGC * make_cursor_gc (GtkWidget *widget,
- const gchar *property_name,
- GdkColor *fallback);
-
G_DEFINE_TYPE_WITH_CODE (EelEditableLabel, eel_editable_label, GTK_TYPE_MISC,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, eel_editable_label_editable_init));
@@ -210,7 +227,6 @@ static void
eel_editable_label_class_init (EelEditableLabelClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkBindingSet *binding_set;
@@ -218,12 +234,21 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
gobject_class->get_property = eel_editable_label_get_property;
gobject_class->finalize = eel_editable_label_finalize;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = eel_editable_label_get_preferred_width;
+ widget_class->get_preferred_height = eel_editable_label_get_preferred_height;
+#else
widget_class->size_request = eel_editable_label_size_request;
+#endif
widget_class->size_allocate = eel_editable_label_size_allocate;
widget_class->state_changed = eel_editable_label_state_changed;
widget_class->style_set = eel_editable_label_style_set;
widget_class->direction_changed = eel_editable_label_direction_changed;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->draw = eel_editable_label_draw;
+#else
widget_class->expose_event = eel_editable_label_expose;
+#endif
widget_class->realize = eel_editable_label_realize;
widget_class->unrealize = eel_editable_label_unrealize;
widget_class->map = eel_editable_label_map;
@@ -247,7 +272,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
signals[MOVE_CURSOR] =
g_signal_new ("move_cursor",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EelEditableLabelClass, move_cursor),
NULL, NULL,
@@ -256,7 +281,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
signals[COPY_CLIPBOARD] =
g_signal_new ("copy_clipboard",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EelEditableLabelClass, copy_clipboard),
NULL, NULL,
@@ -265,7 +290,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
signals[POPULATE_POPUP] =
g_signal_new ("populate_popup",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EelEditableLabelClass, populate_popup),
NULL, NULL,
@@ -274,7 +299,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
signals[DELETE_FROM_CURSOR] =
g_signal_new ("delete_from_cursor",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EelEditableLabelClass, delete_from_cursor),
NULL, NULL,
@@ -283,7 +308,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
signals[CUT_CLIPBOARD] =
g_signal_new ("cut_clipboard",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EelEditableLabelClass, cut_clipboard),
NULL, NULL,
@@ -292,7 +317,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
signals[PASTE_CLIPBOARD] =
g_signal_new ("paste_clipboard",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EelEditableLabelClass, paste_clipboard),
NULL, NULL,
@@ -301,7 +326,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
signals[TOGGLE_OVERWRITE] =
g_signal_new ("toggle_overwrite",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EelEditableLabelClass, toggle_overwrite),
NULL, NULL,
@@ -309,7 +334,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
G_TYPE_NONE, 0);
- g_object_class_install_property (G_OBJECT_CLASS(object_class),
+ g_object_class_install_property (gobject_class,
PROP_TEXT,
g_param_spec_string ("text",
_("Text"),
@@ -360,159 +385,159 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
binding_set = gtk_binding_set_by_class (class);
/* Moving the insertion point */
- add_move_binding (binding_set, GDK_Right, 0,
+ add_move_binding (binding_set, GDK_KEY_Right, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
- add_move_binding (binding_set, GDK_Left, 0,
+ add_move_binding (binding_set, GDK_KEY_Left, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
- add_move_binding (binding_set, GDK_KP_Right, 0,
+ add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
- add_move_binding (binding_set, GDK_KP_Left, 0,
+ add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
- add_move_binding (binding_set, GDK_f, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_f, GDK_CONTROL_MASK,
GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
- add_move_binding (binding_set, GDK_b, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_b, GDK_CONTROL_MASK,
GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
- add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
GTK_MOVEMENT_WORDS, 1);
- add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
GTK_MOVEMENT_WORDS, -1);
- add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
GTK_MOVEMENT_WORDS, 1);
- add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
GTK_MOVEMENT_WORDS, -1);
- add_move_binding (binding_set, GDK_a, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
GTK_MOVEMENT_PARAGRAPH_ENDS, -1);
- add_move_binding (binding_set, GDK_e, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_e, GDK_CONTROL_MASK,
GTK_MOVEMENT_PARAGRAPH_ENDS, 1);
- add_move_binding (binding_set, GDK_f, GDK_MOD1_MASK,
+ add_move_binding (binding_set, GDK_KEY_f, GDK_MOD1_MASK,
GTK_MOVEMENT_WORDS, 1);
- add_move_binding (binding_set, GDK_b, GDK_MOD1_MASK,
+ add_move_binding (binding_set, GDK_KEY_b, GDK_MOD1_MASK,
GTK_MOVEMENT_WORDS, -1);
- add_move_binding (binding_set, GDK_Home, 0,
+ add_move_binding (binding_set, GDK_KEY_Home, 0,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
- add_move_binding (binding_set, GDK_End, 0,
+ add_move_binding (binding_set, GDK_KEY_End, 0,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
- add_move_binding (binding_set, GDK_KP_Home, 0,
+ add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
- add_move_binding (binding_set, GDK_KP_End, 0,
+ add_move_binding (binding_set, GDK_KEY_KP_End, 0,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
- add_move_binding (binding_set, GDK_Home, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK,
GTK_MOVEMENT_BUFFER_ENDS, -1);
- add_move_binding (binding_set, GDK_End, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK,
GTK_MOVEMENT_BUFFER_ENDS, 1);
- add_move_binding (binding_set, GDK_KP_Home, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
GTK_MOVEMENT_BUFFER_ENDS, -1);
- add_move_binding (binding_set, GDK_KP_End, GDK_CONTROL_MASK,
+ add_move_binding (binding_set, GDK_KEY_KP_End, GDK_CONTROL_MASK,
GTK_MOVEMENT_BUFFER_ENDS, 1);
- add_move_binding (binding_set, GDK_Up, 0,
+ add_move_binding (binding_set, GDK_KEY_Up, 0,
GTK_MOVEMENT_DISPLAY_LINES, -1);
- add_move_binding (binding_set, GDK_KP_Up, 0,
+ add_move_binding (binding_set, GDK_KEY_KP_Up, 0,
GTK_MOVEMENT_DISPLAY_LINES, -1);
- add_move_binding (binding_set, GDK_Down, 0,
+ add_move_binding (binding_set, GDK_KEY_Down, 0,
GTK_MOVEMENT_DISPLAY_LINES, 1);
- add_move_binding (binding_set, GDK_KP_Down, 0,
+ add_move_binding (binding_set, GDK_KEY_KP_Down, 0,
GTK_MOVEMENT_DISPLAY_LINES, 1);
/* Select all
*/
- gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
"move_cursor", 3,
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
G_TYPE_INT, -1,
G_TYPE_BOOLEAN, FALSE);
- gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
"move_cursor", 3,
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
G_TYPE_INT, 1,
G_TYPE_BOOLEAN, TRUE);
/* Deleting text */
- gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0,
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_CHARS,
G_TYPE_INT, 1);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0,
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_CHARS,
G_TYPE_INT, 1);
- gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0,
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_CHARS,
G_TYPE_INT, -1);
/* Make this do the same as Backspace, to help with mis-typing */
- gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK,
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_CHARS,
G_TYPE_INT, -1);
- gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_CONTROL_MASK,
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
G_TYPE_INT, 1);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_CONTROL_MASK,
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
G_TYPE_INT, 1);
- gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK,
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
G_TYPE_INT, -1);
/* Cut/copy/paste */
- gtk_binding_entry_add_signal (binding_set, GDK_x, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_x, GDK_CONTROL_MASK,
"cut_clipboard", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_c, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
"copy_clipboard", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_v, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_v, GDK_CONTROL_MASK,
"paste_clipboard", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_SHIFT_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK,
"cut_clipboard", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_CONTROL_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_CONTROL_MASK,
"copy_clipboard", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_SHIFT_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_SHIFT_MASK,
"paste_clipboard", 0);
/* Overwrite */
- gtk_binding_entry_add_signal (binding_set, GDK_Insert, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, 0,
"toggle_overwrite", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, 0,
"toggle_overwrite", 0);
}
static void
-eel_editable_label_editable_init (GtkEditableClass *iface)
+eel_editable_label_editable_init (GtkEditableInterface *iface)
{
iface->do_insert_text = editable_insert_text_emit;
iface->do_delete_text = editable_delete_text_emit;
@@ -1137,6 +1162,32 @@ eel_editable_label_size_request (GtkWidget *widget,
requisition->height = height;
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void
+eel_editable_label_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GtkRequisition requisition;
+
+ eel_editable_label_size_request (widget, &requisition);
+
+ *minimum = *natural = requisition.width;
+}
+
+static void
+eel_editable_label_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GtkRequisition requisition;
+
+ eel_editable_label_size_request (widget, &requisition);
+
+ *minimum = *natural = requisition.height;
+}
+#endif
+
static void
eel_editable_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -1163,7 +1214,6 @@ eel_editable_label_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
EelEditableLabel *label;
- static GdkColor gray = { 0, 0x8888, 0x8888, 0x8888 };
g_assert (EEL_IS_EDITABLE_LABEL (widget));
@@ -1181,26 +1231,6 @@ eel_editable_label_style_set (GtkWidget *widget,
style = gtk_widget_get_style (widget);
gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]);
-
- if (label->primary_cursor_gc != NULL)
- {
- gtk_gc_release (label->primary_cursor_gc);
- label->primary_cursor_gc = NULL;
- }
-
- if (label->secondary_cursor_gc != NULL)
- {
- gtk_gc_release (label->secondary_cursor_gc);
- label->secondary_cursor_gc = NULL;
- }
-
- label->primary_cursor_gc = make_cursor_gc (widget,
- "cursor-color",
- &style->black);
-
- label->secondary_cursor_gc = make_cursor_gc (widget,
- "secondary-cursor-color",
- &gray);
}
}
@@ -1235,7 +1265,11 @@ get_layout_location (EelEditableLabel *label,
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
xalign = 1.0 - xalign;
- gtk_widget_get_child_requisition (widget, &req);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_get_preferred_size (widget, &req, NULL);
+#else
+ gtk_widget_size_request (widget, &req);
+#endif
gtk_misc_get_padding (misc, &xpad, &ypad);
gtk_widget_get_allocation (widget, &allocation);
@@ -1403,98 +1437,12 @@ eel_editable_label_get_block_cursor_location (EelEditableLabel *label,
/* These functions are copies from gtk+, as they are not exported from gtk+ */
-static GdkGC *
-make_cursor_gc (GtkWidget *widget,
- const gchar *property_name,
- GdkColor *fallback)
-{
- GdkGCValues gc_values;
- GdkGCValuesMask gc_values_mask;
- GdkColor *cursor_color;
- GtkStyle *style;
-
- style = gtk_widget_get_style (widget);
- gtk_widget_style_get (widget, property_name, &cursor_color, NULL);
-
- gc_values_mask = GDK_GC_FOREGROUND;
- if (cursor_color)
- {
- gc_values.foreground = *cursor_color;
- gdk_color_free (cursor_color);
- }
- else
- gc_values.foreground = *fallback;
-
- gdk_rgb_find_color (style->colormap, &gc_values.foreground);
- return gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-}
-
-static void
-_eel_draw_insertion_cursor (GtkWidget *widget,
- GdkDrawable *drawable,
- GdkGC *gc,
- GdkRectangle *location,
- GtkTextDirection direction,
- gboolean draw_arrow)
-{
- gint stem_width;
- gint arrow_width;
- gint x, y;
- gint i;
- gfloat cursor_aspect_ratio;
- gint offset;
-
- g_assert (direction != GTK_TEXT_DIR_NONE);
-
- gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL);
-
- stem_width = location->height * cursor_aspect_ratio + 1;
- arrow_width = stem_width + 1;
-
- /* put (stem_width % 2) on the proper side of the cursor */
- if (direction == GTK_TEXT_DIR_LTR)
- offset = stem_width / 2;
- else
- offset = stem_width - stem_width / 2;
-
- for (i = 0; i < stem_width; i++)
- gdk_draw_line (drawable, gc,
- location->x + i - offset, location->y,
- location->x + i - offset, location->y + location->height - 1);
-
- if (draw_arrow)
- {
- if (direction == GTK_TEXT_DIR_RTL)
- {
- x = location->x - offset - 1;
- y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
-
- for (i = 0; i < arrow_width; i++)
- {
- gdk_draw_line (drawable, gc,
- x, y + i + 1,
- x, y + 2 * arrow_width - i - 1);
- x --;
- }
- }
- else if (direction == GTK_TEXT_DIR_LTR)
- {
- x = location->x + stem_width - offset;
- y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
-
- for (i = 0; i < arrow_width; i++)
- {
- gdk_draw_line (drawable, gc,
- x, y + i + 1,
- x, y + 2 * arrow_width - i - 1);
- x++;
- }
- }
- }
-}
-
static void
+#if GTK_CHECK_VERSION(3,0,0)
+eel_editable_label_draw_cursor (EelEditableLabel *label, cairo_t *cr, gint xoffset, gint yoffset)
+#else
eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yoffset)
+#endif
{
if (gtk_widget_is_drawable (GTK_WIDGET (label)))
{
@@ -1561,10 +1509,15 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (cursor1->height);
- _eel_draw_insertion_cursor (widget, gtk_widget_get_window (widget),
- label->primary_cursor_gc,
- &cursor_location, dir1,
- dir2 != GTK_TEXT_DIR_NONE);
+ gtk_draw_insertion_cursor (widget,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+ &cursor_location,
+#else
+ gtk_widget_get_window (widget),
+ NULL, &cursor_location,
+#endif
+ TRUE, dir1, dir2 != GTK_TEXT_DIR_NONE);
if (dir2 != GTK_TEXT_DIR_NONE)
{
@@ -1573,58 +1526,80 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (cursor2->height);
- _eel_draw_insertion_cursor (widget, gtk_widget_get_window (widget),
- label->secondary_cursor_gc,
- &cursor_location, dir2, TRUE);
+ gtk_draw_insertion_cursor (widget,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+ &cursor_location,
+#else
+ gtk_widget_get_window (widget),
+ NULL, &cursor_location,
+#endif
+ FALSE, dir2, TRUE);
}
}
else /* Block cursor */
{
- GdkRegion *clip;
-
- gdk_draw_rectangle (gtk_widget_get_window (widget), label->primary_cursor_gc, TRUE,
- xoffset + PANGO_PIXELS (strong_pos.x),
- yoffset + PANGO_PIXELS (strong_pos.y),
- PANGO_PIXELS (strong_pos.width),
- PANGO_PIXELS (strong_pos.height));
+ cairo_region_t *clip;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#endif
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr,
+ xoffset + PANGO_PIXELS (strong_pos.x),
+ yoffset + PANGO_PIXELS (strong_pos.y),
+ PANGO_PIXELS (strong_pos.width),
+ PANGO_PIXELS (strong_pos.height));
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_fill (cr);
+#endif
if (!block_at_line_end)
{
clip = gdk_pango_layout_get_clip_region (label->layout,
- xoffset, yoffset,
- range, 1);
+ xoffset, yoffset,
+ range, 1);
- /* FIXME should use gtk_paint, but it can't use a clip
- * region
- */
+ gdk_cairo_region (cr, clip);
+ cairo_clip (cr);
+ gdk_cairo_set_source_color (cr,
+ &gtk_widget_get_style (widget)->base[GTK_STATE_NORMAL]);
+ cairo_move_to (cr, xoffset, yoffset);
+ pango_cairo_show_layout (cr, label->layout);
- gdk_gc_set_clip_region (label->primary_cursor_gc, clip);
-
- gdk_draw_layout_with_colors (gtk_widget_get_window (widget),
- label->primary_cursor_gc,
- xoffset, yoffset,
- label->layout,
- &gtk_widget_get_style (widget)->base[GTK_STATE_NORMAL],
- NULL);
-
- gdk_gc_set_clip_region (label->primary_cursor_gc, NULL);
- gdk_region_destroy (clip);
+ cairo_region_destroy (clip);
}
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
+ cairo_destroy (cr);
+#endif
}
}
}
static gint
+#if GTK_CHECK_VERSION(3,0,0)
+eel_editable_label_draw (GtkWidget *widget,
+ cairo_t *cr)
+#else
eel_editable_label_expose (GtkWidget *widget,
GdkEventExpose *event)
+#endif
{
EelEditableLabel *label;
GtkStyle *style;
gint x, y;
g_assert (EEL_IS_EDITABLE_LABEL (widget));
+#if !GTK_CHECK_VERSION(3,0,0)
g_assert (event != NULL);
+#endif
label = EEL_EDITABLE_LABEL (widget);
style = gtk_widget_get_style (widget);
@@ -1637,10 +1612,16 @@ eel_editable_label_expose (GtkWidget *widget,
get_layout_location (label, &x, &y);
gtk_paint_layout (style,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+#else
gtk_widget_get_window (widget),
+#endif
gtk_widget_get_state (widget),
TRUE,
+#if !GTK_CHECK_VERSION(3,0,0)
&event->area,
+#endif
widget,
"label",
x, y,
@@ -1650,7 +1631,7 @@ eel_editable_label_expose (GtkWidget *widget,
{
gint range[2];
const char *text;
- GdkRegion *clip;
+ cairo_region_t *clip;
GtkStateType state;
range[0] = label->selection_anchor;
@@ -1658,7 +1639,7 @@ eel_editable_label_expose (GtkWidget *widget,
/* Handle possible preedit string */
if (label->preedit_length > 0 &&
- range[1] > label->selection_anchor)
+ range[1] > label->selection_anchor)
{
text = pango_layout_get_text (label->layout) + label->selection_anchor;
range[1] += g_utf8_offset_to_pointer (text, label->preedit_length) - text;
@@ -1672,44 +1653,60 @@ eel_editable_label_expose (GtkWidget *widget,
}
clip = gdk_pango_layout_get_clip_region (label->layout,
- x, y,
- range,
- 1);
-
- /* FIXME should use gtk_paint, but it can't use a clip
- * region
- */
-
- gdk_gc_set_clip_region (style->black_gc, clip);
-
+ x, y,
+ range,
+ 1);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#endif
+ gdk_cairo_region (cr, clip);
+ cairo_clip (cr);
state = GTK_STATE_SELECTED;
if (!gtk_widget_has_focus (widget))
state = GTK_STATE_ACTIVE;
- gdk_draw_layout_with_colors (gtk_widget_get_window (widget),
- style->black_gc,
- x, y,
- label->layout,
- &style->text[state],
- &style->base[state]);
+ gdk_cairo_set_source_color (cr, &style->base[state]);
+ cairo_paint (cr);
- gdk_gc_set_clip_region (style->black_gc, NULL);
- gdk_region_destroy (clip);
+ gdk_cairo_set_source_color (cr, &style->text[state]);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_layout (cr, label->layout);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
+ cairo_destroy (cr);
+#endif
+ cairo_region_destroy (clip);
}
else if (gtk_widget_has_focus (widget))
+#if GTK_CHECK_VERSION(3,0,0)
+ eel_editable_label_draw_cursor (label, cr, x, y);
+#else
eel_editable_label_draw_cursor (label, x, y);
+#endif
if (label->draw_outline)
{
GtkAllocation allocation;
+
gtk_widget_get_allocation (widget, &allocation);
- gdk_draw_rectangle (gtk_widget_get_window (widget),
- style->text_gc [gtk_widget_get_state (widget)],
- FALSE,
- 0, 0,
- allocation.width - 1,
- allocation.height - 1);
+#if !GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#endif
+ gdk_cairo_set_source_color (cr, &style->text [gtk_widget_get_state (widget)]);
+ cairo_set_line_width (cr, 1.0);
+ cairo_rectangle (cr, 0.5, 0.5,
+ allocation.width - 1,
+ allocation.height - 1);
+ cairo_stroke (cr);
+
+#if !GTK_CHECK_VERSION(3,0,0)
+ cairo_destroy (cr);
+#endif
}
}
@@ -1722,7 +1719,6 @@ eel_editable_label_realize (GtkWidget *widget)
EelEditableLabel *label;
GdkWindowAttr attributes;
gint attributes_mask;
- static GdkColor gray = { 0, 0x8888, 0x8888, 0x8888 };
GtkAllocation allocation;
GdkWindow *window;
GtkStyle *style;
@@ -1738,7 +1734,9 @@ eel_editable_label_realize (GtkWidget *widget)
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.visual = gtk_widget_get_visual (widget);
+#if !GTK_CHECK_VERSION(3,0,0)
attributes.colormap = gtk_widget_get_colormap (widget);
+#endif
attributes.cursor = gdk_cursor_new (GDK_XTERM);
attributes.event_mask = gtk_widget_get_events (widget) |
(GDK_EXPOSURE_MASK |
@@ -1751,7 +1749,11 @@ eel_editable_label_realize (GtkWidget *widget)
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
+#if GTK_CHECK_VERSION(3,0,0)
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_CURSOR;
+#else
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR;
+#endif
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
@@ -1766,14 +1768,6 @@ eel_editable_label_realize (GtkWidget *widget)
gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]);
gtk_im_context_set_client_window (label->im_context, gtk_widget_get_window (widget));
-
- label->primary_cursor_gc = make_cursor_gc (widget,
- "cursor-color",
- &style->black);
-
- label->secondary_cursor_gc = make_cursor_gc (widget,
- "secondary-cursor-color",
- &gray);
}
static void
@@ -1783,12 +1777,6 @@ eel_editable_label_unrealize (GtkWidget *widget)
label = EEL_EDITABLE_LABEL (widget);
- gtk_gc_release (label->primary_cursor_gc);
- label->primary_cursor_gc = NULL;
-
- gtk_gc_release (label->secondary_cursor_gc);
- label->secondary_cursor_gc = NULL;
-
/* Strange. Copied from GtkEntry, should be NULL? */
gtk_im_context_set_client_window (label->im_context, NULL);
@@ -3087,7 +3075,7 @@ activate_cb (GtkWidget *menuitem,
EelEditableLabel *label)
{
const gchar *signal = g_object_get_data (G_OBJECT (menuitem), "gtk-signal");
- g_signal_emit_by_name (GTK_OBJECT (label), signal);
+ g_signal_emit_by_name (label, signal);
}
static void
@@ -3221,7 +3209,7 @@ popup_targets_received (GtkClipboard *clipboard,
gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (label->im_context),
GTK_MENU_SHELL (submenu));
- g_signal_emit (GTK_OBJECT (label),
+ g_signal_emit (label,
signals[POPULATE_POPUP], 0,
label->popup_menu);
diff --git a/eel/eel-editable-label.h b/eel/eel-editable-label.h
index 249a3367..b19c2417 100644
--- a/eel/eel-editable-label.h
+++ b/eel/eel-editable-label.h
@@ -79,9 +79,6 @@ extern "C" {
int preedit_length; /* length of preedit string, in bytes */
int preedit_cursor; /* offset of cursor within preedit string, in chars */
- GdkGC *primary_cursor_gc;
- GdkGC *secondary_cursor_gc;
-
PangoFontDescription *font_desc;
};
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index 86a8600e..ed694277 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -40,48 +40,6 @@
#define GRADIENT_BAND_SIZE 4
/**
- * eel_gdk_rectangle_contains_rectangle:
- * @outer: Rectangle possibly containing another rectangle.
- * @inner: Rectangle that might be inside.
- *
- * Retun TRUE if inner rectangle is contained inside outer rectangle
- */
-gboolean
-eel_gdk_rectangle_contains_rectangle (GdkRectangle outer, GdkRectangle inner)
-{
- return outer.x <= inner.x && outer.x + outer.width >= inner.x + inner.width
- && outer.y <= inner.y && outer.y + outer.height >= inner.y + inner.height;
-}
-
-/**
- * eel_interpolate_color:
- * @ratio: Place on line between colors to interpolate.
- * @start_color: Color for one end.
- * @end_color: Color for the other end
- * @interpolated_color: Result.
- *
- * Compute a color between @start_color and @end_color in color space.
- * Currently, the color space used is RGB, but a future version could
- * instead do the interpolation in the best color space for expressing
- * human perception.
- */
-guint32
-eel_interpolate_color (gdouble ratio,
- guint32 start_rgb,
- guint32 end_rgb)
-{
- guchar red, green, blue;
-
- g_return_val_if_fail (ratio >= 0.0, 0);
- g_return_val_if_fail (ratio <= 1.0, 0);
-
- red = ((start_rgb >> 16) & 0xFF) * (1.0 - ratio) + ((end_rgb >> 16) & 0xFF) * ratio;
- green = ((start_rgb >> 8) & 0xFF) * (1.0 - ratio) + ((end_rgb >> 8) & 0xFF) * ratio;
- blue = (start_rgb & 0xFF) * (1.0 - ratio) + (end_rgb & 0xFF) * ratio;
- return (((red << 8) | green) << 8) | blue;
-}
-
-/**
* eel_gradient_new
* @start_color: Color for the top or left.
* @end_color: Color for the bottom or right.
@@ -387,26 +345,6 @@ eel_gdk_color_parse_with_white_default (const char *color_spec,
}
}
-/**
- * eel_parse_rgb_with_white_default
- * @color_spec: A color spec, or NULL.
- * Returns: An rgb value.
- *
- * The same as gdk_color_parse, except sets the color to white if
- * the spec. can't be parsed instead of returning a boolean flag
- * and returns a guint32 rgb value instead of a GdkColor.
- */
-guint32
-eel_parse_rgb_with_white_default (const char *color_spec)
-{
- GdkColor color;
-
- eel_gdk_color_parse_with_white_default (color_spec, &color);
- return ((color.red << 8) & EEL_RGB_COLOR_RED)
- | (color.green & EEL_RGB_COLOR_GREEN)
- | ((color.blue >> 8) & EEL_RGB_COLOR_BLUE);
-}
-
guint32
eel_rgb16_to_rgb (gushort r, gushort g, gushort b)
{
@@ -476,51 +414,6 @@ eel_gdk_rgb_to_color_spec (const guint32 color)
return g_strdup_printf ("#%06X", (guint) (color & 0xFFFFFF));
}
-static guint32
-eel_shift_color_component (guchar component, float shift_by)
-{
- guint32 result;
- if (shift_by > 1.0)
- {
- result = component * (2 - shift_by);
- }
- else
- {
- result = 0xff - shift_by * (0xff - component);
- }
-
- return result & 0xff;
-}
-
-/**
- * eel_rgb_shift_color
- * @color: A color.
- * @shift_by: darken or lighten factor.
- * Returns: An darkened or lightened rgb value.
- *
- * Darkens (@shift_by > 1) or lightens (@shift_by < 1)
- * @color.
- */
-guint32
-eel_rgb_shift_color (guint32 color, float shift_by)
-{
- guint32 result;
-
- /* shift red by shift_by */
- result = eel_shift_color_component((color & 0x00ff0000) >> 16, shift_by);
- result <<= 8;
- /* shift green by shift_by */
- result |= eel_shift_color_component((color & 0x0000ff00) >> 8, shift_by);
- result <<= 8;
- /* shift blue by shift_by */
- result |= eel_shift_color_component((color & 0x000000ff), shift_by);
-
- /* alpha doesn't change */
- result |= (0xff000000 & color);
-
- return result;
-}
-
/**
* eel_gdk_color_is_dark:
*
@@ -538,169 +431,6 @@ eel_gdk_color_is_dark (GdkColor *color)
return intensity < 128;
}
-/**
- * eel_stipple_bitmap_for_screen:
- *
- * Get pointer to 50% stippled bitmap suitable for use
- * on @screen. This is a global object; do not free.
- */
-GdkBitmap *
-eel_stipple_bitmap_for_screen (GdkScreen *screen)
-{
- static char stipple_bits[] = { 0x02, 0x01 };
- static GPtrArray *stipples = NULL;
- int screen_num, n_screens, i;
-
- if (stipples == NULL)
- {
- n_screens = gdk_display_get_n_screens (
- gdk_screen_get_display (screen));
- stipples = g_ptr_array_sized_new (n_screens);
-
- for (i = 0; i < n_screens; i++)
- {
- g_ptr_array_index (stipples, i) = NULL;
- }
- }
-
- screen_num = gdk_screen_get_number (screen);
-
- if (g_ptr_array_index (stipples, screen_num) == NULL)
- {
- g_ptr_array_index (stipples, screen_num) =
- gdk_bitmap_create_from_data (
- gdk_screen_get_root_window (screen),
- stipple_bits, 2, 2);
- }
-
- return g_ptr_array_index (stipples, screen_num);
-}
-
-/**
- * eel_stipple_bitmap:
- *
- * Get pointer to 50% stippled bitmap suitable for use
- * on the default screen. This is a global object; do
- * not free.
- *
- * This method is not multiscreen safe. Do not use it.
- */
-GdkBitmap *
-eel_stipple_bitmap (void)
-{
- return eel_stipple_bitmap_for_screen (gdk_screen_get_default ());
-}
-
-/**
- * eel_gdk_window_bring_to_front:
- *
- * Raise window and give it focus.
- */
-void
-eel_gdk_window_bring_to_front (GdkWindow *window)
-{
- /* This takes care of un-iconifying the window and
- * raising it if needed.
- */
- gdk_window_show (window);
-
- /* If the window was already showing, it would not have
- * the focus at this point. Do a little X trickery to
- * ensure it is focused.
- */
- eel_gdk_window_focus (window, GDK_CURRENT_TIME);
-}
-
-void
-eel_gdk_window_focus (GdkWindow *window, guint32 timestamp)
-{
- gdk_error_trap_push ();
- XSetInputFocus (GDK_DISPLAY (),
- GDK_WINDOW_XWINDOW (window),
- RevertToParent,
- timestamp);
- gdk_flush();
- gdk_error_trap_pop ();
-}
-
-void
-eel_gdk_window_set_wm_protocols (GdkWindow *window,
- GdkAtom *protocols,
- int nprotocols)
-{
- Atom *atoms;
- int i;
-
- atoms = g_new (Atom, nprotocols);
- for (i = 0; i < nprotocols; i++)
- {
- atoms[i] = gdk_x11_atom_to_xatom (protocols[i]);
- }
-
- XSetWMProtocols (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XWINDOW (window),
- atoms, nprotocols);
-
- g_free (atoms);
-}
-
-/**
- * eel_gdk_window_set_wm_hints_input:
- *
- * Set the WM_HINTS.input flag to the passed in value
- */
-void
-eel_gdk_window_set_wm_hints_input (GdkWindow *window, gboolean status)
-{
- Display *dpy;
- Window id;
- XWMHints *wm_hints;
-
- g_return_if_fail (window != NULL);
-
- dpy = GDK_WINDOW_XDISPLAY (window);
- id = GDK_WINDOW_XWINDOW (window);
-
- wm_hints = XGetWMHints (dpy, id);
- if (wm_hints == 0)
- {
- wm_hints = XAllocWMHints ();
- }
-
- wm_hints->flags |= InputHint;
- wm_hints->input = (status == FALSE) ? False : True;
-
- XSetWMHints (dpy, id, wm_hints);
- XFree (wm_hints);
-}
-
-void
-eel_gdk_window_set_invisible_cursor (GdkWindow *window)
-{
- GdkBitmap *empty_bitmap;
- GdkCursor *cursor;
- GdkColor useless;
- char invisible_cursor_bits[] = { 0x0 };
-
- useless.red = useless.green = useless.blue = 0;
- useless.pixel = 0;
-
- empty_bitmap = gdk_bitmap_create_from_data (window,
- invisible_cursor_bits,
- 1, 1);
-
- cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
- empty_bitmap,
- &useless,
- &useless, 0, 0);
-
- gdk_window_set_cursor (window, cursor);
-
- gdk_cursor_unref (cursor);
-
- g_object_unref (empty_bitmap);
-}
-
EelGdkGeometryFlags
eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
guint *width_return, guint *height_return)
@@ -747,23 +477,37 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
}
void
+#if GTK_CHECK_VERSION(3,0,0)
+eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+#else
eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
- GdkGC *gc,
+#endif
GdkColor *text_color,
GdkColor *shadow_color,
int x,
int y,
PangoLayout *layout)
{
- gdk_draw_layout_with_colors (drawable, gc,
- x+1, y+1,
- layout,
- shadow_color, NULL);
-
- gdk_draw_layout_with_colors (drawable, gc,
- x, y,
- layout,
- text_color, NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr;
+ cr = gdk_cairo_create (drawable);
+#endif
+
+ gdk_cairo_set_source_color (cr, shadow_color);
+ cairo_move_to (cr, x+1, y+1);
+ pango_cairo_show_layout (cr, layout);
+
+ gdk_cairo_set_source_color (cr, text_color);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_layout (cr, layout);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore
+#else
+ cairo_destroy (cr);
+#endif
}
#if ! defined (EEL_OMIT_SELF_CHECK)
@@ -797,12 +541,6 @@ eel_self_check_gdk_rgb_to_color (guint32 color)
void
eel_self_check_gdk_extensions (void)
{
- /* eel_interpolate_color */
- EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (0.0, 0, 0), 0);
- EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (0.0, 0, 0xFFFFFF), 0);
- EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (0.5, 0, 0xFFFFFF), 0x7F7F7F);
- EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (1.0, 0, 0xFFFFFF), 0xFFFFFF);
-
/* eel_gradient_new */
EEL_CHECK_STRING_RESULT (eel_gradient_new ("", "", FALSE), "");
EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "b", FALSE), "a-b");
diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h
index 91518186..2036eec4 100644
--- a/eel/eel-gdk-extensions.h
+++ b/eel/eel-gdk-extensions.h
@@ -28,6 +28,10 @@
#include <gdk/gdk.h>
+#ifndef GTK_CHECK_VERSION
+#include <gtk/gtk.h>
+#endif
+
#define EEL_RGB_COLOR_RED 0xFF0000
#define EEL_RGB_COLOR_GREEN 0x00FF00
#define EEL_RGB_COLOR_BLUE 0x0000FF
@@ -98,16 +102,8 @@ char * eel_gradient_set_bottom_color_spec (const char
/* A version of parse_color that substitutes a default color instead of returning
a boolean to indicate it cannot be parsed.
*/
-void eel_gdk_color_parse_with_default (const char *color_spec,
- const GdkColor *default_color,
- GdkColor *parsed_color);
void eel_gdk_color_parse_with_white_default (const char *color_spec,
GdkColor *parsed_color);
-guint32 eel_parse_rgb_with_default (const char *color_spec,
- guint32 default_rgb);
-guint32 eel_parse_rgb_with_white_default (const char *color_spec);
-guint32 eel_rgb_shift_color (guint32 color,
- float shift_by);
guint32 eel_rgb16_to_rgb (gushort r,
gushort g,
gushort b);
@@ -120,45 +116,20 @@ char * eel_gdk_rgb_to_color_spec (guint32
gboolean eel_gdk_color_is_dark (GdkColor *color);
-/* A routine to get a 50% gray stippled bitmap for use in some types of highlighting. */
-GdkBitmap * eel_stipple_bitmap_for_screen (GdkScreen *screen);
-GdkBitmap * eel_stipple_bitmap (void);
-
-
-/* Misc GdkRectangle helper functions */
-gboolean eel_gdk_rectangle_contains_rectangle (GdkRectangle outer,
- GdkRectangle inner);
-
-
-/* A basic operation we use for drawing gradients is interpolating two colors.*/
-guint32 eel_interpolate_color (gdouble ratio,
- guint32 start_rgb,
- guint32 end_rgb);
-
-/* Misc GdkWindow helper functions */
-void eel_gdk_window_bring_to_front (GdkWindow *window);
-void eel_gdk_window_set_invisible_cursor (GdkWindow *window);
-void eel_gdk_window_focus (GdkWindow *window,
- guint32 timestamp);
-void eel_gdk_window_set_wm_protocols (GdkWindow *window,
- GdkAtom *protocols,
- int nprotocols);
-
-
-void eel_gdk_window_set_wm_hints_input (GdkWindow *w,
- gboolean status);
-
/* Wrapper for XParseGeometry */
EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string,
int *x_return,
int *y_return,
guint *width_return,
guint *height_return);
+#if GTK_CHECK_VERSION(3,0,0)
+void eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+#else
void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
- GdkGC *gc,
- GdkColor *text_color,
- GdkColor *shadow_color,
- int x,
- int y,
- PangoLayout *layout);
+#endif
+ GdkColor *text_color,
+ GdkColor *shadow_color,
+ int x,
+ int y,
+ PangoLayout *layout);
#endif /* EEL_GDK_EXTENSIONS_H */
diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c
index a75158db..c913cb10 100644
--- a/eel/eel-gdk-pixbuf-extensions.c
+++ b/eel/eel-gdk-pixbuf-extensions.c
@@ -26,8 +26,6 @@
#include <config.h>
#include "eel-gdk-pixbuf-extensions.h"
-#include "eel-art-gtk-extensions.h"
-#include "eel-debug-drawing.h"
#include "eel-debug.h"
#include "eel-gdk-extensions.h"
#include "eel-glib-extensions.h"
@@ -56,30 +54,6 @@ struct EelPixbufLoadHandle
char buffer[LOAD_BUFFER_SIZE];
};
-/**
- * eel_gdk_pixbuf_list_ref
- * @pixbuf_list: A list of GdkPixbuf objects.
- *
- * Refs all the pixbufs.
- **/
-void
-eel_gdk_pixbuf_list_ref (GList *pixbuf_list)
-{
- g_list_foreach (pixbuf_list, (GFunc) g_object_ref, NULL);
-}
-
-/**
- * eel_gdk_pixbuf_list_free
- * @pixbuf_list: A list of GdkPixbuf objects.
- *
- * Unrefs all the pixbufs, then frees the list.
- **/
-void
-eel_gdk_pixbuf_list_free (GList *pixbuf_list)
-{
- eel_g_list_free_deep_custom (pixbuf_list, (GFunc) g_object_unref, NULL);
-}
-
GdkPixbuf *
eel_gdk_pixbuf_load (const char *uri)
{
@@ -649,13 +623,9 @@ eel_gdk_pixbuf_unref_if_not_null (GdkPixbuf *pixbuf_or_null)
void
eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf,
GdkDrawable *drawable,
- GdkGC *gc,
int source_x,
int source_y,
- EelIRect destination_area,
- GdkRgbDither dither,
- GdkPixbufAlphaMode alpha_compositing_mode,
- int alpha_threshold)
+ EelIRect destination_area)
{
EelDimensions dimensions;
EelIRect target;
@@ -664,15 +634,11 @@ eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf,
int target_height;
int source_width;
int source_height;
+ cairo_t *cr;
g_return_if_fail (eel_gdk_pixbuf_is_valid (pixbuf));
g_return_if_fail (drawable != NULL);
- g_return_if_fail (gc != NULL);
g_return_if_fail (!eel_irect_is_empty (&destination_area));
- g_return_if_fail (alpha_threshold > EEL_OPACITY_FULLY_TRANSPARENT);
- g_return_if_fail (alpha_threshold <= EEL_OPACITY_FULLY_OPAQUE);
- g_return_if_fail (alpha_compositing_mode >= GDK_PIXBUF_ALPHA_BILEVEL);
- g_return_if_fail (alpha_compositing_mode <= GDK_PIXBUF_ALPHA_FULL);
dimensions = eel_gdk_pixbuf_get_dimensions (pixbuf);
@@ -707,16 +673,14 @@ eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf,
target.x1 = target.x0 + MIN (target_width, source_width);
target.y1 = target.y0 + MIN (target_height, source_height);
- gdk_draw_pixbuf (drawable, gc, (GdkPixbuf *) pixbuf,
- source.x0,
- source.y0,
- target.x0,
- target.y0,
+ cr = gdk_cairo_create (drawable);
+ gdk_cairo_set_source_pixbuf (cr, (GdkPixbuf *) pixbuf,
+ source.x0 - target.x0, source.y0 - target.y0);
+ cairo_rectangle (cr, target.x0, target.y0,
target.x1 - target.x0,
- target.y1 - target.y0,
- dither,
- 0,
- 0);
+ target.y1 - target.y0);
+ cairo_fill (cr);
+ cairo_destroy (cr);
}
/**
diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h
index 7d7956e4..382cd6cd 100644
--- a/eel/eel-gdk-pixbuf-extensions.h
+++ b/eel/eel-gdk-pixbuf-extensions.h
@@ -31,7 +31,6 @@
#include <gdk/gdk.h>
#include <gio/gio.h>
-#define EEL_STANDARD_ALPHA_THRESHHOLD 128
#define EEL_OPACITY_FULLY_TRANSPARENT 0
#define EEL_OPACITY_FULLY_OPAQUE 255
@@ -42,12 +41,6 @@ typedef void (* EelPixbufLoadCallback) (GError *error,
GdkPixbuf *pixbuf,
gpointer callback_data);
-/* Convenience functions for lists of GdkPixbuf objects. */
-void eel_gdk_pixbuf_list_ref (GList *pixbuf_list);
-void eel_gdk_pixbuf_list_unref (GList *pixbuf_list);
-void eel_gdk_pixbuf_list_free (GList *pixbuf_list);
-
-
/* Loading a GdkPixbuf with a URI. */
GdkPixbuf * eel_gdk_pixbuf_load (const char *uri);
GdkPixbuf * eel_gdk_pixbuf_load_from_stream (GInputStream *stream);
@@ -100,13 +93,9 @@ void eel_gdk_pixbuf_unref_if_not_null (GdkPixbuf
/* Copy a pixbuf to an area of a GdkDrawable */
void eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf,
GdkDrawable *drawable,
- GdkGC *gc,
int source_x,
int source_y,
- EelIRect destination_area,
- GdkRgbDither dither,
- GdkPixbufAlphaMode alpha_compositing_mode,
- int alpha_threshold);
+ EelIRect destination_area);
/* Copy a pixbuf to an area of another pixbuf */
void eel_gdk_pixbuf_draw_to_pixbuf (const GdkPixbuf *pixbuf,
diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c
index 67986b32..5b016aad 100644
--- a/eel/eel-glib-extensions.c
+++ b/eel/eel-glib-extensions.c
@@ -30,7 +30,6 @@
#include "eel-debug.h"
#include "eel-lib-self-check-functions.h"
#include "eel-string.h"
-#include "eel-i18n.h"
#include <glib-object.h>
#include <math.h>
#include <stdlib.h>
@@ -377,63 +376,6 @@ eel_g_str_list_index (GList *str_list,
}
/**
- * eel_g_list_free_deep_custom
- *
- * Frees the elements of a list and then the list, using a custom free function.
- *
- * @list: List of elements that can be freed with the provided free function.
- * @element_free_func: function to call with the data pointer and user_data to free it.
- * @user_data: User data to pass to element_free_func
- **/
-void
-eel_g_list_free_deep_custom (GList *list, GFunc element_free_func, gpointer user_data)
-{
- g_list_foreach (list, element_free_func, user_data);
- g_list_free (list);
-}
-
-/**
- * eel_g_list_free_deep
- *
- * Frees the elements of a list and then the list.
- * @list: List of elements that can be freed with g_free.
- **/
-void
-eel_g_list_free_deep (GList *list)
-{
- eel_g_list_free_deep_custom (list, (GFunc) g_free, NULL);
-}
-
-/**
- * eel_g_list_free_deep_custom
- *
- * Frees the elements of a list and then the list, using a custom free function.
- *
- * @list: List of elements that can be freed with the provided free function.
- * @element_free_func: function to call with the data pointer and user_data to free it.
- * @user_data: User data to pass to element_free_func
- **/
-void
-eel_g_slist_free_deep_custom (GSList *list, GFunc element_free_func, gpointer user_data)
-{
- g_slist_foreach (list, element_free_func, user_data);
- g_slist_free (list);
-}
-
-/**
- * eel_g_slist_free_deep
- *
- * Frees the elements of a list and then the list.
- * @list: List of elements that can be freed with g_free.
- **/
-void
-eel_g_slist_free_deep (GSList *list)
-{
- eel_g_slist_free_deep_custom (list, (GFunc) g_free, NULL);
-}
-
-
-/**
* eel_g_strv_find
*
* Get index of string in array of strings.
@@ -749,74 +691,6 @@ eel_round (double d)
return val;
}
-GList *
-eel_g_list_from_g_slist (GSList *slist)
-{
- GList *list;
- GSList *node;
-
- list = NULL;
- for (node = slist; node != NULL; node = node->next)
- {
- list = g_list_prepend (list, node->data);
- }
- return g_list_reverse (list);
-}
-
-GSList *
-eel_g_slist_from_g_list (GList *list)
-{
- GSList *slist;
- GList *node;
-
- slist = NULL;
- for (node = list; node != NULL; node = node->next)
- {
- slist = g_slist_prepend (slist, node->data);
- }
- return g_slist_reverse (slist);
-}
-
-/* Return the operating system name: Linux, Solaris, etc. */
-char *
-eel_get_operating_system_name (void)
-{
- struct utsname buffer;
-
- if (uname (&buffer) != -1)
- {
- /* Check for special sysnames for which there is
- * more accepted names.
- */
- if (eel_str_is_equal (buffer.sysname, "SunOS"))
- {
- return g_strdup ("Solaris");
- }
-
- return g_strdup (buffer.sysname);
- }
-
- return g_strdup ("Unix");
-}
-
-int
-eel_compare_integer (gconstpointer a,
- gconstpointer b)
-{
- int int_a;
- int int_b;
-
- int_a = GPOINTER_TO_INT (a);
- int_b = GPOINTER_TO_INT (b);
-
- if (int_a == int_b)
- {
- return 0;
- }
-
- return int_a < int_b ? -1 : 1;
-}
-
/**
* eel_g_object_list_ref
*
@@ -831,31 +705,6 @@ eel_g_object_list_ref (GList *list)
}
/**
- * eel_g_object_list_unref
- *
- * Unref all the objects in a list.
- * @list: GList of objects.
- **/
-void
-eel_g_object_list_unref (GList *list)
-{
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
-}
-
-/**
- * eel_g_object_list_free
- *
- * Free a list of objects after unrefing them.
- * @list: GList of objects.
- **/
-void
-eel_g_object_list_free (GList *list)
-{
- eel_g_object_list_unref (list);
- g_list_free (list);
-}
-
-/**
* eel_g_object_list_copy
*
* Copy the list of objects, ref'ing each one.
@@ -926,104 +775,6 @@ eel_remove_weak_pointer (gpointer pointer_location)
*object_location = NULL;
}
-/* Get the filename encoding, returns TRUE if utf8 */
-
-typedef struct _EelFilenameCharsetCache EelFilenameCharsetCache;
-
-struct _EelFilenameCharsetCache
-{
- gboolean is_utf8;
- gchar *charset;
- gchar *filename_charset;
-};
-
-static void
-filename_charset_cache_free (gpointer data)
-{
- EelFilenameCharsetCache *cache = data;
- g_free (cache->charset);
- g_free (cache->filename_charset);
- g_free (cache);
-}
-
-/*
- * eel_get_filename_charset:
- * @charset: return location for the name of the filename encoding
- *
- * Determines the character set used for filenames by consulting the
- * environment variables G_FILENAME_ENCODING and G_BROKEN_FILENAMES.
- *
- * G_FILENAME_ENCODING may be set to a comma-separated list of character
- * set names. The special token "@locale" is taken to mean the character set
- * for the current locale. The first character set from the list is taken
- * as the filename encoding.
- * If G_FILENAME_ENCODING is not set, but G_BROKEN_FILENAMES is, the
- * character set of the current locale is taken as the filename encoding.
- *
- * The returned @charset belongs to Eel and must not be freed.
- *
- * Return value: %TRUE if the charset used for filename is UTF-8.
- */
-gboolean
-eel_get_filename_charset (const gchar **filename_charset)
-{
- static GStaticPrivate cache_private = G_STATIC_PRIVATE_INIT;
- EelFilenameCharsetCache *cache = g_static_private_get (&cache_private);
- const gchar *charset;
-
- if (!cache)
- {
- cache = g_new0 (EelFilenameCharsetCache, 1);
- g_static_private_set (&cache_private, cache, filename_charset_cache_free);
- }
-
- g_get_charset (&charset);
-
- if (!(cache->charset && strcmp (cache->charset, charset) == 0))
- {
- const gchar *new_charset;
- gchar *p, *q;
-
- g_free (cache->charset);
- g_free (cache->filename_charset);
- cache->charset = g_strdup (charset);
-
- p = getenv ("G_FILENAME_ENCODING");
- if (p != NULL)
- {
- q = strchr (p, ',');
- if (!q)
- q = p + strlen (p);
-
- if (strncmp ("@locale", p, q - p) == 0)
- {
- cache->is_utf8 = g_get_charset (&new_charset);
- cache->filename_charset = g_strdup (new_charset);
- }
- else
- {
- cache->filename_charset = g_strndup (p, q - p);
- cache->is_utf8 = (strcmp (cache->filename_charset, "UTF-8") == 0);
- }
- }
- else if (getenv ("G_BROKEN_FILENAMES") != NULL)
- {
- cache->is_utf8 = g_get_charset (&new_charset);
- cache->filename_charset = g_strdup (new_charset);
- }
- else
- {
- cache->filename_charset = g_strdup ("UTF-8");
- cache->is_utf8 = TRUE;
- }
- }
-
- if (filename_charset)
- *filename_charset = cache->filename_charset;
-
- return cache->is_utf8;
-}
-
static void
update_auto_boolean (GSettings *settings,
const gchar *key,
@@ -1283,11 +1034,16 @@ eel_self_check_glib_extensions (void)
EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_4), FALSE);
EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_5), FALSE);
- eel_g_list_free_deep (compare_list_1);
- eel_g_list_free_deep (compare_list_2);
- eel_g_list_free_deep (compare_list_3);
- eel_g_list_free_deep (compare_list_4);
- eel_g_list_free_deep (compare_list_5);
+ g_list_foreach (compare_list_1, (GFunc) g_free, NULL);
+ g_list_free(compare_list_1);
+ g_list_foreach (compare_list_2, (GFunc) g_free, NULL);
+ g_list_free(compare_list_2);
+ g_list_foreach (compare_list_3, (GFunc) g_free, NULL);
+ g_list_free(compare_list_3);
+ g_list_foreach (compare_list_4, (GFunc) g_free, NULL);
+ g_list_free(compare_list_4);
+ g_list_foreach (compare_list_5, (GFunc) g_free, NULL);
+ g_list_free(compare_list_5);
/* eel_g_list_partition */
@@ -1340,27 +1096,6 @@ eel_self_check_glib_extensions (void)
setlocale (LC_TIME, "");
g_free (huge_string);
-
- /* eel_shell_quote */
- EEL_CHECK_STRING_RESULT (g_shell_quote (""), "''");
- EEL_CHECK_STRING_RESULT (g_shell_quote ("a"), "'a'");
- EEL_CHECK_STRING_RESULT (g_shell_quote ("("), "'('");
- EEL_CHECK_STRING_RESULT (g_shell_quote ("'"), "''\\'''");
- EEL_CHECK_STRING_RESULT (g_shell_quote ("'a"), "''\\''a'");
- EEL_CHECK_STRING_RESULT (g_shell_quote ("a'"), "'a'\\'''");
- EEL_CHECK_STRING_RESULT (g_shell_quote ("a'a"), "'a'\\''a'");
-
- /* eel_compare_integer */
- EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (0)), 0);
- EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (1)), -1);
- EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (1), GINT_TO_POINTER (0)), 1);
- EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (-1), GINT_TO_POINTER (0)), -1);
- EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (-1)), 1);
- EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (-1), GINT_TO_POINTER (-1)), 0);
-
-#ifdef __linux__
- EEL_CHECK_STRING_RESULT (eel_get_operating_system_name (), "Linux");
-#endif
}
#endif /* !EEL_OMIT_SELF_CHECK */
diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h
index 1093e319..907a1ec9 100644
--- a/eel/eel-glib-extensions.h
+++ b/eel/eel-glib-extensions.h
@@ -33,13 +33,6 @@
/* A gboolean variant for bit fields. */
typedef guint eel_boolean_bit;
-/* Callback functions that have user data. */
-typedef int (* EelCompareFunction) (gconstpointer a,
- gconstpointer b,
- gpointer callback_data);
-typedef int (* EelSearchFunction) (gconstpointer item,
- gpointer callback_data);
-
/* Predicate. */
typedef gboolean (* EelPredicateFunction) (gpointer data,
gpointer callback_data);
@@ -61,22 +54,6 @@ GList * eel_g_list_partition (GList *
gpointer user_data,
GList **removed);
-/* List functions for lists of g_free'able objects. */
-void eel_g_list_free_deep (GList *list);
-void eel_g_list_free_deep_custom (GList *list,
- GFunc element_free_func,
- gpointer user_data);
-
-/* GSList functions. */
-GList * eel_g_list_from_g_slist (GSList *list);
-GSList * eel_g_slist_from_g_list (GList *list);
-
-/* List functions for slists of g_free'able objects. */
-void eel_g_slist_free_deep (GSList *list);
-void eel_g_slist_free_deep_custom (GSList *list,
- GFunc element_free_func,
- gpointer user_data);
-
/* List functions for lists of C strings. */
gboolean eel_g_str_list_equal (GList *str_list_a,
GList *str_list_b);
@@ -87,8 +64,6 @@ int eel_g_str_list_index (GList *
/* List functions for lists of objects */
GList * eel_g_object_list_ref (GList *list);
-void eel_g_object_list_unref (GList *list);
-void eel_g_object_list_free (GList *list);
GList * eel_g_object_list_copy (GList *list);
/* GHashTable functions */
@@ -111,20 +86,10 @@ gint64 eel_get_system_time (void);
/* math */
int eel_round (double d);
-/* A GCompareFunc for integers */
-int eel_compare_integer (gconstpointer a,
- gconstpointer b);
-
-/* Return the operating system name: Linux, Solaris, etc. */
-char * eel_get_operating_system_name (void);
-
/* Better weak pointer functions */
void eel_add_weak_pointer (gpointer pointer_location);
void eel_remove_weak_pointer (gpointer pointer_location);
-/* Get the filename encoding, returns TRUE if utf8 */
-gboolean eel_get_filename_charset (const gchar **filename_charset);
-
void eel_g_settings_add_auto_enum (GSettings *settings,
const char *key,
int *storage);
diff --git a/eel/eel-graphic-effects.c b/eel/eel-graphic-effects.c
index b234b914..ffb5beba 100644
--- a/eel/eel-graphic-effects.c
+++ b/eel/eel-graphic-effects.c
@@ -47,22 +47,6 @@ create_new_pixbuf (GdkPixbuf *src)
gdk_pixbuf_get_height (src));
}
-static GdkPixbuf *
-create_new_pixbuf_with_alpha (GdkPixbuf *src)
-{
- g_assert (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB);
- g_assert ((!gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 3)
- || (gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 4));
-
- return gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
- TRUE,
- gdk_pixbuf_get_bits_per_sample (src),
- gdk_pixbuf_get_width (src),
- gdk_pixbuf_get_height (src));
-}
-
/* utility routine to bump the level of a color component with pinning */
static guchar
@@ -351,71 +335,3 @@ eel_embed_image_in_frame (GdkPixbuf *source_image, GdkPixbuf *frame_image, int l
return result_pixbuf;
}
-
-/* this routine takes the source pixbuf and returns a new one that's semi-transparent, by
- clearing every other pixel's alpha value in a checkerboard grip. We have to do the
- checkerboard instead of reducing the alpha since it will be turned into an alpha-less
- gdkpixmap and mask for the actual dragging */
-
-GdkPixbuf *
-eel_make_semi_transparent (GdkPixbuf *src)
-{
- gint i, j, temp_alpha;
- gint width, height, has_alpha, src_row_stride, dst_row_stride;
- guchar *target_pixels, *original_pixels;
- guchar *pixsrc, *pixdest;
- guchar alpha_value;
- GdkPixbuf *dest_pixbuf;
- guchar start_alpha_value;
-
- g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL);
- g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 3)
- || (gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 4), NULL);
- g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL);
-
- dest_pixbuf = create_new_pixbuf_with_alpha (src);
-
- has_alpha = gdk_pixbuf_get_has_alpha (src);
- width = gdk_pixbuf_get_width (src);
- height = gdk_pixbuf_get_height (src);
- src_row_stride = gdk_pixbuf_get_rowstride (src);
- dst_row_stride = gdk_pixbuf_get_rowstride (dest_pixbuf);
-
- /* set up pointers to the actual pixels */
- target_pixels = gdk_pixbuf_get_pixels (dest_pixbuf);
- original_pixels = gdk_pixbuf_get_pixels (src);
-
- /* loop through the pixels to do the actual work, copying from the source to the destination */
- start_alpha_value = ~0;
- for (i = 0; i < height; i++)
- {
- pixdest = target_pixels + i * dst_row_stride;
- pixsrc = original_pixels + i * src_row_stride;
- alpha_value = start_alpha_value;
- for (j = 0; j < width; j++)
- {
- *pixdest++ = *pixsrc++; /* red */
- *pixdest++ = *pixsrc++; /* green */
- *pixdest++ = *pixsrc++; /* blue */
-
- if (has_alpha)
- {
- temp_alpha = *pixsrc++;
- }
- else
- {
- temp_alpha = ~0;
- }
- *pixdest++ = temp_alpha & alpha_value;
-
- alpha_value = ~alpha_value;
- }
-
- start_alpha_value = ~start_alpha_value;
- }
-
- return dest_pixbuf;
-}
-
diff --git a/eel/eel-graphic-effects.h b/eel/eel-graphic-effects.h
index 7ac627f1..6ae00421 100644
--- a/eel/eel-graphic-effects.h
+++ b/eel/eel-graphic-effects.h
@@ -59,8 +59,4 @@ GdkPixbuf *eel_embed_image_in_frame (GdkPixbuf *source_image,
int right_offset,
int bottom_offset);
-/* return a semi-transparent pixbuf from the source pixbuf using a checkboard
- stipple in the alpha channel (so it can be converted to an alpha-less pixmap) */
-GdkPixbuf *eel_make_semi_transparent (GdkPixbuf *source_pixbuf);
-
#endif /* EEL_GRAPHIC_EFFECTS_H */
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index 94c4987d..5b8121b6 100644
--- a/eel/eel-gtk-extensions.c
+++ b/eel/eel-gtk-extensions.c
@@ -32,17 +32,17 @@
#include "eel-gdk-pixbuf-extensions.h"
#include "eel-glib-extensions.h"
#include "eel-mate-extensions.h"
-#include "eel-pango-extensions.h"
+#include "eel-marshal.h"
#include "eel-string.h"
+
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
#include <math.h>
-#include "eel-marshal.h"
-#include "eel-marshal.c"
/* This number is fairly arbitrary. Long enough to show a pretty long
* menu title, but not so long to make a menu grotesquely wide.
@@ -84,103 +84,6 @@ eel_gtk_window_get_geometry_string (GtkWindow *window)
}
static void
-send_delete_event (GtkWindow *window)
-{
- /* Synthesize delete_event to close window. */
-
- GdkEvent event;
- GtkWidget *widget;
-
- widget = GTK_WIDGET (window);
-
- event.any.type = GDK_DELETE;
- event.any.window = gtk_widget_get_window (widget);
- event.any.send_event = TRUE;
-
- g_object_ref (event.any.window);
- gtk_main_do_event (&event);
- g_object_unref (event.any.window);
-}
-
-static int
-handle_standard_close_accelerator (GtkWindow *window,
- GdkEventKey *event,
- gpointer user_data)
-{
- g_assert (GTK_IS_WINDOW (window));
- g_assert (event != NULL);
- g_assert (user_data == NULL);
-
- if (eel_gtk_window_event_is_close_accelerator (window, event))
- {
- send_delete_event (window);
- g_signal_stop_emission_by_name (
- G_OBJECT (window), "key_press_event");
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * eel_gtk_window_event_is_close_accelerator:
- *
- * Tests whether a key event is a standard window close accelerator.
- * Not needed for clients that use eel_gtk_window_set_up_close_accelerator;
- * use only if you must set up your own key_event handler for your own reasons.
- **/
-gboolean
-eel_gtk_window_event_is_close_accelerator (GtkWindow *window, GdkEventKey *event)
-{
- g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (event->state & GDK_CONTROL_MASK)
- {
- /* Note: menu item equivalents are case-sensitive, so we will
- * be case-sensitive here too.
- */
- if (event->keyval == EEL_STANDARD_CLOSE_WINDOW_CONTROL_KEY)
- {
- return TRUE;
- }
- }
-
-
- return FALSE;
-}
-
-/**
- * eel_gtk_window_set_up_close_accelerator:
- *
- * Sets up the standard keyboard equivalent to close the window.
- * Call this for windows that don't set up a keyboard equivalent to
- * close the window some other way, e.g. via a menu item accelerator.
- *
- * NOTE: do not use for GtkDialog, it already sets up the right
- * stuff here.
- *
- * @window: The GtkWindow that should be hidden when the standard
- * keyboard equivalent is typed.
- **/
-void
-eel_gtk_window_set_up_close_accelerator (GtkWindow *window)
-{
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- if (GTK_IS_DIALOG (window))
- {
- g_warning ("eel_gtk_window_set_up_close_accelerator: Should not mess with close accelerator on GtkDialogs");
- return;
- }
-
- g_signal_connect (window,
- "key_press_event",
- G_CALLBACK (handle_standard_close_accelerator),
- NULL);
-}
-
-static void
sanity_check_window_position (int *left, int *top)
{
g_assert (left != NULL);
@@ -430,30 +333,6 @@ eel_gtk_menu_insert_separator (GtkMenu *menu, int index)
return GTK_MENU_ITEM (menu_item);
}
-void
-eel_gtk_menu_set_item_visibility (GtkMenu *menu, int index, gboolean visible)
-{
- GList *children;
- GtkWidget *menu_item;
-
- g_return_if_fail (GTK_IS_MENU (menu));
-
- children = gtk_container_get_children (GTK_CONTAINER (menu));
- g_return_if_fail (index >= 0 && index < (int) g_list_length (children));
-
- menu_item = GTK_WIDGET (g_list_nth_data (children, index));
- if (visible)
- {
- gtk_widget_show (menu_item);
- }
- else
- {
- gtk_widget_hide (menu_item);
- }
-
- g_list_free (children);
-}
-
GtkWidget *
eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button)
{
@@ -474,296 +353,6 @@ eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button)
return button;
}
-gboolean
-eel_point_in_allocation (const GtkAllocation *allocation,
- int x, int y)
-{
- g_return_val_if_fail (allocation != NULL, FALSE);
- return x >= allocation->x
- && y >= allocation->y
- && x < allocation->x + allocation->width
- && y < allocation->y + allocation->height;
-}
-
-/* FIXME this function is dangerous, because gtk_widget_get_window (widget) coords (or
- * other window-belonging-to-widget coords) do not need to be in the
- * same coordinate system as widget->allocation.
- * If you use this function, be aware of that. Someone should probably
- * audit all uses, too.
- */
-gboolean
-eel_point_in_widget (GtkWidget *widget,
- int x, int y)
-{
- GtkAllocation allocation;
- if (widget == NULL)
- {
- return FALSE;
- }
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- gtk_widget_get_allocation (widget, &allocation);
- return eel_point_in_allocation (&allocation, x, y);
-}
-
-/**
- * eel_gtk_widget_set_shown
- *
- * Show or hide a widget.
- * @widget: The widget.
- * @shown: Boolean value indicating whether the widget should be shown or hidden.
- **/
-void
-eel_gtk_widget_set_shown (GtkWidget *widget, gboolean shown)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (shown)
- {
- gtk_widget_show (widget);
- }
- else
- {
- gtk_widget_hide (widget);
- }
-}
-
-/* This stuff is stolen from Gtk. */
-
-typedef struct DisconnectInfo
-{
- GtkObject *object1;
- guint disconnect_handler1;
- guint signal_handler;
- GtkObject *object2;
- guint disconnect_handler2;
-} DisconnectInfo;
-
-static void
-alive_disconnecter (GtkObject *object, DisconnectInfo *info)
-{
- g_assert (info != NULL);
- g_assert (GTK_IS_OBJECT (info->object1));
- g_assert (info->disconnect_handler1 != 0);
- g_assert (info->signal_handler != 0);
- g_assert (GTK_IS_OBJECT (info->object2));
- g_assert (info->disconnect_handler2 != 0);
- g_assert (object == info->object1 || object == info->object2);
-
- g_signal_handler_disconnect (info->object1, info->disconnect_handler1);
- g_signal_handler_disconnect (info->object1, info->signal_handler);
- g_signal_handler_disconnect (info->object2, info->disconnect_handler2);
-
- g_free (info);
-}
-
-/**
- * eel_gtk_signal_connect_full_while_alive
- *
- * Like gtk_signal_connect_while_alive, but works with full parameters.
- **/
-void
-eel_gtk_signal_connect_full_while_alive (GtkObject *object,
- const gchar *name,
- GCallback func,
- GtkCallbackMarshal marshal,
- gpointer data,
- GDestroyNotify destroy_func,
- gboolean object_signal,
- gboolean after,
- GtkObject *alive_object)
-{
- DisconnectInfo *info;
-
- g_return_if_fail (GTK_IS_OBJECT (object));
- g_return_if_fail (name != NULL);
- g_return_if_fail (func != NULL || marshal != NULL);
- g_return_if_fail (object_signal == FALSE || object_signal == TRUE);
- g_return_if_fail (after == FALSE || after == TRUE);
- g_return_if_fail (GTK_IS_OBJECT (alive_object));
-
- info = g_new (DisconnectInfo, 1);
- info->object1 = object;
- info->object2 = alive_object;
-
-
- info->signal_handler = g_signal_connect_closure (
- object, name,
- (object_signal
- ? g_cclosure_new_swap
- : g_cclosure_new) (func, data, (GClosureNotify) destroy_func),
- after);
-
- info->disconnect_handler1 = g_signal_connect (G_OBJECT (object),
- "destroy",
- G_CALLBACK (alive_disconnecter),
- info);
- info->disconnect_handler2 = g_signal_connect (G_OBJECT (alive_object),
- "destroy",
- G_CALLBACK (alive_disconnecter),
- info);
-}
-
-typedef struct
-{
- GtkObject *object;
- guint object_destroy_handler;
-
- GtkWidget *realized_widget;
- guint realized_widget_destroy_handler;
- guint realized_widget_unrealized_handler;
-
- guint signal_handler;
-} RealizeDisconnectInfo;
-
-static void
-while_realized_disconnecter (GtkObject *object,
- RealizeDisconnectInfo *info)
-{
- g_assert (GTK_IS_OBJECT (object));
- g_assert (info != NULL);
- g_assert (GTK_IS_OBJECT (info->object));
- g_assert (info->object_destroy_handler != 0);
- g_assert (info->object_destroy_handler != 0);
- g_assert (info->realized_widget_destroy_handler != 0);
- g_assert (info->realized_widget_unrealized_handler != 0);
-
- g_signal_handler_disconnect (info->object, info->object_destroy_handler);
- g_signal_handler_disconnect (info->object, info->signal_handler);
- g_signal_handler_disconnect (info->realized_widget, info->realized_widget_destroy_handler);
- g_signal_handler_disconnect (info->realized_widget, info->realized_widget_unrealized_handler);
- g_free (info);
-}
-
-/**
- * eel_gtk_signal_connect_while_realized:
- *
- * @object: Object to connect to.
- * @name: Name of signal to connect to.
- * @callback: Caller's callback.
- * @callback_data: Caller's callback_data.
- * @realized_widget: Widget to monitor for realized state. Signal is connected
- * while this wigget is realized.
- *
- * Connect to a signal of an object while another widget is realized. This is
- * useful for non windowed widgets that need to monitor events in their ancestored
- * windowed widget. The signal is automatically disconnected when &widget is
- * unrealized. Also, the signal is automatically disconnected when either &object
- * or &widget are destroyed.
- **/
-void
-eel_gtk_signal_connect_while_realized (GtkObject *object,
- const char *name,
- GCallback callback,
- gpointer callback_data,
- GtkWidget *realized_widget)
-{
- RealizeDisconnectInfo *info;
-
- g_return_if_fail (GTK_IS_OBJECT (object));
- g_return_if_fail (name != NULL);
- g_return_if_fail (name[0] != '\0');
- g_return_if_fail (callback != NULL);
- g_return_if_fail (GTK_IS_WIDGET (realized_widget));
- g_return_if_fail (gtk_widget_get_realized (realized_widget));
-
- info = g_new0 (RealizeDisconnectInfo, 1);
-
- info->object = object;
- info->object_destroy_handler =
- g_signal_connect (G_OBJECT (info->object),
- "destroy",
- G_CALLBACK (while_realized_disconnecter),
- info);
-
- info->realized_widget = realized_widget;
- info->realized_widget_destroy_handler =
- g_signal_connect (G_OBJECT (info->realized_widget),
- "destroy",
- G_CALLBACK (while_realized_disconnecter),
- info);
- info->realized_widget_unrealized_handler =
- g_signal_connect_after (G_OBJECT (info->realized_widget),
- "unrealize",
- G_CALLBACK (while_realized_disconnecter),
- info);
-
- info->signal_handler = g_signal_connect (G_OBJECT (info->object),
- name, callback, callback_data);
-}
-
-/**
- * eel_gtk_container_get_first_child.
- *
- * Returns the first child of a container.
- * @container: The container.
- **/
-
-static void
-get_first_callback (GtkWidget *widget, gpointer callback_data)
-{
- GtkWidget **first_child_slot;
-
- g_assert (GTK_IS_WIDGET (widget));
- g_assert (callback_data != NULL);
-
- first_child_slot = callback_data;
-
- if (*first_child_slot == NULL)
- {
- *first_child_slot = widget;
- /* We'd stop the iterating now if we could. */
- }
- else
- {
- g_assert (GTK_IS_WIDGET (*first_child_slot));
- }
-}
-
-GtkWidget *
-eel_gtk_container_get_first_child (GtkContainer *container)
-{
- GtkWidget *first_child;
-
- g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
-
- first_child = NULL;
- gtk_container_foreach (container, get_first_callback, &first_child);
- g_assert (first_child == NULL || GTK_IS_WIDGET (first_child));
- return first_child;
-}
-
-typedef struct
-{
- GtkCallback callback;
- gpointer callback_data;
-} container_foreach_deep_callback_data;
-
-static void
-container_foreach_deep_callback (GtkWidget *child, gpointer data)
-{
- container_foreach_deep_callback_data *deep_data;
-
- deep_data = (container_foreach_deep_callback_data *) data;
-
- deep_data->callback (child, deep_data->callback_data);
-
- if (GTK_IS_CONTAINER (child))
- {
- gtk_container_foreach (GTK_CONTAINER (child), container_foreach_deep_callback, data);
- }
-}
-
-void
-eel_gtk_container_foreach_deep (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data)
-{
- container_foreach_deep_callback_data deep_data;
- deep_data.callback = callback;
- deep_data.callback_data = callback_data;
- gtk_container_foreach (container, container_foreach_deep_callback, &deep_data);
-}
-
/* The standard gtk_adjustment_set_value ignores page size, which
* disagrees with the logic used by scroll bars, for example.
*/
@@ -822,276 +411,6 @@ eel_gtk_label_make_bold (GtkLabel *label)
pango_font_description_free (font_desc);
}
-/**
- * eel_gtk_label_set_scale:
- * @label:
- * @num_steps:
- *
- * Function is broken, see eel_gtk_label_make_larger() for explanation
- *
- **/
-void
-eel_gtk_label_set_scale (GtkLabel *label,
- double scale_factor)
-{
- PangoAttrList *old_attr_list;
- PangoAttrList *attr_list;
-
- g_return_if_fail (GTK_IS_LABEL (label));
- g_return_if_fail (scale_factor > 0);
-
- old_attr_list = gtk_label_get_attributes (label);
- attr_list = eel_pango_attr_list_apply_global_attribute (old_attr_list,
- pango_attr_scale_new (scale_factor));
- gtk_label_set_attributes (label, attr_list);
- pango_attr_list_unref (attr_list);
-}
-
-static void
-get_layout_location (GtkLabel *label,
- gint *xp,
- gint *yp)
-{
- GtkMisc *misc;
- GtkWidget *widget;
- float xalign, yalign;
- int x, y, xpad, ypad;
- int shadow_offset;
- GtkAllocation allocation;
- GtkRequisition req;
-
- shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-offset"));
-
- misc = GTK_MISC (label);
- widget = GTK_WIDGET (label);
- gtk_misc_get_alignment (misc, &xalign, &yalign);
- gtk_misc_get_padding (misc, &xpad, &ypad);
-
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
- xalign = 1.0 - xalign;
-
- gtk_widget_get_allocation (widget, &allocation);
- gtk_widget_get_requisition (widget, &req);
- x = floor (allocation.x + xpad
- + ((allocation.width - req.width - shadow_offset) * xalign)
- + 0.5);
-
- y = floor (allocation.y + ypad
- + ((allocation.height - req.height - shadow_offset) * yalign)
- + 0.5);
-
-
- if (xp)
- *xp = x;
-
- if (yp)
- *yp = y;
-}
-
-static gboolean
-eel_gtk_label_expose_event (GtkLabel *label, GdkEventExpose *event, gpointer user_data)
-{
- int x, y;
- GdkColor color;
- GtkWidget *widget;
- GdkGC *gc;
- guint32 shadow_color;
- int shadow_offset;
-
- shadow_color = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-color"));
- shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-offset"));
-
- color = eel_gdk_rgb_to_color (shadow_color);
-
- get_layout_location (label, &x, &y);
-
- widget = GTK_WIDGET (label);
- if (shadow_offset > 0)
- {
- gc = gdk_gc_new (gtk_widget_get_window (widget));
- gdk_gc_set_rgb_fg_color (gc, &color);
- gdk_gc_set_clip_rectangle (gc, &event->area);
-
- gdk_draw_layout (gtk_widget_get_window (widget),
- gc,
- x + shadow_offset, y + shadow_offset,
- gtk_label_get_layout (label));
- g_object_unref (gc);
- }
-
- gtk_paint_layout (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- FALSE,
- &event->area,
- widget,
- "label",
- x, y,
- gtk_label_get_layout (label));
-
- return TRUE;
-}
-
-static void
-eel_gtk_label_size_request (GtkLabel *label, GtkRequisition *requisition, gpointer user_data)
-{
- gint shadow_offset;
-
- shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label),
- "eel-label-shadow-offset"));
-
- requisition->width += shadow_offset;
- requisition->height += shadow_offset;
-}
-
-static void
-set_up_label (GtkLabel *label)
-{
-
- if (g_object_get_data (G_OBJECT (label), "eel-label-set-up") != NULL)
- {
- return;
- }
-
- g_signal_connect (label, "expose_event",
- G_CALLBACK (eel_gtk_label_expose_event), NULL);
- g_signal_connect_after (label, "size_request",
- G_CALLBACK (eel_gtk_label_size_request), NULL);
-
- g_object_set_data (G_OBJECT (label), "eel-label-set-up", "eel-label-set-up");
-}
-
-void
-eel_gtk_label_set_drop_shadow_color (GtkLabel *label,
- guint32 color)
-{
- set_up_label (label);
-
- g_object_set_data (G_OBJECT (label), "eel-label-shadow-color",
- GINT_TO_POINTER (color));
-
- gtk_widget_queue_draw (GTK_WIDGET (label));
-}
-
-void
-eel_gtk_label_set_drop_shadow_offset (GtkLabel *label,
- gint offset)
-{
- set_up_label (label);
-
- g_object_set_data (G_OBJECT (label), "eel-label-shadow-offset",
- GINT_TO_POINTER (offset));
-
- gtk_widget_queue_draw (GTK_WIDGET (label));
-}
-
-void
-eel_gtk_widget_set_background_color (GtkWidget *widget,
- const char *color_spec)
-{
- GdkColor color;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- eel_gdk_color_parse_with_white_default (color_spec, &color);
-
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_bg (widget, GTK_STATE_ACTIVE, &color);
- gtk_widget_modify_base (widget, GTK_STATE_ACTIVE, &color);
-}
-
-void
-eel_gtk_widget_set_foreground_color (GtkWidget *widget,
- const char *color_spec)
-{
- GdkColor color;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- eel_gdk_color_parse_with_white_default (color_spec, &color);
-
- gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_text (widget, GTK_STATE_NORMAL, &color);
- gtk_widget_modify_fg (widget, GTK_STATE_ACTIVE, &color);
- gtk_widget_modify_text (widget, GTK_STATE_ACTIVE, &color);
-}
-
-GtkWidget *
-eel_gtk_widget_find_windowed_ancestor (GtkWidget *widget)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- while (widget && !gtk_widget_get_has_window (widget))
- {
- widget = gtk_widget_get_parent (widget);
- }
-
- return widget;
-}
-
-/* eel_gtk_get_system_font:
- *
- * Return the system font as selected in the control center. Need to
- * g_object_unref() the result when done with it.
- *
- * Perhaps there is a better way to figure out what that font is, but
- * the following is simple enough and it works.
- */
-PangoFontDescription *
-eel_gtk_get_system_font (void)
-{
- GtkWidget *label;
- PangoFontDescription *font;
-
- label = gtk_label_new ("");
-
- gtk_widget_ensure_style (label);
-
- font = pango_font_description_copy (gtk_widget_get_style (label)->font_desc);
-
- g_object_ref_sink (label);
- g_object_unref (label);
-
- return font;
-}
-
-void
-eel_gtk_widget_get_button_event_location (GtkWidget *widget,
- const GdkEventButton *event,
- int *x,
- int *y)
-{
- int window_x, window_y;
- GtkAllocation allocation;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (event != NULL);
-
- gdk_window_get_position (event->window, &window_x, &window_y);
- gtk_widget_get_allocation (widget, &allocation);
- if (x != NULL)
- {
- *x = event->x + window_x - allocation.x;
- }
- if (y != NULL)
- {
- *y = event->y + window_y - allocation.y;
- }
-}
-
-void
-eel_gtk_widget_get_motion_event_location (GtkWidget *widget,
- const GdkEventMotion *event,
- int *x,
- int *y)
-{
- eel_gtk_widget_get_button_event_location (widget, (const GdkEventButton *) event, x, y);
-}
-
static gboolean
tree_view_button_press_callback (GtkWidget *tree_view,
GdkEventButton *event,
@@ -1147,101 +466,24 @@ eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view,
}
}
-gboolean
-eel_gtk_viewport_get_visible_rect (GtkViewport *viewport,
- GdkRectangle *rect)
-{
- GdkRectangle viewport_rect;
- GdkRectangle child_rect;
- gboolean return_val;
-
- g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), FALSE);
- g_return_val_if_fail (rect != NULL, FALSE);
-
- if (gtk_widget_get_realized (GTK_WIDGET (viewport)))
- {
- viewport_rect.x = 0;
- viewport_rect.y = 0;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- viewport_rect.width = gdk_window_get_width(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
- viewport_rect.height = gdk_window_get_height(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
-#else
- gdk_drawable_get_size(gtk_viewport_get_view_window(viewport), &viewport_rect.width, &viewport_rect.height);
-#endif
-
- gdk_window_get_position (gtk_viewport_get_bin_window (viewport),
- &child_rect.x,
- &child_rect.y);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- child_rect.width = gdk_window_get_width(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
- child_rect.height = gdk_window_get_height(GDK_WINDOW(gtk_viewport_get_view_window(viewport)));
-#else
- gdk_drawable_get_size(gtk_viewport_get_bin_window(viewport), &child_rect.width, &child_rect.height);
-#endif
-
- return_val = gdk_rectangle_intersect (&viewport_rect,
- &child_rect,
- rect);
- rect->x -= child_rect.x;
- rect->y -= child_rect.y;
-
- return return_val;
- }
-
- rect->x = rect->y = rect->width = rect->height = 0;
- return FALSE;
-}
-
void
-eel_gtk_viewport_scroll_to_rect (GtkViewport *viewport,
- GdkRectangle *rect)
+eel_gtk_message_dialog_set_details_label (GtkMessageDialog *dialog,
+ const gchar *details_text)
{
- GdkRectangle visible_rect;
- int scroll_x;
- int scroll_y;
- GtkAdjustment *adjustment;
+ GtkWidget *content_area, *expander, *label;
- g_return_if_fail (GTK_IS_VIEWPORT (viewport));
- g_return_if_fail (rect != NULL);
+ content_area = gtk_message_dialog_get_message_area (dialog);
+ expander = gtk_expander_new_with_mnemonic (_("Show more _details"));
+ gtk_expander_set_spacing (GTK_EXPANDER (expander), 6);
- if (eel_gtk_viewport_get_visible_rect (viewport, &visible_rect))
- {
- scroll_x = -1;
- scroll_y = -1;
+ label = gtk_label_new (details_text);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- if (rect->x + rect->width > visible_rect.x + visible_rect.width)
- {
- scroll_x = rect->x - (visible_rect.width - rect->width);
- }
- if (rect->y + rect->height > visible_rect.y + visible_rect.height)
- {
- scroll_y = rect->y - (visible_rect.height - rect->height);
- }
+ gtk_container_add (GTK_CONTAINER (expander), label);
+ gtk_box_pack_start (GTK_BOX (content_area), expander, FALSE, FALSE, 0);
- if (rect->x < visible_rect.x)
- {
- scroll_x = rect->x;
- }
-
- if (rect->y < visible_rect.y)
- {
- scroll_y = rect->y;
- }
-
- adjustment = gtk_viewport_get_hadjustment (viewport);
- if (adjustment && scroll_x != -1)
- {
- eel_gtk_adjustment_set_value (adjustment,
- (double)scroll_x);
- }
-
- adjustment = gtk_viewport_get_vadjustment (viewport);
- if (adjustment && scroll_y != -1)
- {
- eel_gtk_adjustment_set_value (adjustment,
- (double)scroll_y);
- }
- }
+ gtk_widget_show (label);
+ gtk_widget_show (expander);
}
diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h
index e286bf74..a5d8e60a 100644
--- a/eel/eel-gtk-extensions.h
+++ b/eel/eel-gtk-extensions.h
@@ -35,51 +35,6 @@
#define EEL_DEFAULT_POPUP_MENU_DISPLACEMENT 2
#define EEL_STANDARD_CLOSE_WINDOW_CONTROL_KEY 'w'
-/* signals */
-void eel_gtk_signal_connect_full_while_alive (GtkObject *object,
- const gchar *name,
- GCallback func,
- GtkCallbackMarshal marshal,
- gpointer data,
- GDestroyNotify destroy_func,
- gboolean object_signal,
- gboolean after,
- GtkObject *alive_object);
-void eel_gtk_signal_connect_while_realized (GtkObject *object,
- const char *name,
- GCallback callback,
- gpointer callback_data,
- GtkWidget *realized_widget);
-
-/* GtkWidget */
-void eel_gtk_widget_set_shown (GtkWidget *widget,
- gboolean shown);
-gboolean eel_point_in_allocation (const GtkAllocation *allocation,
- int x,
- int y);
-gboolean eel_point_in_widget (GtkWidget *widget,
- int x,
- int y);
-void eel_gtk_widget_set_background_color (GtkWidget *widget,
- const char *color_spec);
-void eel_gtk_widget_set_foreground_color (GtkWidget *widget,
- const char *color_spec);
-GtkWidget * eel_gtk_widget_find_windowed_ancestor (GtkWidget *widget);
-PangoFontDescription *eel_gtk_get_system_font (void);
-void eel_gtk_widget_get_button_event_location (GtkWidget *widget,
- const GdkEventButton *event,
- int *x,
- int *y);
-void eel_gtk_widget_get_motion_event_location (GtkWidget *widget,
- const GdkEventMotion *event,
- int *x,
- int *y);
-
-/* GtkContainer */
-GtkWidget * eel_gtk_container_get_first_child (GtkContainer *container);
-void eel_gtk_container_foreach_deep (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data);
/* GtkWindow */
void eel_gtk_window_set_initial_geometry (GtkWindow *window,
@@ -93,9 +48,6 @@ void eel_gtk_window_set_initial_geometry_from_string (GtkWindow
guint minimum_width,
guint minimum_height,
gboolean ignore_position);
-void eel_gtk_window_set_up_close_accelerator (GtkWindow *window);
-gboolean eel_gtk_window_event_is_close_accelerator (GtkWindow *window,
- GdkEventKey *event);
char * eel_gtk_window_get_geometry_string (GtkWindow *window);
@@ -107,21 +59,12 @@ void eel_pop_up_context_menu (GtkMenu
GtkMenuItem * eel_gtk_menu_append_separator (GtkMenu *menu);
GtkMenuItem * eel_gtk_menu_insert_separator (GtkMenu *menu,
int index);
-void eel_gtk_menu_set_item_visibility (GtkMenu *menu,
- int index,
- gboolean visible);
/* GtkMenuToolButton */
GtkWidget * eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button);
/* GtkLabel */
void eel_gtk_label_make_bold (GtkLabel *label);
-void eel_gtk_label_set_scale (GtkLabel *label,
- double scale_factor);
-void eel_gtk_label_set_drop_shadow_color (GtkLabel *label,
- guint32 color);
-void eel_gtk_label_set_drop_shadow_offset (GtkLabel *label,
- gint offset);
/* GtkAdjustment */
void eel_gtk_adjustment_set_value (GtkAdjustment *adjustment,
float value);
@@ -131,11 +74,8 @@ void eel_gtk_adjustment_clamp_value (GtkAdjust
void eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view,
gboolean should_activate);
-/* GtkViewport */
-gboolean eel_gtk_viewport_get_visible_rect (GtkViewport *viewport,
- GdkRectangle *rect);
-
-void eel_gtk_viewport_scroll_to_rect (GtkViewport *viewport,
- GdkRectangle *rect);
+/* GtkMessageDialog */
+void eel_gtk_message_dialog_set_details_label (GtkMessageDialog *dialog,
+ const gchar *details_text);
#endif /* EEL_GTK_EXTENSIONS_H */
diff --git a/eel/eel-i18n.c b/eel/eel-i18n.c
deleted file mode 100644
index 9e7ef29b..00000000
--- a/eel/eel-i18n.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-i18n.c: I18n stuff for Eel.
-
- Copyright (C) 2002 MandrakeSoft.
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Frederic Crozat <[email protected]>
-*/
-
-#include <config.h>
-#include <glib.h>
-
-#include "eel-i18n.h"
-
-#ifdef ENABLE_NLS
-
-#include <libintl.h>
-
-const char* _eel_gettext(const char* str)
-{
- static gboolean _eel_gettext_initialized = FALSE;
-
- if (!_eel_gettext_initialized)
- {
- bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR);
-
-#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-#endif
-
- _eel_gettext_initialized = TRUE;
- }
-
- return dgettext(GETTEXT_PACKAGE, str);
-}
-
-#endif /* ENABLE_NLS */
diff --git a/eel/eel-i18n.h b/eel/eel-i18n.h
deleted file mode 100644
index 68b71f11..00000000
--- a/eel/eel-i18n.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-i18n.h: I18n stuff for Eel.
-
- Copyright (C) 2002 MandrakeSoft
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Frederic Crozat <[email protected]>
-*/
-
-#ifndef EEL_I18N_H
-#define EEL_I18N_H
-
-#ifdef ENABLE_NLS
-
-#include <glib.h>
-
-
-const char* _eel_gettext(const char* str) G_GNUC_FORMAT(1);
-
-#include <libintl.h>
-#define _(String) _eel_gettext(String)
-
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
-
-#else /* NLS is disabled */
-#define _(String) (String)
-#define N_(String) (String)
-#define textdomain(String) (String)
-#define gettext(String) (String)
-#define dgettext(Domain,String) (String)
-#define dcgettext(Domain,String,Type) (String)
-#define bindtextdomain(Domain,Directory) (Domain)
-#endif
-
-
-#endif /* EEL_I18N_H */
diff --git a/eel/eel-image-table.c b/eel/eel-image-table.c
index 8f87660b..205fc70a 100644
--- a/eel/eel-image-table.c
+++ b/eel/eel-image-table.c
@@ -29,7 +29,6 @@
#include "eel-art-gtk-extensions.h"
#include "eel-debug-drawing.h"
#include "eel-gtk-extensions.h"
-#include "eel-gtk-macros.h"
#include "eel-labeled-image.h"
#include "eel-marshal.h"
#include <gtk/gtk.h>
@@ -46,7 +45,6 @@ struct EelImageTableDetails
{
GtkWidget *child_under_pointer;
GtkWidget *child_being_pressed;
- GdkGC *clear_gc;
};
/* Signals */
@@ -63,31 +61,17 @@ typedef enum
/* Signals */
static guint image_table_signals[LAST_SIGNAL] = { 0 };
-static void eel_image_table_class_init (EelImageTableClass *image_table_class);
-static void eel_image_table_init (EelImageTable *image);
-
-/* GObjectClass methods */
-static void eel_image_table_finalize (GObject *object);
-
-/* GtkWidgetClass methods */
-static void eel_image_table_realize (GtkWidget *widget);
-static void eel_image_table_unrealize (GtkWidget *widget);
-
-/* GtkContainerClass methods */
-static void eel_image_table_remove (GtkContainer *container,
- GtkWidget *widget);
-static GType eel_image_table_child_type (GtkContainer *container);
-
-/* Private EelImageTable methods */
-static void image_table_emit_signal (EelImageTable *image_table,
- GtkWidget *child,
- guint signal_index,
- int x,
- int y,
- int button,
- guint state,
- GdkEvent *event);
-
+/* Ancestor methods */
+GtkWidget * find_windowed_ancestor (GtkWidget *widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void signal_connect_while_realized (GtkWidget *object,
+#else
+static void signal_connect_while_realized (GtkObject *object,
+#endif
+ const char *name,
+ GCallback callback,
+ gpointer callback_data,
+ GtkWidget *realized_widget);
/* Ancestor callbacks */
static int ancestor_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event,
@@ -105,85 +89,16 @@ static int ancestor_button_release_event (GtkWidget *widget,
GdkEventButton *event,
gpointer event_data);
-EEL_CLASS_BOILERPLATE (EelImageTable, eel_image_table, EEL_TYPE_WRAP_TABLE)
-
-static void
-eel_image_table_class_init (EelImageTableClass *image_table_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (image_table_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (image_table_class);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (image_table_class);
-
- /* GObjectClass */
- object_class->finalize = eel_image_table_finalize;
-
- /* GtkWidgetClass */
- widget_class->realize = eel_image_table_realize;
- widget_class->unrealize = eel_image_table_unrealize;
-
- /* GtkContainerClass */
- container_class->remove = eel_image_table_remove;
- container_class->child_type = eel_image_table_child_type;
-
- /* Signals */
- image_table_signals[CHILD_ENTER] = g_signal_new ("child_enter",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EelImageTableClass, child_enter),
- NULL, NULL,
- eel_marshal_VOID__OBJECT_POINTER,
- G_TYPE_NONE,
- 2,
- GTK_TYPE_WIDGET,
- G_TYPE_POINTER);
- image_table_signals[CHILD_LEAVE] = g_signal_new ("child_leave",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EelImageTableClass, child_leave),
- NULL, NULL,
- eel_marshal_VOID__OBJECT_POINTER,
- G_TYPE_NONE,
- 2,
- GTK_TYPE_WIDGET,
- G_TYPE_POINTER);
- image_table_signals[CHILD_PRESSED] = g_signal_new ("child_pressed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EelImageTableClass, child_pressed),
- NULL, NULL,
- eel_marshal_VOID__OBJECT_POINTER,
- G_TYPE_NONE,
- 2,
- GTK_TYPE_WIDGET,
- G_TYPE_POINTER);
- image_table_signals[CHILD_RELEASED] = g_signal_new ("child_released",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EelImageTableClass, child_released),
- NULL, NULL,
- eel_marshal_VOID__OBJECT_POINTER,
- G_TYPE_NONE,
- 2,
- GTK_TYPE_WIDGET,
- G_TYPE_POINTER);
- image_table_signals[CHILD_CLICKED] = g_signal_new ("child_clicked",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EelImageTableClass, child_clicked),
- NULL, NULL,
- eel_marshal_VOID__OBJECT_POINTER,
- G_TYPE_NONE,
- 2,
- GTK_TYPE_WIDGET,
- G_TYPE_POINTER);
-}
+G_DEFINE_TYPE (EelImageTable, eel_image_table, EEL_TYPE_WRAP_TABLE)
static void
eel_image_table_init (EelImageTable *image_table)
{
gtk_widget_set_has_window (GTK_WIDGET (image_table), FALSE);
- image_table->details = g_new0 (EelImageTableDetails, 1);
+ image_table->details = G_TYPE_INSTANCE_GET_PRIVATE (image_table,
+ EEL_TYPE_IMAGE_TABLE,
+ EelImageTableDetails);
}
/* GObjectClass methods */
@@ -194,9 +109,7 @@ eel_image_table_finalize (GObject *object)
image_table = EEL_IMAGE_TABLE (object);
- g_free (image_table->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (eel_image_table_parent_class)->finalize (object);
}
static void
@@ -207,9 +120,9 @@ eel_image_table_realize (GtkWidget *widget)
g_assert (EEL_IS_IMAGE_TABLE (widget));
/* Chain realize */
- EEL_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget));
+ GTK_WIDGET_CLASS (eel_image_table_parent_class)->realize (widget);
- windowed_ancestor = eel_gtk_widget_find_windowed_ancestor (widget);
+ windowed_ancestor = find_windowed_ancestor (widget);
g_assert (GTK_IS_WIDGET (windowed_ancestor));
gtk_widget_add_events (windowed_ancestor,
@@ -220,54 +133,39 @@ eel_image_table_realize (GtkWidget *widget)
| GDK_LEAVE_NOTIFY_MASK
| GDK_POINTER_MOTION_MASK);
- eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
- "enter_notify_event",
- G_CALLBACK (ancestor_enter_notify_event),
- widget,
- widget);
-
- eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
- "leave_notify_event",
- G_CALLBACK (ancestor_leave_notify_event),
- widget,
- widget);
-
- eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
- "motion_notify_event",
- G_CALLBACK (ancestor_motion_notify_event),
- widget,
- widget);
-
- eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
- "button_press_event",
- G_CALLBACK (ancestor_button_press_event),
- widget,
- widget);
-
- eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
- "button_release_event",
- G_CALLBACK (ancestor_button_release_event),
- widget,
- widget);
-}
-
-static void
-eel_image_table_unrealize (GtkWidget *widget)
-{
- EelImageTable *image_table;
-
- g_assert (EEL_IS_IMAGE_TABLE (widget));
-
- image_table = EEL_IMAGE_TABLE (widget);
-
- if (image_table->details->clear_gc != NULL)
- {
- g_object_unref (image_table->details->clear_gc);
- image_table->details->clear_gc = NULL;
- }
-
- /* Chain unrealize */
- EEL_CALL_PARENT (GTK_WIDGET_CLASS, unrealize, (widget));
+#if !GTK_CHECK_VERSION (3, 0, 0)
+#define windowed_ancestor GTK_OBJECT(windowed_ancestor)
+#endif
+
+ signal_connect_while_realized (windowed_ancestor,
+ "enter_notify_event",
+ G_CALLBACK (ancestor_enter_notify_event),
+ widget,
+ widget);
+
+ signal_connect_while_realized (windowed_ancestor,
+ "leave_notify_event",
+ G_CALLBACK (ancestor_leave_notify_event),
+ widget,
+ widget);
+
+ signal_connect_while_realized (windowed_ancestor,
+ "motion_notify_event",
+ G_CALLBACK (ancestor_motion_notify_event),
+ widget,
+ widget);
+
+ signal_connect_while_realized (windowed_ancestor,
+ "button_press_event",
+ G_CALLBACK (ancestor_button_press_event),
+ widget,
+ widget);
+
+ signal_connect_while_realized (windowed_ancestor,
+ "button_release_event",
+ G_CALLBACK (ancestor_button_release_event),
+ widget,
+ widget);
}
/* GtkContainerClass methods */
@@ -292,7 +190,7 @@ eel_image_table_remove (GtkContainer *container,
image_table->details->child_being_pressed = NULL;
}
- EEL_CALL_PARENT (GTK_CONTAINER_CLASS, remove, (container, child));
+ GTK_CONTAINER_CLASS (eel_image_table_parent_class)->remove (container, child);
}
static GType
@@ -333,6 +231,78 @@ image_table_emit_signal (EelImageTable *image_table,
}
static void
+eel_image_table_class_init (EelImageTableClass *image_table_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (image_table_class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (image_table_class);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (image_table_class);
+
+ /* GObjectClass */
+ object_class->finalize = eel_image_table_finalize;
+
+ /* GtkWidgetClass */
+ widget_class->realize = eel_image_table_realize;
+
+ /* GtkContainerClass */
+ container_class->remove = eel_image_table_remove;
+ container_class->child_type = eel_image_table_child_type;
+
+ /* Signals */
+ image_table_signals[CHILD_ENTER] = g_signal_new ("child_enter",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EelImageTableClass, child_enter),
+ NULL, NULL,
+ eel_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE,
+ 2,
+ GTK_TYPE_WIDGET,
+ G_TYPE_POINTER);
+ image_table_signals[CHILD_LEAVE] = g_signal_new ("child_leave",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EelImageTableClass, child_leave),
+ NULL, NULL,
+ eel_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE,
+ 2,
+ GTK_TYPE_WIDGET,
+ G_TYPE_POINTER);
+ image_table_signals[CHILD_PRESSED] = g_signal_new ("child_pressed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EelImageTableClass, child_pressed),
+ NULL, NULL,
+ eel_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE,
+ 2,
+ GTK_TYPE_WIDGET,
+ G_TYPE_POINTER);
+ image_table_signals[CHILD_RELEASED] = g_signal_new ("child_released",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EelImageTableClass, child_released),
+ NULL, NULL,
+ eel_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE,
+ 2,
+ GTK_TYPE_WIDGET,
+ G_TYPE_POINTER);
+ image_table_signals[CHILD_CLICKED] = g_signal_new ("child_clicked",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EelImageTableClass, child_clicked),
+ NULL, NULL,
+ eel_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE,
+ 2,
+ GTK_TYPE_WIDGET,
+ G_TYPE_POINTER);
+
+ g_type_class_add_private (image_table_class, sizeof (EelImageTableDetails));
+}
+
+static void
image_table_handle_motion (EelImageTable *image_table,
int x,
int y,
@@ -401,6 +371,115 @@ image_table_handle_motion (EelImageTable *image_table,
}
}
+GtkWidget *
+find_windowed_ancestor (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ while (widget && !gtk_widget_get_has_window (widget))
+ {
+ widget = gtk_widget_get_parent (widget);
+ }
+
+ return widget;
+}
+
+typedef struct
+{
+ GObject *object;
+ guint object_destroy_handler;
+
+ GtkWidget *realized_widget;
+ guint realized_widget_destroy_handler;
+ guint realized_widget_unrealized_handler;
+
+ guint signal_handler;
+} RealizeDisconnectInfo;
+
+static void
+while_realized_disconnecter (GObject *object,
+ RealizeDisconnectInfo *info)
+{
+ g_assert (G_IS_OBJECT (object));
+ g_assert (info != NULL);
+ g_assert (G_IS_OBJECT (info->object));
+ g_assert (info->object_destroy_handler != 0);
+ g_assert (info->object_destroy_handler != 0);
+ g_assert (info->realized_widget_destroy_handler != 0);
+ g_assert (info->realized_widget_unrealized_handler != 0);
+
+ g_signal_handler_disconnect (info->object, info->object_destroy_handler);
+ g_signal_handler_disconnect (info->object, info->signal_handler);
+ g_signal_handler_disconnect (info->realized_widget, info->realized_widget_destroy_handler);
+ g_signal_handler_disconnect (info->realized_widget, info->realized_widget_unrealized_handler);
+ g_free (info);
+}
+
+/**
+ * signal_connect_while_realized:
+ *
+ * @object: Object to connect to.
+ * @name: Name of signal to connect to.
+ * @callback: Caller's callback.
+ * @callback_data: Caller's callback_data.
+ * @realized_widget: Widget to monitor for realized state. Signal is connected
+ * while this wigget is realized.
+ *
+ * Connect to a signal of an object while another widget is realized. This is
+ * useful for non windowed widgets that need to monitor events in their ancestored
+ * windowed widget. The signal is automatically disconnected when &widget is
+ * unrealized. Also, the signal is automatically disconnected when either &object
+ * or &widget are destroyed.
+ **/
+static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+signal_connect_while_realized (GtkWidget *object,
+#else
+signal_connect_while_realized (GtkObject *object,
+#endif
+ const char *name,
+ GCallback callback,
+ gpointer callback_data,
+ GtkWidget *realized_widget)
+{
+ RealizeDisconnectInfo *info;
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_return_if_fail (GTK_IS_WIDGET (object));
+#else
+ g_return_if_fail (GTK_IS_OBJECT (object));
+#endif
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (name[0] != '\0');
+ g_return_if_fail (callback != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (realized_widget));
+ g_return_if_fail (gtk_widget_get_realized (realized_widget));
+
+ info = g_new0 (RealizeDisconnectInfo, 1);
+
+ info->object = object;
+ info->object_destroy_handler =
+ g_signal_connect (G_OBJECT (info->object),
+ "destroy",
+ G_CALLBACK (while_realized_disconnecter),
+ info);
+
+ info->realized_widget = realized_widget;
+ info->realized_widget_destroy_handler =
+ g_signal_connect (G_OBJECT (info->realized_widget),
+ "destroy",
+ G_CALLBACK (while_realized_disconnecter),
+ info);
+ info->realized_widget_unrealized_handler =
+ g_signal_connect_after (G_OBJECT (info->realized_widget),
+ "unrealize",
+ G_CALLBACK (while_realized_disconnecter),
+ info);
+
+ info->signal_handler = g_signal_connect (G_OBJECT (info->object),
+ name, callback, callback_data);
+}
+
static int
ancestor_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event,
diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c
index c1e51070..12dad9c1 100644
--- a/eel/eel-labeled-image.c
+++ b/eel/eel-labeled-image.c
@@ -30,7 +30,6 @@
#include "eel-debug-drawing.h"
#include "eel-gtk-container.h"
#include "eel-gtk-extensions.h"
-#include "eel-gtk-macros.h"
#include "eel-accessibility.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@@ -89,47 +88,9 @@ static GType eel_labeled_image_check_button_get_type (void);
static GType eel_labeled_image_radio_button_get_type (void);
static GType eel_labeled_image_toggle_button_get_type (void);
-
-static void eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class);
-static void eel_labeled_image_init (EelLabeledImage *image);
-static void eel_labeled_image_finalize (GObject *object);
-
-
-
-/* GObjectClass methods */
-static void eel_labeled_image_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void eel_labeled_image_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-/* GtkObjectClass methods */
-static void eel_labeled_image_destroy (GtkObject *object);
-
/* GtkWidgetClass methods */
-static void eel_labeled_image_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static int eel_labeled_image_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void eel_labeled_image_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void eel_labeled_image_map (GtkWidget *widget);
-static void eel_labeled_image_unmap (GtkWidget *widget);
static AtkObject *eel_labeled_image_get_accessible (GtkWidget *widget);
-/* GtkContainerClass methods */
-static void eel_labeled_image_add (GtkContainer *container,
- GtkWidget *widget);
-static void eel_labeled_image_remove (GtkContainer *container,
- GtkWidget *widget);
-static void eel_labeled_image_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
/* Private EelLabeledImage methods */
static EelDimensions labeled_image_get_image_dimensions (const EelLabeledImage *labeled_image);
static EelDimensions labeled_image_get_label_dimensions (const EelLabeledImage *labeled_image);
@@ -143,158 +104,16 @@ static gboolean labeled_image_show_image (const EelLabeledImage
static guint labeled_image_signals[LAST_SIGNAL] = { 0 };
-EEL_CLASS_BOILERPLATE (EelLabeledImage, eel_labeled_image, GTK_TYPE_CONTAINER)
-
-/* Class init methods */
-static void
-eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (labeled_image_class);
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (labeled_image_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (labeled_image_class);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (labeled_image_class);
- GtkBindingSet *binding_set;
-
- gobject_class->finalize = eel_labeled_image_finalize;
-
- /* GObjectClass */
- gobject_class->set_property = eel_labeled_image_set_property;
- gobject_class->get_property = eel_labeled_image_get_property;
-
- /* GtkObjectClass */
- object_class->destroy = eel_labeled_image_destroy;
-
- /* GtkWidgetClass */
- widget_class->size_request = eel_labeled_image_size_request;
- widget_class->size_allocate = eel_labeled_image_size_allocate;
- widget_class->expose_event = eel_labeled_image_expose_event;
- widget_class->map = eel_labeled_image_map;
- widget_class->unmap = eel_labeled_image_unmap;
- widget_class->get_accessible = eel_labeled_image_get_accessible;
-
- /* GtkContainerClass */
- container_class->add = eel_labeled_image_add;
- container_class->remove = eel_labeled_image_remove;
- container_class->forall = eel_labeled_image_forall;
-
- labeled_image_signals[ACTIVATE] =
- g_signal_new ("activate",
- G_TYPE_FROM_CLASS (labeled_image_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EelLabeledImageClass,
- activate),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- widget_class->activate_signal = labeled_image_signals[ACTIVATE];
-
- binding_set = gtk_binding_set_by_class (gobject_class);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_Return, 0,
- "activate", 0);
- gtk_binding_entry_add_signal (binding_set,
- GDK_KP_Enter, 0,
- "activate", 0);
- gtk_binding_entry_add_signal (binding_set,
- GDK_space, 0,
- "activate", 0);
-
-
- /* Properties */
- g_object_class_install_property (
- gobject_class,
- PROP_PIXBUF,
- g_param_spec_object ("pixbuf", NULL, NULL,
- GDK_TYPE_PIXBUF, G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_LABEL,
- g_param_spec_string ("label", NULL, NULL,
- "", G_PARAM_READWRITE));
-
-
- g_object_class_install_property (
- gobject_class,
- PROP_LABEL_POSITION,
- g_param_spec_enum ("label_position", NULL, NULL,
- GTK_TYPE_POSITION_TYPE,
- GTK_POS_BOTTOM,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_SHOW_LABEL,
- g_param_spec_boolean ("show_label", NULL, NULL,
- TRUE, G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_SHOW_IMAGE,
- g_param_spec_boolean ("show_image", NULL, NULL,
- TRUE, G_PARAM_READWRITE));
-
-
- g_object_class_install_property (
- gobject_class,
- PROP_SPACING,
- g_param_spec_uint ("spacing", NULL, NULL,
- 0,
- G_MAXINT,
- DEFAULT_SPACING,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_X_PADDING,
- g_param_spec_int ("x_padding", NULL, NULL,
- 0,
- G_MAXINT,
- DEFAULT_X_PADDING,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_Y_PADDING,
- g_param_spec_int ("y_padding", NULL, NULL,
- 0,
- G_MAXINT,
- DEFAULT_Y_PADDING,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_X_ALIGNMENT,
- g_param_spec_float ("x_alignment", NULL, NULL,
- 0.0,
- 1.0,
- DEFAULT_X_ALIGNMENT,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_Y_ALIGNMENT,
- g_param_spec_float ("y_alignment", NULL, NULL,
- 0.0,
- 1.0,
- DEFAULT_Y_ALIGNMENT,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_FILL,
- g_param_spec_boolean ("fill", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE));
-}
+G_DEFINE_TYPE (EelLabeledImage, eel_labeled_image, GTK_TYPE_CONTAINER)
static void
eel_labeled_image_init (EelLabeledImage *labeled_image)
{
gtk_widget_set_has_window (GTK_WIDGET (labeled_image), FALSE);
- labeled_image->details = g_new0 (EelLabeledImageDetails, 1);
+ labeled_image->details = G_TYPE_INSTANCE_GET_PRIVATE (labeled_image,
+ EEL_TYPE_LABELED_IMAGE,
+ EelLabeledImageDetails);
labeled_image->details->show_label = TRUE;
labeled_image->details->show_image = TRUE;
labeled_image->details->label_position = GTK_POS_BOTTOM;
@@ -309,20 +128,11 @@ eel_labeled_image_init (EelLabeledImage *labeled_image)
}
static void
-eel_labeled_image_finalize (GObject *object)
-{
- EelLabeledImage *labeled_image;
-
- labeled_image = EEL_LABELED_IMAGE (object);
-
- g_free (labeled_image->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-
-static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+eel_labeled_image_destroy (GtkWidget *object)
+#else
eel_labeled_image_destroy (GtkObject *object)
+#endif
{
EelLabeledImage *labeled_image;
@@ -338,7 +148,11 @@ eel_labeled_image_destroy (GtkObject *object)
gtk_widget_destroy (labeled_image->details->label);
}
- EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (eel_labeled_image_parent_class)->destroy (object);
+#else
+ GTK_OBJECT_CLASS (eel_labeled_image_parent_class)->destroy (object);
+#endif
}
/* GObjectClass methods */
@@ -694,6 +508,152 @@ eel_labeled_image_forall (GtkContainer *container,
}
}
+/* Class init methods */
+static void
+eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (labeled_image_class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (labeled_image_class);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (labeled_image_class);
+ GtkBindingSet *binding_set;
+
+ /* GObjectClass */
+ gobject_class->set_property = eel_labeled_image_set_property;
+ gobject_class->get_property = eel_labeled_image_get_property;
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GTK_OBJECT_CLASS (labeled_image_class)->destroy = eel_labeled_image_destroy;
+#else
+ widget_class->destroy = eel_labeled_image_destroy;
+#endif
+
+ /* GtkWidgetClass */
+ widget_class->size_request = eel_labeled_image_size_request;
+ widget_class->size_allocate = eel_labeled_image_size_allocate;
+ widget_class->expose_event = eel_labeled_image_expose_event;
+ widget_class->map = eel_labeled_image_map;
+ widget_class->unmap = eel_labeled_image_unmap;
+ widget_class->get_accessible = eel_labeled_image_get_accessible;
+
+ /* GtkContainerClass */
+ container_class->add = eel_labeled_image_add;
+ container_class->remove = eel_labeled_image_remove;
+ container_class->forall = eel_labeled_image_forall;
+
+ labeled_image_signals[ACTIVATE] =
+ g_signal_new ("activate",
+ G_TYPE_FROM_CLASS (labeled_image_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EelLabeledImageClass,
+ activate),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ widget_class->activate_signal = labeled_image_signals[ACTIVATE];
+
+ binding_set = gtk_binding_set_by_class (gobject_class);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_Return, 0,
+ "activate", 0);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_KP_Enter, 0,
+ "activate", 0);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_space, 0,
+ "activate", 0);
+
+
+ /* Properties */
+ g_object_class_install_property (
+ gobject_class,
+ PROP_PIXBUF,
+ g_param_spec_object ("pixbuf", NULL, NULL,
+ GDK_TYPE_PIXBUF, G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_LABEL,
+ g_param_spec_string ("label", NULL, NULL,
+ "", G_PARAM_READWRITE));
+
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_LABEL_POSITION,
+ g_param_spec_enum ("label_position", NULL, NULL,
+ GTK_TYPE_POSITION_TYPE,
+ GTK_POS_BOTTOM,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_SHOW_LABEL,
+ g_param_spec_boolean ("show_label", NULL, NULL,
+ TRUE, G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_SHOW_IMAGE,
+ g_param_spec_boolean ("show_image", NULL, NULL,
+ TRUE, G_PARAM_READWRITE));
+
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_SPACING,
+ g_param_spec_uint ("spacing", NULL, NULL,
+ 0,
+ G_MAXINT,
+ DEFAULT_SPACING,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_X_PADDING,
+ g_param_spec_int ("x_padding", NULL, NULL,
+ 0,
+ G_MAXINT,
+ DEFAULT_X_PADDING,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_Y_PADDING,
+ g_param_spec_int ("y_padding", NULL, NULL,
+ 0,
+ G_MAXINT,
+ DEFAULT_Y_PADDING,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_X_ALIGNMENT,
+ g_param_spec_float ("x_alignment", NULL, NULL,
+ 0.0,
+ 1.0,
+ DEFAULT_X_ALIGNMENT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_Y_ALIGNMENT,
+ g_param_spec_float ("y_alignment", NULL, NULL,
+ 0.0,
+ 1.0,
+ DEFAULT_Y_ALIGNMENT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_FILL,
+ g_param_spec_boolean ("fill", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (labeled_image_class, sizeof (EelLabeledImageDetails));
+}
+
/* Private EelLabeledImage methods */
static gboolean
is_fixed_height (const EelLabeledImage *labeled_image)
@@ -1308,7 +1268,7 @@ labeled_image_show_label (const EelLabeledImage *labeled_image)
* be created as neeeded.
*
* Thus, using this widget in place of EelImage or EelLabel is "free" with
- * only the GtkObject and function call overhead.
+ * only the GtkWidget and function call overhead.
*
*/
GtkWidget*
diff --git a/eel/eel-lib-self-check-functions.h b/eel/eel-lib-self-check-functions.h
index 6c3e07d1..d14aa99e 100644
--- a/eel/eel-lib-self-check-functions.h
+++ b/eel/eel-lib-self-check-functions.h
@@ -43,7 +43,6 @@ void eel_run_lib_self_checks (void);
macro (eel_self_check_gdk_extensions) \
macro (eel_self_check_gdk_pixbuf_extensions) \
macro (eel_self_check_glib_extensions) \
- macro (eel_self_check_pango_extensions) \
macro (eel_self_check_string) \
/* Add new self-check functions to the list above this line. */
diff --git a/eel/eel-mate-extensions.c b/eel/eel-mate-extensions.c
index aca3cddf..2af5a941 100644
--- a/eel/eel-mate-extensions.c
+++ b/eel/eel-mate-extensions.c
@@ -29,26 +29,10 @@
#define MATE_DESKTOP_USE_UNSTABLE_API
#include "eel-mate-extensions.h"
-#include "eel-art-extensions.h"
-#include "eel-gdk-extensions.h"
-#include "eel-glib-extensions.h"
-#include "eel-gtk-extensions.h"
-#include "eel-stock-dialogs.h"
-#include "eel-i18n.h"
-#include <X11/Xatom.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <gdk/gdkx.h>
+
#include <gtk/gtk.h>
#include <libmate/mate-desktop-utils.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <unistd.h>
+
/* Return a command string containing the path to a terminal on this system. */
diff --git a/eel/eel-mate-extensions.h b/eel/eel-mate-extensions.h
index cabd4380..cb97e55b 100644
--- a/eel/eel-mate-extensions.h
+++ b/eel/eel-mate-extensions.h
@@ -29,10 +29,6 @@
#include <gtk/gtk.h>
-/* icon selection callback function. */
-typedef void (* EelIconSelectionFunction) (const char *icon_path, gpointer callback_data);
-
-
/* Return a command string containing the path to a terminal on this system. */
char * eel_mate_make_terminal_command (const char *command);
diff --git a/eel/eel-pango-extensions.c b/eel/eel-pango-extensions.c
deleted file mode 100644
index 68a9b08e..00000000
--- a/eel/eel-pango-extensions.c
+++ /dev/null
@@ -1,615 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-pango-extensions.h - interface for new functions that conceptually
- belong in pango. Perhaps some of these will be
- actually rolled into pango someday.
-
- Copyright (C) 2001 Anders Carlsson
-
- The Eel Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Eel Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Eel Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Anders Carlsson <[email protected]>
-*/
-
-#include <config.h>
-#include "eel-pango-extensions.h"
-
-#if !defined (EEL_OMIT_SELF_CHECK)
-#include "eel-lib-self-check-functions.h"
-#endif
-
-#include <gtk/gtk.h>
-#include <pango/pango.h>
-#include <string.h>
-
-PangoAttrList *
-eel_pango_attr_list_copy_or_create (PangoAttrList *attr_list)
-{
- if (attr_list != NULL)
- {
- return pango_attr_list_copy (attr_list);
- }
- return pango_attr_list_new ();
-}
-
-PangoAttrList *
-eel_pango_attr_list_apply_global_attribute (PangoAttrList *attr_list,
- PangoAttribute *attr)
-{
- PangoAttrList *new_attr_list;
-
- g_return_val_if_fail (attr != NULL, NULL);
-
- attr->start_index = 0;
- attr->end_index = G_MAXINT;
-
- new_attr_list = eel_pango_attr_list_copy_or_create (attr_list);
- pango_attr_list_change (new_attr_list, attr);
- return new_attr_list;
-}
-
-#define ELLIPSIS "..."
-
-/* Caution: this is an _expensive_ function */
-static int
-measure_string_width (const char *string,
- PangoLayout *layout)
-{
- int width;
-
- pango_layout_set_text (layout, string, -1);
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- return width;
-}
-
-/* this is also plenty slow */
-static void
-compute_character_widths (const char *string,
- PangoLayout *layout,
- int *char_len_return,
- int **widths_return,
- int **cuts_return)
-{
- int *widths;
- int *offsets;
- int *cuts;
- int char_len;
- int byte_len;
- const char *p;
- int i;
- PangoLayoutIter *iter;
- PangoLogAttr *attrs;
-
-#define BEGINS_UTF8_CHAR(x) (((x) & 0xc0) != 0x80)
-
- char_len = g_utf8_strlen (string, -1);
- byte_len = strlen (string);
-
- widths = g_new (int, char_len);
- offsets = g_new (int, byte_len);
-
- /* Create a translation table from byte index to char offset */
- p = string;
- i = 0;
- while (*p)
- {
- int byte_index = p - string;
-
- if (BEGINS_UTF8_CHAR (*p))
- {
- offsets[byte_index] = i;
- ++i;
- }
- else
- {
- offsets[byte_index] = G_MAXINT; /* segv if we try to use this */
- }
-
- ++p;
- }
-
- /* Now fill in the widths array */
- pango_layout_set_text (layout, string, -1);
-
- iter = pango_layout_get_iter (layout);
-
- do
- {
- PangoRectangle extents;
- int byte_index;
-
- byte_index = pango_layout_iter_get_index (iter);
-
- if (byte_index < byte_len)
- {
- pango_layout_iter_get_char_extents (iter, &extents);
-
- g_assert (BEGINS_UTF8_CHAR (string[byte_index]));
- g_assert (offsets[byte_index] < char_len);
-
- widths[offsets[byte_index]] = PANGO_PIXELS (extents.width);
- }
-
- }
- while (pango_layout_iter_next_char (iter));
-
- pango_layout_iter_free (iter);
-
- g_free (offsets);
-
- *widths_return = widths;
-
- /* Now compute character offsets that are legitimate places to
- * chop the string
- */
- attrs = g_new (PangoLogAttr, char_len + 1);
-
- pango_get_log_attrs (string, byte_len, -1,
- pango_context_get_language (
- pango_layout_get_context (layout)),
- attrs,
- char_len + 1);
-
- cuts = g_new (int, char_len);
- i = 0;
- while (i < char_len)
- {
- cuts[i] = attrs[i].is_cursor_position;
-
- ++i;
- }
-
- g_free (attrs);
-
- *cuts_return = cuts;
-
- *char_len_return = char_len;
-}
-
-
-static char *
-eel_string_ellipsize_start (const char *string, PangoLayout *layout, int width)
-{
- int resulting_width;
- int *cuts;
- int *widths;
- int char_len;
- const char *p;
- int truncate_offset;
-
- /* Zero-length string can't get shorter - catch this here to
- * avoid expensive calculations
- */
- if (*string == '\0')
- return g_strdup ("");
-
- /* I'm not sure if this short-circuit is a net win; it might be better
- * to just dump this, and always do the compute_character_widths() etc.
- * down below.
- */
- resulting_width = measure_string_width (string, layout);
-
- if (resulting_width <= width)
- {
- /* String is already short enough. */
- return g_strdup (string);
- }
-
- /* Remove width of an ellipsis */
- width -= measure_string_width (ELLIPSIS, layout);
-
- if (width < 0)
- {
- /* No room even for an ellipsis. */
- return g_strdup ("");
- }
-
- /* Our algorithm involves removing enough chars from the string to bring
- * the width to the required small size. However, due to ligatures,
- * combining characters, etc., it's not guaranteed that the algorithm
- * always works 100%. It's sort of a heuristic thing. It should work
- * nearly all the time... but I wouldn't put in
- * g_assert (width of resulting string < width).
- *
- * Hmm, another thing that this breaks with is explicit line breaks
- * in "string"
- */
-
- compute_character_widths (string, layout, &char_len, &widths, &cuts);
-
- for (truncate_offset = 1; truncate_offset < char_len; truncate_offset++)
- {
-
- resulting_width -= widths[truncate_offset];
-
- if (resulting_width <= width &&
- cuts[truncate_offset])
- {
- break;
- }
- }
-
- g_free (cuts);
- g_free (widths);
-
- p = g_utf8_offset_to_pointer (string, truncate_offset);
-
- return g_strconcat (ELLIPSIS, p, NULL);
-}
-
-static char *
-eel_string_ellipsize_end (const char *string, PangoLayout *layout, int width)
-{
- int resulting_width;
- int *cuts;
- int *widths;
- int char_len;
- const char *p;
- int truncate_offset;
- char *result;
-
- /* See explanatory comments in ellipsize_start */
-
- if (*string == '\0')
- return g_strdup ("");
-
- resulting_width = measure_string_width (string, layout);
-
- if (resulting_width <= width)
- {
- return g_strdup (string);
- }
-
- width -= measure_string_width (ELLIPSIS, layout);
-
- if (width < 0)
- {
- return g_strdup ("");
- }
-
- compute_character_widths (string, layout, &char_len, &widths, &cuts);
-
- for (truncate_offset = char_len - 1; truncate_offset > 0; truncate_offset--)
- {
- resulting_width -= widths[truncate_offset];
- if (resulting_width <= width &&
- cuts[truncate_offset])
- {
- break;
- }
- }
-
- g_free (cuts);
- g_free (widths);
-
- p = g_utf8_offset_to_pointer (string, truncate_offset);
-
- result = g_malloc ((p - string) + strlen (ELLIPSIS) + 1);
- memcpy (result, string, (p - string));
- strcpy (result + (p - string), ELLIPSIS);
-
- return result;
-}
-
-static char *
-eel_string_ellipsize_middle (const char *string, PangoLayout *layout, int width)
-{
- int resulting_width;
- int *cuts;
- int *widths;
- int char_len;
- int starting_fragment_byte_len;
- int ending_fragment_byte_index;
- int starting_fragment_length;
- int ending_fragment_offset;
- char *result;
-
- /* See explanatory comments in ellipsize_start */
-
- if (*string == '\0')
- return g_strdup ("");
-
- resulting_width = measure_string_width (string, layout);
-
- if (resulting_width <= width)
- {
- return g_strdup (string);
- }
-
- width -= measure_string_width (ELLIPSIS, layout);
-
- if (width < 0)
- {
- return g_strdup ("");
- }
-
- compute_character_widths (string, layout, &char_len, &widths, &cuts);
-
- starting_fragment_length = char_len / 2;
- ending_fragment_offset = starting_fragment_length + 1;
-
- /* Shave off a character at a time from the first and the second half
- * until we can fit
- */
- resulting_width -= widths[ending_fragment_offset - 1];
-
- /* depending on whether the original string length is odd or even, start by
- * shaving off the characters from the starting or ending fragment
- */
- if (char_len % 2)
- {
- goto shave_end;
- }
-
- while (starting_fragment_length > 0 || ending_fragment_offset < char_len)
- {
- if (resulting_width <= width &&
- cuts[ending_fragment_offset] &&
- cuts[starting_fragment_length])
- {
- break;
- }
-
- if (starting_fragment_length > 0)
- {
- resulting_width -= widths[starting_fragment_length];
- starting_fragment_length--;
- }
-
-shave_end:
- if (resulting_width <= width &&
- cuts[ending_fragment_offset] &&
- cuts[starting_fragment_length])
- {
- break;
- }
-
- if (ending_fragment_offset < char_len)
- {
- resulting_width -= widths[ending_fragment_offset];
- ending_fragment_offset++;
- }
- }
-
- g_free (cuts);
- g_free (widths);
-
- /* patch the two fragments together with an ellipsis */
- result = g_malloc (strlen (string) + strlen (ELLIPSIS) + 1); /* a bit wasteful, no biggie */
-
- starting_fragment_byte_len = g_utf8_offset_to_pointer (string, starting_fragment_length) - string;
- ending_fragment_byte_index = g_utf8_offset_to_pointer (string, ending_fragment_offset) - string;
-
- memcpy (result, string, starting_fragment_byte_len);
- strcpy (result + starting_fragment_byte_len, ELLIPSIS);
- strcpy (result + starting_fragment_byte_len + strlen (ELLIPSIS), string + ending_fragment_byte_index);
-
- return result;
-}
-
-
-/**
- * eel_pango_layout_set_text_ellipsized
- *
- * @layout: a pango layout
- * @string: A a string to be ellipsized.
- * @width: Desired maximum width in points.
- * @mode: The desired ellipsizing mode.
- *
- * Truncates a string if required to fit in @width and sets it on the
- * layout. Truncation involves removing characters from the start, middle or end
- * respectively and replacing them with "...". Algorithm is a bit
- * fuzzy, won't work 100%.
- *
- */
-void
-eel_pango_layout_set_text_ellipsized (PangoLayout *layout,
- const char *string,
- int width,
- EelEllipsizeMode mode)
-{
- char *s;
-
- g_return_if_fail (PANGO_IS_LAYOUT (layout));
- g_return_if_fail (string != NULL);
- g_return_if_fail (width >= 0);
-
- switch (mode)
- {
- case EEL_ELLIPSIZE_START:
- s = eel_string_ellipsize_start (string, layout, width);
- break;
- case EEL_ELLIPSIZE_MIDDLE:
- s = eel_string_ellipsize_middle (string, layout, width);
- break;
- case EEL_ELLIPSIZE_END:
- s = eel_string_ellipsize_end (string, layout, width);
- break;
- default:
- g_return_if_reached ();
- }
-
- pango_layout_set_text (layout, s, -1);
-
- g_free (s);
-}
-
-
-int
-eel_pango_font_description_get_largest_fitting_font_size (const PangoFontDescription *font_desc,
- PangoContext *context,
- const char *text,
- int available_width,
- int minimum_acceptable_font_size,
- int maximum_acceptable_font_size)
-{
- int i;
- int width;
- PangoLayout *layout;
- PangoFontDescription *font;
-
- g_return_val_if_fail (text != NULL, 0);
- g_return_val_if_fail (text[0] != '\0', 0);
- g_return_val_if_fail (available_width > 0, 0);
- g_return_val_if_fail (minimum_acceptable_font_size > 0, 0);
- g_return_val_if_fail (maximum_acceptable_font_size > 0, 0);
- g_return_val_if_fail (maximum_acceptable_font_size > minimum_acceptable_font_size, 0);
-
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, text, -1);
- pango_layout_set_font_description (layout, font_desc);
-
- font = pango_font_description_new ();
-
- for (i = maximum_acceptable_font_size; i >= minimum_acceptable_font_size; i--)
- {
-
- pango_font_description_set_size (font, i * PANGO_SCALE);
- pango_layout_set_font_description (layout, font);
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- if (width <= available_width)
- {
- pango_font_description_free (font);
- g_object_unref (layout);
- return i;
- }
- }
-
- pango_font_description_free (font);
- g_object_unref (layout);
- return i;
-}
-
-
-#if !defined (EEL_OMIT_SELF_CHECK)
-
-static PangoContext *
-eel_create_bogus_test_pango_context (void)
-{
- PangoContext *context;
-
- context = gdk_pango_context_get ();
- pango_context_set_language (context, gtk_get_default_language ());
-
- return context;
-}
-
-/* Testing string truncation is tough because we do not know what font/
- * font metrics to expect on a given system. To work around this we use
- * a substring of the original, measure it's length using the given font,
- * add the length of the "..." string and use that for truncation.
- * The result should then be the substring prepended with a "..."
- */
-static char *
-eel_self_check_ellipsize (const char *string, const char *truncate_to_length_string, EelEllipsizeMode mode)
-{
- PangoContext *context;
- int truncation_length;
- char *result;
- PangoLayout *layout;
-
- context = eel_create_bogus_test_pango_context ();
- layout = pango_layout_new (context);
-
- /* measure the length we want to truncate to */
- truncation_length = measure_string_width (truncate_to_length_string, layout);
-
- eel_pango_layout_set_text_ellipsized (layout, string, truncation_length, mode);
-
- result = g_strdup (pango_layout_get_text (layout));
-
- g_object_unref (G_OBJECT (context));
- g_object_unref (G_OBJECT (layout));
-
- return result;
-}
-
-static char *
-eel_self_check_ellipsize_start (const char *string, const char *truncate_to_length_string)
-{
- return eel_self_check_ellipsize (string, truncate_to_length_string, EEL_ELLIPSIZE_START);
-}
-
-static char *
-eel_self_check_ellipsize_middle (const char *string, const char *truncate_to_length_string)
-{
- return eel_self_check_ellipsize (string, truncate_to_length_string, EEL_ELLIPSIZE_MIDDLE);
-}
-
-static char *
-eel_self_check_ellipsize_end (const char *string, const char *truncate_to_length_string)
-{
- return eel_self_check_ellipsize (string, truncate_to_length_string, EEL_ELLIPSIZE_END);
-}
-
-void
-eel_self_check_pango_extensions (void)
-{
- PangoContext *context;
-
- /* used to test ellipsize routines */
- context = eel_create_bogus_test_pango_context ();
-
- /* Turned off these tests because they are failing for me and I
- * want the release to be able to pass "make check". We'll have
- * to revisit this at some point. The failures started because
- * I changed my default font and enabled Xft support. I presume
- * this is simply the "fuzziness" Havoc mentions in his comments
- * above.
- * - Darin
- */
-
- if (0)
- {
- /* eel_string_ellipsize_start */
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "0012345678"), "012345678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "012345678"), "012345678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...45678"), "...45678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...5678"), "...5678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...678"), "...678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...78"), "...78");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...8"), "...8");
-
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "0123456789"), "012345678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "012345678"), "012345678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "012...78"), "012...78");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "01...78"), "01...78");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "01...8"), "01...8");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "0...8"), "0...8");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "0..."), "0...");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "0123456789"), "0123456789");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "012...789"), "012...789");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "012...89"), "012...89");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "01...89"), "01...89");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "01...9"), "01...9");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "0...9"), "0...9");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "0..."), "0...");
-
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "0123456789"), "012345678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "012345678"), "012345678");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "01234..."), "01234...");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "0123..."), "0123...");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "012..."), "012...");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "01..."), "01...");
- EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "0..."), "0...");
- }
-
- g_object_unref (context);
-}
-
-#endif /* !EEL_OMIT_SELF_CHECK */
diff --git a/eel/eel-pango-extensions.h b/eel/eel-pango-extensions.h
deleted file mode 100644
index 2be3a965..00000000
--- a/eel/eel-pango-extensions.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-pango-extensions.h - interface for new functions that conceptually
- belong in pango. Perhaps some of these will be
- actually rolled into pango someday.
-
- Copyright (C) 2001 Anders Carlsson
-
- The Eel Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Eel Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Eel Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Anders Carlsson <[email protected]>
-*/
-
-#ifndef EEL_PANGO_EXTENSIONS_H
-#define EEL_PANGO_EXTENSIONS_H
-
-#include <pango/pango.h>
-
-typedef enum
-{
- EEL_ELLIPSIZE_START,
- EEL_ELLIPSIZE_MIDDLE,
- EEL_ELLIPSIZE_END
-} EelEllipsizeMode;
-
-PangoAttrList *eel_pango_attr_list_copy_or_create (PangoAttrList *attr_list);
-PangoAttrList *eel_pango_attr_list_apply_global_attribute (PangoAttrList *attr_list,
- PangoAttribute *attr);
-int eel_pango_font_description_get_largest_fitting_font_size (const PangoFontDescription *font_desc,
- PangoContext *context,
- const char *text,
- int available_width,
- int minimum_acceptable_font_size,
- int maximum_acceptable_font_size);
-
-/* caution: this function is expensive. */
-void eel_pango_layout_set_text_ellipsized (PangoLayout *layout,
- const char *string,
- int width,
- EelEllipsizeMode mode);
-
-#endif /* EEL_PANGO_EXTENSIONS_H */
diff --git a/eel/eel-stock-dialogs.c b/eel/eel-stock-dialogs.c
index c9cadfb3..7f83476e 100644
--- a/eel/eel-stock-dialogs.c
+++ b/eel/eel-stock-dialogs.c
@@ -25,11 +25,10 @@
#include <config.h>
#include "eel-stock-dialogs.h"
-#include "eel-alert-dialog.h"
#include "eel-glib-extensions.h"
-#include "eel-mate-extensions.h"
-#include "eel-string.h"
-#include "eel-i18n.h"
+#include "eel-gtk-extensions.h"
+
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#define TIMED_WAIT_STANDARD_DURATION 2000
@@ -61,7 +60,7 @@ typedef struct
static GHashTable *timed_wait_hash_table;
-static void timed_wait_dialog_destroy_callback (GtkObject *object, gpointer callback_data);
+static void timed_wait_dialog_destroy_callback (GtkWidget *object, gpointer callback_data);
static guint
timed_wait_hash (gconstpointer value)
@@ -87,7 +86,7 @@ timed_wait_hash_equal (gconstpointer value1, gconstpointer value2)
}
static void
-timed_wait_delayed_close_destroy_dialog_callback (GtkObject *object, gpointer callback_data)
+timed_wait_delayed_close_destroy_dialog_callback (GtkWidget *object, gpointer callback_data)
{
g_source_remove (GPOINTER_TO_UINT (callback_data));
}
@@ -104,7 +103,7 @@ timed_wait_delayed_close_timeout_callback (gpointer callback_data)
G_CALLBACK (timed_wait_delayed_close_destroy_dialog_callback),
GUINT_TO_POINTER (handler_id));
- gtk_object_destroy (GTK_OBJECT (callback_data));
+ gtk_widget_destroy (GTK_WIDGET (callback_data));
return FALSE;
}
@@ -154,7 +153,7 @@ timed_wait_free (TimedWait *wait)
}
else
{
- gtk_object_destroy (GTK_OBJECT (wait->dialog));
+ gtk_widget_destroy (GTK_WIDGET (wait->dialog));
}
}
@@ -163,7 +162,7 @@ timed_wait_free (TimedWait *wait)
}
static void
-timed_wait_dialog_destroy_callback (GtkObject *object, gpointer callback_data)
+timed_wait_dialog_destroy_callback (GtkWidget *object, gpointer callback_data)
{
TimedWait *wait;
@@ -203,12 +202,16 @@ timed_wait_callback (gpointer callback_data)
/* Put up the timed wait window. */
button = wait->cancel_callback != NULL ? GTK_STOCK_CANCEL : GTK_STOCK_OK;
- dialog = GTK_DIALOG (eel_alert_dialog_new (wait->parent_window,
- 0,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_NONE,
- wait->wait_message,
- _("You can stop this operation by clicking cancel.")));
+ dialog = GTK_DIALOG (gtk_message_dialog_new (wait->parent_window,
+ 0,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_NONE,
+ NULL));
+
+ g_object_set (dialog,
+ "text", wait->wait_message,
+ "secondary-text", _("You can stop this operation by clicking cancel."),
+ NULL);
gtk_dialog_add_button (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
@@ -340,12 +343,16 @@ eel_run_simple_dialog (GtkWidget *parent, gboolean ignore_close_box,
}
/* Create the dialog. */
- dialog = eel_alert_dialog_new (GTK_WINDOW (chosen_parent),
- 0,
- message_type,
- GTK_BUTTONS_NONE,
- primary_text,
- secondary_text);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (chosen_parent),
+ 0,
+ message_type,
+ GTK_BUTTONS_NONE,
+ NULL);
+
+ g_object_set (dialog,
+ "text", primary_text,
+ "secondary-text", secondary_text,
+ NULL);
va_start (button_title_args, secondary_text);
response_id = 0;
@@ -370,7 +377,7 @@ eel_run_simple_dialog (GtkWidget *parent, gboolean ignore_close_box,
gtk_widget_show (GTK_WIDGET (dialog));
result = gtk_dialog_run (GTK_DIALOG (dialog));
}
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (dialog);
return result;
}
@@ -384,12 +391,17 @@ create_message_dialog (const char *primary_text,
{
GtkWidget *dialog;
- dialog = eel_alert_dialog_new (parent,
- 0,
- type,
- buttons_type,
- primary_text,
- secondary_text);
+ dialog = gtk_message_dialog_new (parent,
+ 0,
+ type,
+ buttons_type,
+ NULL);
+
+ g_object_set (dialog,
+ "text", primary_text,
+ "secondary-text", secondary_text,
+ NULL);
+
return GTK_DIALOG (dialog);
}
@@ -405,14 +417,14 @@ show_message_dialog (const char *primary_text,
dialog = create_message_dialog (primary_text, secondary_text, type,
buttons_type, parent);
- if (details_text != NULL)
- {
- eel_alert_dialog_set_details_label (EEL_ALERT_DIALOG (dialog), details_text);
+ if (details_text != NULL) {
+ eel_gtk_message_dialog_set_details_label (GTK_MESSAGE_DIALOG (dialog),
+ details_text);
}
gtk_widget_show (GTK_WIDGET (dialog));
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_object_destroy), NULL);
+ G_CALLBACK (gtk_widget_destroy), NULL);
return dialog;
}
diff --git a/eel/eel-types.c b/eel/eel-types.c
deleted file mode 100644
index 4b5ae176..00000000
--- a/eel/eel-types.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* eel-types.h -
-
- Copyright (C) 2000 Eazel, Inc.
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Maciej Stachowiak <[email protected]>
-*/
-
-
-#include <config.h>
-#include <gtk/gtk.h>
-
-#define EEL_COMPILATION 1
-#include <eel/eel.h>
-
-#include "eel-type-builtins-vars.c"
-#include "eel-type-builtins-evals.c"
-
-void
-eel_type_init (void)
-{
- int i;
- GType type_id;
- static gboolean initialized = FALSE;
-
- static struct
- {
- const gchar *type_name;
- GType *type_id;
- GType parent;
- gconstpointer pointer1;
- gpointer pointer2;
- } builtin_info[EEL_TYPE_N_BUILTINS] =
- {
-#include "eel-type-builtins-ids.c"
- };
-
- if (initialized)
- {
- return;
- }
- initialized = TRUE;
-
- for (i = 0; i < EEL_TYPE_N_BUILTINS; i++)
- {
- type_id = G_TYPE_INVALID;
-
- if (builtin_info[i].parent == G_TYPE_ENUM)
- {
- type_id = g_enum_register_static (builtin_info[i].type_name,
- builtin_info[i].pointer1);
- }
- else if (builtin_info[i].parent == G_TYPE_FLAGS)
- {
- type_id = g_flags_register_static (builtin_info[i].type_name,
- builtin_info[i].pointer1);
- }
- else
- {
- g_assert_not_reached ();
- }
-
- g_assert (type_id != G_TYPE_INVALID);
- *builtin_info[i].type_id = type_id;
- }
-}
-
diff --git a/eel/eel-types.h b/eel/eel-types.h
deleted file mode 100644
index ff25087d..00000000
--- a/eel/eel-types.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* eel-types.h -
-
- Copyright (C) 2000 Eazel, Inc.
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Maciej Stachowiak <[email protected]>
-*/
-
-#ifndef EEL_TYPES_H
-#define EEL_TYPES_H
-
-#include <eel/eel-type-builtins.h>
-
-void eel_type_init (void);
-
-#endif /* EEL_TYPES_H */
-
diff --git a/eel/eel-vfs-extensions.c b/eel/eel-vfs-extensions.c
index 27db2a46..9c786965 100644
--- a/eel/eel-vfs-extensions.c
+++ b/eel/eel-vfs-extensions.c
@@ -27,11 +27,11 @@
*/
#include <config.h>
-#include "eel-i18n.h"
#include "eel-vfs-extensions.h"
#include "eel-glib-extensions.h"
#include "eel-lib-self-check-functions.h"
#include <glib.h>
+#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include "eel-string.h"
@@ -99,34 +99,6 @@ eel_make_valid_utf8 (const char *name)
return g_string_free (string, FALSE);
}
-/**
- * eel_format_uri_for_display:
- *
- * Filter, modify, unescape and change URIs to make them appropriate
- * to display to users. The conversion is done such that the roundtrip
- * to UTf8 is reversible.
- *
- * Rules:
- * file: URI's without fragments should appear as local paths
- * file: URI's with fragments should appear as file: URI's
- * All other URI's appear as expected
- *
- * @uri: a URI
- *
- * returns a g_malloc'd UTF8 string
- **/
-char *
-eel_format_uri_for_display (const char *uri)
-{
- GFile *file;
- char *res;
-
- file = g_file_new_for_uri (uri);
- res = g_file_get_parse_name (file);
- g_object_unref (file);
- return res;
-}
-
char *
eel_filename_strip_extension (const char * filename_with_extension)
{
diff --git a/eel/eel-vfs-extensions.h b/eel/eel-vfs-extensions.h
index a79df1c3..e564ca15 100644
--- a/eel/eel-vfs-extensions.h
+++ b/eel/eel-vfs-extensions.h
@@ -46,7 +46,6 @@ extern "C" {
gboolean eel_uri_is_search(const char* uri);
- char* eel_format_uri_for_display(const char* uri);
char* eel_make_valid_utf8(const char* name);
char* eel_filename_strip_extension(const char* filename);
diff --git a/eel/eel-wrap-table.c b/eel/eel-wrap-table.c
index f7e8a6ad..42253acd 100644
--- a/eel/eel-wrap-table.c
+++ b/eel/eel-wrap-table.c
@@ -28,8 +28,6 @@
#include "eel-art-extensions.h"
#include "eel-art-gtk-extensions.h"
#include "eel-gtk-extensions.h"
-#include "eel-gtk-macros.h"
-#include "eel-types.h"
#include <gtk/gtk.h>
/* Arguments */
@@ -57,127 +55,30 @@ struct EelWrapTableDetails
guint cols;
};
-static void eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class);
-static void eel_wrap_table_init (EelWrapTable *wrap);
-/* GObjectClass methods */
-static void eel_wrap_table_finalize (GObject *object);
-static void eel_wrap_table_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void eel_wrap_table_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-/* GtkWidgetClass methods */
-static void eel_wrap_table_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static int eel_wrap_table_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void eel_wrap_table_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void eel_wrap_table_map (GtkWidget *widget);
-static void eel_wrap_table_unmap (GtkWidget *widget);
-static void eel_wrap_table_realize (GtkWidget *widget);
-
-/* GtkContainerClass methods */
-static void eel_wrap_table_add (GtkContainer *container,
- GtkWidget *widget);
-static void eel_wrap_table_remove (GtkContainer *container,
- GtkWidget *widget);
-static void eel_wrap_table_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType eel_wrap_table_child_type (GtkContainer *container);
-
-
/* Private EelWrapTable methods */
static EelDimensions wrap_table_irect_max_dimensions (const EelDimensions *one,
const EelDimensions *two);
static EelDimensions wrap_table_get_max_child_dimensions (const EelWrapTable *wrap_table);
static EelDimensions wrap_table_get_content_dimensions (const EelWrapTable *wrap_table);
static EelIRect wrap_table_get_content_bounds (const EelWrapTable *wrap_table);
+static gboolean wrap_table_child_visible_in (GtkWidget *child,
+ GtkWidget *scrolled);
static gboolean wrap_table_child_focus_in (GtkWidget *widget,
GdkEventFocus *event,
gpointer data);
static void wrap_table_layout (EelWrapTable *wrap_table);
-EEL_CLASS_BOILERPLATE (EelWrapTable, eel_wrap_table, GTK_TYPE_CONTAINER)
-
-/* Class init methods */
-static void
-eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (wrap_table_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (wrap_table_class);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (wrap_table_class);
-
- /* GObjectClass */
- gobject_class->finalize = eel_wrap_table_finalize;
- gobject_class->set_property = eel_wrap_table_set_property;
- gobject_class->get_property = eel_wrap_table_get_property;
-
- /* GtkWidgetClass */
- widget_class->size_request = eel_wrap_table_size_request;
- widget_class->size_allocate = eel_wrap_table_size_allocate;
- widget_class->expose_event = eel_wrap_table_expose_event;
- widget_class->map = eel_wrap_table_map;
- widget_class->unmap = eel_wrap_table_unmap;
- widget_class->realize = eel_wrap_table_realize;
-
- /* GtkContainerClass */
- container_class->add = eel_wrap_table_add;
- container_class->remove = eel_wrap_table_remove;
- container_class->forall = eel_wrap_table_forall;
- container_class->child_type = eel_wrap_table_child_type;
-
- /* Register some the enum types we need */
- eel_type_init ();
-
- /* Arguments */
- g_object_class_install_property
- (gobject_class,
- PROP_X_SPACING,
- g_param_spec_uint ("x_spacing", NULL, NULL,
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_Y_SPACING,
- g_param_spec_uint ("y_spacing", NULL, NULL,
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_X_JUSTIFICATION,
- g_param_spec_enum ("x_justification", NULL, NULL,
- EEL_TYPE_JUSTIFICATION,
- EEL_JUSTIFICATION_BEGINNING,
- G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_Y_JUSTIFICATION,
- g_param_spec_enum ("y_justification", NULL, NULL,
- EEL_TYPE_JUSTIFICATION,
- EEL_JUSTIFICATION_BEGINNING,
- G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_HOMOGENEOUS,
- g_param_spec_boolean ("homogenous", NULL, NULL,
- FALSE, G_PARAM_READWRITE));
-}
+G_DEFINE_TYPE (EelWrapTable, eel_wrap_table, GTK_TYPE_CONTAINER)
static void
eel_wrap_table_init (EelWrapTable *wrap_table)
{
gtk_widget_set_has_window (GTK_WIDGET (wrap_table), FALSE);
- wrap_table->details = g_new0 (EelWrapTableDetails, 1);
+ wrap_table->details = G_TYPE_INSTANCE_GET_PRIVATE (wrap_table,
+ EEL_TYPE_WRAP_TABLE,
+ EelWrapTableDetails);
wrap_table->details->x_justification = EEL_JUSTIFICATION_BEGINNING;
wrap_table->details->y_justification = EEL_JUSTIFICATION_END;
wrap_table->details->cols = 1;
@@ -191,9 +92,8 @@ eel_wrap_table_finalize (GObject *object)
wrap_table = EEL_WRAP_TABLE (object);
g_list_free (wrap_table->details->children);
- g_free (wrap_table->details);
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (eel_wrap_table_parent_class)->finalize (object);
}
/* GObjectClass methods */
@@ -391,7 +291,7 @@ eel_wrap_table_realize (GtkWidget *widget)
{
g_assert (EEL_IS_WRAP_TABLE (widget));
- GTK_WIDGET_CLASS (parent_class)->realize (widget);
+ GTK_WIDGET_CLASS (eel_wrap_table_parent_class)->realize (widget);
gtk_widget_queue_resize (widget);
}
@@ -497,6 +397,71 @@ eel_wrap_table_child_type (GtkContainer *container)
return GTK_TYPE_WIDGET;
}
+/* Class init methods */
+static void
+eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (wrap_table_class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (wrap_table_class);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (wrap_table_class);
+
+ /* GObjectClass */
+ gobject_class->finalize = eel_wrap_table_finalize;
+ gobject_class->set_property = eel_wrap_table_set_property;
+ gobject_class->get_property = eel_wrap_table_get_property;
+
+ /* GtkWidgetClass */
+ widget_class->size_request = eel_wrap_table_size_request;
+ widget_class->size_allocate = eel_wrap_table_size_allocate;
+ widget_class->expose_event = eel_wrap_table_expose_event;
+ widget_class->map = eel_wrap_table_map;
+ widget_class->unmap = eel_wrap_table_unmap;
+ widget_class->realize = eel_wrap_table_realize;
+
+ /* GtkContainerClass */
+ container_class->add = eel_wrap_table_add;
+ container_class->remove = eel_wrap_table_remove;
+ container_class->forall = eel_wrap_table_forall;
+ container_class->child_type = eel_wrap_table_child_type;
+
+ /* Arguments */
+ g_object_class_install_property
+ (gobject_class,
+ PROP_X_SPACING,
+ g_param_spec_uint ("x_spacing", NULL, NULL,
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_Y_SPACING,
+ g_param_spec_uint ("y_spacing", NULL, NULL,
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_X_JUSTIFICATION,
+ g_param_spec_enum ("x_justification", NULL, NULL,
+ GTK_TYPE_JUSTIFICATION,
+ GTK_JUSTIFY_LEFT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_Y_JUSTIFICATION,
+ g_param_spec_enum ("y_justification", NULL, NULL,
+ GTK_TYPE_JUSTIFICATION,
+ GTK_JUSTIFY_LEFT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_HOMOGENEOUS,
+ g_param_spec_boolean ("homogenous", NULL, NULL,
+ FALSE, G_PARAM_READWRITE));
+
+ g_type_class_add_private (wrap_table_class, sizeof (EelWrapTableDetails));
+}
+
/* Private EelWrapTable methods */
static int
wrap_table_get_num_fitting (int available,
@@ -744,23 +709,55 @@ wrap_table_get_content_bounds (const EelWrapTable *wrap_table)
return content_bounds;
}
+/**
+ * wrap_table_child_visible_in
+ *
+ * Get child position relative to parent, then determine whether
+ * the whole child rectangle is visible in the scrolled window
+ **/
+static gboolean
+wrap_table_child_visible_in (GtkWidget *child, GtkWidget *scrolled)
+{
+ gint x, y;
+ GtkAllocation child_alloc, scroll_alloc;
+
+ gtk_widget_translate_coordinates (child, scrolled, 0, 0, &x, &y);
+ gtk_widget_get_allocation(child, &child_alloc);
+ gtk_widget_get_allocation(scrolled, &scroll_alloc);
+
+ return (x >= 0 && y >= 0)
+ && x + child_alloc.width <= scroll_alloc.width
+ && y + child_alloc.height <= scroll_alloc.height;
+}
+
static gboolean
wrap_table_child_focus_in (GtkWidget *widget,
GdkEventFocus *event,
gpointer data)
{
- GtkWidget *parent, *pparent;
- GtkAllocation allocation;
+ gint x, y;
+ GtkWidget *container, *viewport;
+ GtkAdjustment *hadj, *vadj;
+
+ container = gtk_widget_get_parent (widget);
+ if (container)
+ {
+ viewport = gtk_widget_get_parent (container);
+ }
+ g_assert (container && viewport);
+ g_assert (GTK_IS_VIEWPORT (viewport));
+ g_return_val_if_fail (gtk_widget_get_realized (viewport), FALSE);
+
+ if (!wrap_table_child_visible_in (widget, viewport))
+ {
+ hadj = gtk_viewport_get_hadjustment (GTK_VIEWPORT (viewport));
+ vadj = gtk_viewport_get_vadjustment (GTK_VIEWPORT (viewport));
- parent = gtk_widget_get_parent (widget);
- if (parent)
- pparent = gtk_widget_get_parent (parent);
- g_assert (parent && pparent);
- g_assert (GTK_IS_VIEWPORT (pparent));
+ gtk_widget_translate_coordinates (widget, container, 0, 0, &x, &y);
- gtk_widget_get_allocation (widget, &allocation);
- eel_gtk_viewport_scroll_to_rect (GTK_VIEWPORT (pparent),
- &allocation);
+ gtk_adjustment_set_value (hadj, MIN (x, hadj->upper - hadj->page_size));
+ gtk_adjustment_set_value (vadj, MIN (y, vadj->upper - vadj->page_size));
+ }
return FALSE;
}
@@ -977,16 +974,12 @@ void
eel_wrap_table_set_homogeneous (EelWrapTable *wrap_table,
gboolean homogeneous)
{
- g_return_if_fail (EEL_IS_WRAP_TABLE (wrap_table));
-
- if (wrap_table->details->homogeneous == homogeneous)
+ if (EEL_IS_WRAP_TABLE (wrap_table) &&
+ wrap_table->details->homogeneous != homogeneous)
{
- return;
+ wrap_table->details->homogeneous = homogeneous;
+ gtk_widget_queue_resize (GTK_WIDGET (wrap_table));
}
-
- wrap_table->details->homogeneous = homogeneous;
-
- gtk_widget_queue_resize (GTK_WIDGET (wrap_table));
}
/**
diff --git a/eel/eel-xml-extensions.c b/eel/eel-xml-extensions.c
index fe4a91a4..2bcd4477 100644
--- a/eel/eel-xml-extensions.c
+++ b/eel/eel-xml-extensions.c
@@ -26,8 +26,8 @@
#include "eel-xml-extensions.h"
#include "eel-string.h"
-#include "eel-i18n.h"
#include <glib.h>
+#include <glib/gi18n-lib.h>
#include <libxml/parser.h>
#include <stdlib.h>
diff --git a/eel/eel.h b/eel/eel.h
index 615958ca..c86bc99a 100644
--- a/eel/eel.h
+++ b/eel/eel.h
@@ -38,11 +38,9 @@
#include <eel/eel-gtk-macros.h>
#include <eel/eel-image-table.h>
#include <eel/eel-labeled-image.h>
-#include <eel/eel-pango-extensions.h>
#include <eel/eel-self-checks.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#include <eel/eel-types.h>
#include <eel/eel-vfs-extensions.h>
#include <eel/eel-wrap-table.h>
#include <eel/eel-xml-extensions.h>
diff --git a/eel/eelmarshal.list b/eel/eelmarshal.list
deleted file mode 100644
index 3974c4b7..00000000
--- a/eel/eelmarshal.list
+++ /dev/null
@@ -1,13 +0,0 @@
-BOOLEAN:BOOLEAN
-BOOLEAN:BOXED
-BOOLEAN:POINTER,POINTER
-BOOLEAN:VOID
-ENUM:INT,INT
-INT:INT
-INT:POINTER,STRING
-STRING:POINTER
-STRING:VOID
-VOID:ENUM,INT
-VOID:ENUM,INT,BOOLEAN
-VOID:INT,INT,INT,INT
-VOID:OBJECT,POINTER
diff --git a/eel/makeenums.pl b/eel/makeenums.pl
deleted file mode 100755
index 50402ed2..00000000
--- a/eel/makeenums.pl
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/usr/bin/perl -w
-
-# This script snarfs the enums from header files and writes them out into
-# a .defs file (mate.defs, for example). From there, the sister script
-# maketypes.awk converts the defs into a *typebuiltins.h, as well as
-# *typebuiltins_vals.c, *typebuiltins_ids.c and *typebuiltins_evals.c.
-
-# Information about the current enumeration
-
-my $flags; # Is enumeration a bitmask
-my $seenbitshift; # Have we seen bitshift operators?
-my $prefix; # Prefix for this enumeration
-my $enumname; # Name for this enumeration
-my $firstenum = 1; # Is this the first enumeration in file?
-my @entries; # [ $name, $val ] for each entry
-
-sub parse_options {
- my $opts = shift;
- my @opts;
-
- for $opt (split /\s*,\s*/, $opts) {
- my ($key,$val) = $opt =~ /\s*(\w+)(?:=(\S+))?/;
- defined $val or $val = 1;
- push @opts, $key, $val;
- }
- @opts;
-}
-sub parse_entries {
- my $file = shift;
-
- while (<$file>) {
- # Read lines until we have no open comments
- while (m@/\*
- ([^*]|\*(?!/))*$
- @x) {
- my $new;
- defined ($new = <$file>) || die "Unmatched comment";
- $_ .= $new;
- }
- # Now strip comments
- s@/\*(?!<)
- ([^*]+|\*(?!/))*
- \*/@@gx;
-
- s@\n@ @;
-
- next if m@^\s*$@;
-
- # Handle include files
- if (/^\#include\s*<([^>]*)>/ ) {
- my $file= "../$1";
- open NEWFILE, $file or die "Cannot open include file $file: $!\n";
-
- if (parse_entries (\*NEWFILE)) {
- return 1;
- } else {
- next;
- }
- }
-
- if (/^\s*\}\s*(\w+)/) {
- $enumname = $1;
- return 1;
- }
-
- if (m@^\s*
- (\w+)\s* # name
- (?:=( # value
- (?:[^,/]|/(?!\*))*
- ))?,?\s*
- (?:/\*< # options
- (([^*]|\*(?!/))*)
- >\*/)?
- \s*$
- @x) {
- my ($name, $value, $options) = ($1,$2,$3);
-
- if (!defined $flags && defined $value && $value =~ /<</) {
- $seenbitshift = 1;
- }
- if (defined $options) {
- my %options = parse_options($options);
- if (!defined $options{skip}) {
- push @entries, [ $name, $options{nick} ];
- }
- } else {
- push @entries, [ $name ];
- }
- } else {
- print STDERR "Can't understand: $_\n";
- }
- }
- return 0;
-}
-
-
-my $gen_arrays = 0;
-my $gen_defs = 0;
-
-# Parse arguments
-
-if (@ARGV) {
- if ($ARGV[0] eq "arrays") {
- shift @ARGV;
- $gen_arrays = 1;
- } elsif ($ARGV[0] eq "defs") {
- shift @ARGV;
- $gen_defs = 1;
- } else {
- $gen_defs = 1;
- }
-
-}
-
-if ($gen_defs) {
- print ";; generated by makeenums.pl ; -*- scheme -*-\n\n";
-} else {
- print "/* Generated by makeenums.pl */\n\n";
-}
-
-ENUMERATION:
-while (<>) {
- if (eof) {
- close (ARGV); # reset line numbering
- $firstenum = 1; # Flag to print filename at next enum
- }
-
- if (m@^\s*typedef\s+enum\s*
- ({)?\s*
- (?:/\*<
- (([^*]|\*(?!/))*)
- >\*/)?
- @x) {
- if (defined $2) {
- my %options = parse_options($2);
- $prefix = $options{prefix};
- $flags = $options{flags};
- } else {
- $prefix = undef;
- $flags = undef;
- }
- # Didn't have trailing '{' look on next lines
- if (!defined $1) {
- while (<>) {
- if (s/^\s*\{//) {
- last;
- }
- }
- }
-
- $seenbitshift = 0;
- @entries = ();
-
- # Now parse the entries
- parse_entries (\*ARGV);
-
- # figure out if this was a flags or enums enumeration
-
- if (!defined $flags) {
- $flags = $seenbitshift;
- }
-
- # Autogenerate a prefix
-
- if (!defined $prefix) {
- for (@entries) {
- my $name = $_->[0];
- if (defined $prefix) {
- my $tmp = ~ ($name ^ $prefix);
- ($tmp) = $tmp =~ /(^\xff*)/;
- $prefix = $prefix & $tmp;
- } else {
- $prefix = $name;
- }
- }
- # Trim so that it ends in an underscore
- $prefix =~ s/_[^_]*$/_/;
- }
-
- for $entry (@entries) {
- my ($name,$nick) = @{$entry};
- if (!defined $nick) {
- ($nick = $name) =~ s/^$prefix//;
- $nick =~ tr/_/-/;
- $nick = lc($nick);
- @{$entry} = ($name, $nick);
- }
- }
-
- # Spit out the output
-
- if ($gen_defs) {
- if ($firstenum) {
- print qq(\n; enumerations from "$ARGV"\n);
- $firstenum = 0;
- }
-
- print "\n(define-".($flags ? "flags" : "enum")." $enumname";
-
- for (@entries) {
- my ($name,$nick) = @{$_};
- print "\n ($nick $name)";
- }
- print ")\n";
-
- } else {
- ($valuename = $enumname) =~ s/([A-Z][a-z])/_$1/g;
- $valuename =~ s/([a-z])([A-Z])/$1_$2/g;
- $valuename = lc($valuename);
-
- print "static const GEnumValue $ {valuename}_values[] = {\n";
- for (@entries) {
- my ($name,$nick) = @{$_};
- print qq( { $name, "$name", "$nick" },\n);
- }
- print " { 0, NULL, NULL }\n";
- print "};\n";
- }
- }
-}
diff --git a/eel/maketypes.awk b/eel/maketypes.awk
deleted file mode 100755
index 4284eddd..00000000
--- a/eel/maketypes.awk
+++ /dev/null
@@ -1,155 +0,0 @@
-
-BEGIN {
- type_name = ""; # GtkEnumType
- type_macro = ""; # GTK_TYPE_ENUM_TYPE
- type_ident = ""; # _gtk_enum_type
- type_counter = 0;
- gen_macros = 0;
- gen_entries = 0;
- gen_vars = 0;
- boxed_copy = "";
- boxed_free = "";
-
- for (i = 2; i < ARGC; i++)
- {
- if (ARGV[i] == "macros")
- gen_macros = 1;
- else if (ARGV[i] == "entries")
- gen_entries = 1;
- else if (ARGV[i] == "variables")
- gen_vars = 1;
- ARGV[i] = "";
- }
-
- if (gen_macros)
- {
- printf ("/* type macros, generated by maketypes.awk */\n");
- printf ("\n");
- printf ("#ifdef G_OS_WIN32\n");
- printf ("# ifdef EEL_COMPILATION\n");
- printf ("# define EELTYPEBUILTINS_VAR __declspec(dllexport)\n");
- printf ("# else\n");
- printf ("# define EELTYPEBUILTINS_VAR extern __declspec(dllimport)\n");
- printf ("# endif\n");
- printf ("#else\n");
- printf ("# ifdef EEL_COMPILATION\n");
- printf ("# define EELTYPEBUILTINS_VAR\n");
- printf ("# else\n");
- printf ("# define EELTYPEBUILTINS_VAR extern\n");
- printf ("# endif\n");
- printf ("#endif\n");
- printf ("\n");
- }
- else if (gen_entries)
- printf ("/* type entries, generated by maketypes.awk */\n\n");
- else if (gen_vars)
- printf ("/* type variables, generated by maketypes.awk */\n\n");
- else
- {
- printf ("hm? what do you want me to do?\n") > "/dev/stderr";
- exit 1;
- }
-}
-
-function set_type (set_type_1)
-{
- type_counter += 1;
- type_name = set_type_1;
- type_macro = "EEL_TYPE_";
-
- tmp = type_name;
-# OK, the following is ridiculous, and sed s///g would be far easier
- gsub ("[A-Z]", "@&", tmp);
- gsub ("[^A-Z]@", "&_", tmp);
- gsub ("@", "", tmp);
- gsub ("[A-Z][A-Z][A-Z][0-9a-z]", "@&", tmp);
- gsub ("@..", "&_", tmp);
- gsub ("@", "", tmp);
- type_macro = type_macro toupper (tmp);
- type_ident = "_" tolower (tmp);
-
- sub ("^EEL_TYPE_EEL_", "EEL_TYPE_", type_macro);
-}
-
-function generate (generate_what)
-{
- if (gen_macros)
- {
- printf ("EELTYPEBUILTINS_VAR GType %s;\n", type_macro);
- }
- if (gen_entries)
- {
- printf (" { \"%s\", &%s,\n", type_name, type_macro);
- if (generate_what == "BOXED")
- printf (" G_TYPE_%s, %s, %s, },\n", generate_what, boxed_copy, boxed_free);
- else
- printf (" G_TYPE_%s, %s_values },\n", generate_what, type_ident);
- }
- if (gen_vars)
- {
- printf ("EELTYPEBUILTINS_VAR GType %s = 0;\n", type_macro);
- }
-}
-
-# skip scheme comments
-";" {
- sub (";.*", "");
-}
-
-# parse keywords
-
-/\(define-enum/ {
- if ($2 == "")
- printf ("huh? define-enum keyword without arg?\n") > "/dev/stderr";
- else
- {
- set_type($2);
- generate("ENUM");
- }
-}
-
-/\(define-flags/ {
- if ($2 == "")
- printf ("huh? define-flags keyword without arg?\n") > "/dev/stderr";
- else
- {
- set_type($2);
- generate("FLAGS");
- }
-}
-
-/\(define-boxed/ {
- if ($2 == "")
- printf ("huh? define-boxed keyword without arg?\n") > "/dev/stderr";
- else
- {
- boxed_copy = "NULL";
- boxed_free = "NULL";
- set_type($2);
- do {
- getline;
- sub (";.*", "", $0);
- } while ($0 ~ /^[ \t]*$/);
- tmp_var1 = $1;
- if ($0 ~ /\)/) { generate("BOXED"); next; }
- do {
- getline;
- sub (";.*", "", $0);
- } while ($0 ~ /^[ \t]*$/);
- tmp_var2 = $1;
- sub (/\).*/, "", tmp_var2);
- if (tmp_var1 ~ /^[_A-Za-z][_A-Za-z0-9]*$/ &&
- tmp_var2 ~ /^[_A-Za-z][_A-Za-z0-9]*$/)
- {
- boxed_copy = tmp_var1;
- boxed_free = tmp_var2;
- # printf ("read boxed funcs: %s %s\n", boxed_copy, boxed_free) > "/dev/stderr";
- }
- generate("BOXED");
- }
-}
-
-END {
- if (gen_macros)
- printf("\n#define\tEEL_TYPE_N_BUILTINS\t(%u)\n", type_counter);
-}
diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am
index 6d1c343d..55cadeee 100644
--- a/libcaja-private/Makefile.am
+++ b/libcaja-private/Makefile.am
@@ -18,6 +18,11 @@ INCLUDES = \
$(UNIQUE_CFLAGS) \
$(NULL)
+BUILT_SOURCES = \
+ caja-marshal.c \
+ caja-marshal.h \
+ $(NULL)
+
dependency_static_libs = \
$(top_builddir)/cut-n-paste-code/libegg/libegg.la \
$(NULL)
@@ -36,18 +41,11 @@ libcaja_private_la_LIBADD = \
$(CORE_LIBS) \
$(NULL)
-marshal_sources = \
- caja-marshal.h \
- caja-marshal-guts.c \
- $(NULL)
-
libcaja_private_la_SOURCES = \
caja-autorun.c \
caja-autorun.h \
caja-bookmark.c \
caja-bookmark.h \
- caja-cell-renderer-pixbuf-emblem.c \
- caja-cell-renderer-pixbuf-emblem.h \
caja-cell-renderer-text-ellipsized.c \
caja-cell-renderer-text-ellipsized.h \
caja-clipboard-monitor.c \
@@ -107,8 +105,6 @@ libcaja_private_la_SOURCES = \
caja-file.h \
caja-global-preferences.c \
caja-global-preferences.h \
- caja-horizontal-splitter.c \
- caja-horizontal-splitter.h \
caja-icon-canvas-item.c \
caja-icon-canvas-item.h \
caja-icon-container.c \
@@ -121,15 +117,12 @@ libcaja_private_la_SOURCES = \
caja-icon-names.h \
caja-idle-queue.c \
caja-idle-queue.h \
- caja-iso9660.h \
caja-keep-last-vertical-box.c \
caja-keep-last-vertical-box.h \
caja-lib-self-check-functions.c \
caja-lib-self-check-functions.h \
caja-link.c \
caja-link.h \
- caja-marshal.c \
- caja-marshal.h \
caja-merged-directory.c \
caja-merged-directory.h \
caja-metadata.h \
@@ -198,14 +191,29 @@ libcaja_private_la_SOURCES = \
caja-undostack-manager.h \
$(NULL)
+nodist_libcaja_private_la_SOURCES =\
+ $(BUILT_SOURCES) \
+ $(NULL)
+
$(lib_LTLIBRARIES): $(dependency_static_libs)
-caja-marshal.h: caja-marshal.list $(GLIB_GENMARSHAL)
- $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=caja_marshal > $@
-caja-marshal-guts.c: caja-marshal.list $(GLIB_GENMARSHAL)
- $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --body --prefix=caja_marshal > $@
+caja-marshal.list: $(libcaja_private_la_SOURCES) Makefile.am
+ $(AM_V_GEN)( cd $(srcdir) && \
+ sed -n -e 's/.*caja_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \
+ $(libcaja_private_la_SOURCES) ) \
+ | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > [email protected]
+ @if cmp -s [email protected] $@; then \
+ else \
+ fi
+
+%-marshal.h: %-marshal.list Makefile
+ $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
-$(libcaja_private_la_OBJECTS): $(marshal_sources)
+%-marshal.c: %-marshal.list Makefile
+ $(AM_V_GEN)echo "#include \"caja-marshal.h\"" > $@ && \
+ $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c
gsettingsschema_in_files = org.mate.caja.gschema.xml.in org.mate.media-handling.gschema.xml.in
gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
@@ -223,9 +231,10 @@ EXTRA_DIST = \
$(NULL)
CLEANFILES = \
- $(marshal_sources) \
+ $(BUILT_SOURCES) \
$(schema_DATA) \
$(gsettings_SCHEMAS) \
+ caja-marshal.list \
$(NULL)
dist-hook:
diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c
index cf801b08..66534642 100644
--- a/libcaja-private/caja-autorun.c
+++ b/libcaja-private/caja-autorun.c
@@ -33,7 +33,6 @@
#include <gdk/gdkkeysyms.h>
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-stock-dialogs.h>
#include "caja-icon-info.h"
#include "caja-global-preferences.h"
@@ -274,7 +273,7 @@ dialog_response_cb (GtkDialog *dialog,
}
static void
-dialog_destroy_cb (GtkObject *object,
+dialog_destroy_cb (GtkWidget *object,
CajaAutorunComboBoxData *data)
{
handle_dialog_closure (data);
@@ -652,7 +651,8 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
{
g_object_unref (default_app_info);
}
- eel_g_object_list_free (app_info_list);
+ g_list_foreach (app_info_list, (GFunc) g_object_unref, NULL);
+ g_list_free(app_info_list);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (list_store));
g_object_unref (G_OBJECT (list_store));
@@ -747,8 +747,13 @@ is_shift_pressed (void)
ret = FALSE;
gdk_error_trap_push ();
- status = XkbGetState (GDK_DISPLAY (), XkbUseCoreKbd, &state);
+ status = XkbGetState (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ XkbUseCoreKbd, &state);
+#if GTK_CHECK_VERSION(3,0,0)
+ gdk_error_trap_pop_ignored ();
+#else
gdk_error_trap_pop ();
+#endif
if (status == Success)
{
@@ -907,7 +912,7 @@ autorun_always_toggled (GtkToggleButton *togglebutton, AutorunDialogData *data)
static gboolean
combo_box_enter_ok (GtkWidget *togglebutton, GdkEventKey *event, GtkDialog *dialog)
{
- if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return)
+ if (event->keyval == GDK_KEY_KP_Enter || event->keyval == GDK_KEY_Return)
{
gtk_dialog_response (dialog, GTK_RESPONSE_OK);
return TRUE;
@@ -992,7 +997,6 @@ show_dialog:
dialog = gtk_dialog_new ();
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
diff --git a/libcaja-private/caja-bookmark.c b/libcaja-private/caja-bookmark.c
index e20efd96..48952fbb 100644
--- a/libcaja-private/caja-bookmark.c
+++ b/libcaja-private/caja-bookmark.c
@@ -29,10 +29,10 @@
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
+#include <string.h>
#include <libcaja-private/caja-file.h>
#include <libcaja-private/caja-icon-names.h>
@@ -143,7 +143,7 @@ caja_bookmark_compare_with (gconstpointer a, gconstpointer b)
bookmark_a = CAJA_BOOKMARK (a);
bookmark_b = CAJA_BOOKMARK (b);
- if (eel_strcmp (bookmark_a->details->name,
+ if (g_strcmp0 (bookmark_a->details->name,
bookmark_b->details->name) != 0)
{
return 1;
diff --git a/libcaja-private/caja-cell-renderer-pixbuf-emblem.c b/libcaja-private/caja-cell-renderer-pixbuf-emblem.c
deleted file mode 100644
index 4fec3a4a..00000000
--- a/libcaja-private/caja-cell-renderer-pixbuf-emblem.c
+++ /dev/null
@@ -1,519 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- caja-cell-renderer-pixbuf-emblem.c: cell renderer which can render
- an emblem on top of a pixbuf (for use in FMListView and FMTreeView)
-
- Copyright (C) 2003 Juerg Billeter
-
- 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 St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This is based on GtkCellRendererPixbuf written by
- Jonathan Blandford <[email protected]>
-
- Author: Juerg Billeter <[email protected]>
-*/
-
-#include "caja-cell-renderer-pixbuf-emblem.h"
-
-static void caja_cell_renderer_pixbuf_emblem_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void caja_cell_renderer_pixbuf_emblem_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static void caja_cell_renderer_pixbuf_emblem_init (CajaCellRendererPixbufEmblem *cellpixbuf);
-static void caja_cell_renderer_pixbuf_emblem_class_init (CajaCellRendererPixbufEmblemClass *klass);
-static void caja_cell_renderer_pixbuf_emblem_finalize (GObject *object);
-static void caja_cell_renderer_pixbuf_emblem_create_stock_pixbuf (CajaCellRendererPixbufEmblem *cellpixbuf,
- GtkWidget *widget);
-static void caja_cell_renderer_pixbuf_emblem_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- GdkRectangle *rectangle,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height);
-static void caja_cell_renderer_pixbuf_emblem_render (GtkCellRenderer *cell,
- GdkWindow *window,
- GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
- GtkCellRendererState flags);
-
-enum
-{
- PROP_ZERO,
- PROP_PIXBUF,
- PROP_PIXBUF_EXPANDER_OPEN,
- PROP_PIXBUF_EXPANDER_CLOSED,
- PROP_STOCK_ID,
- PROP_STOCK_SIZE,
- PROP_STOCK_DETAIL,
- PROP_PIXBUF_EMBLEM
-};
-
-#define CELLINFO_KEY "caja-cell-renderer-pixbuf-emblem-info"
-
-typedef struct _CajaCellRendererPixbufEmblemInfo CajaCellRendererPixbufEmblemInfo;
-struct _CajaCellRendererPixbufEmblemInfo
-{
- gchar *stock_id;
- GtkIconSize stock_size;
- gchar *stock_detail;
-};
-
-G_DEFINE_TYPE (CajaCellRendererPixbufEmblem, caja_cell_renderer_pixbuf_emblem, GTK_TYPE_CELL_RENDERER);
-
-static void
-caja_cell_renderer_pixbuf_emblem_init (CajaCellRendererPixbufEmblem *cellpixbuf)
-{
- CajaCellRendererPixbufEmblemInfo *cellinfo;
-
- cellinfo = g_new0 (CajaCellRendererPixbufEmblemInfo, 1);
- cellinfo->stock_size = GTK_ICON_SIZE_MENU;
- g_object_set_data (G_OBJECT (cellpixbuf), CELLINFO_KEY, cellinfo);
-}
-
-static void
-caja_cell_renderer_pixbuf_emblem_class_init (CajaCellRendererPixbufEmblemClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
-
- object_class->finalize = caja_cell_renderer_pixbuf_emblem_finalize;
-
- object_class->get_property = caja_cell_renderer_pixbuf_emblem_get_property;
- object_class->set_property = caja_cell_renderer_pixbuf_emblem_set_property;
-
- cell_class->get_size = caja_cell_renderer_pixbuf_emblem_get_size;
- cell_class->render = caja_cell_renderer_pixbuf_emblem_render;
-
- g_object_class_install_property (object_class,
- PROP_PIXBUF,
- g_param_spec_object ("pixbuf",
- "Pixbuf Object",
- "The pixbuf to render",
- GDK_TYPE_PIXBUF,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
-
- g_object_class_install_property (object_class,
- PROP_PIXBUF_EXPANDER_OPEN,
- g_param_spec_object ("pixbuf_expander_open",
- "Pixbuf Expander Open",
- "Pixbuf for open expander",
- GDK_TYPE_PIXBUF,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
-
- g_object_class_install_property (object_class,
- PROP_PIXBUF_EXPANDER_CLOSED,
- g_param_spec_object ("pixbuf_expander_closed",
- "Pixbuf Expander Closed",
- "Pixbuf for closed expander",
- GDK_TYPE_PIXBUF,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
-
- g_object_class_install_property (object_class,
- PROP_STOCK_ID,
- g_param_spec_string ("stock_id",
- "Stock ID",
- "The stock ID of the stock icon to render",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_STOCK_SIZE,
- g_param_spec_enum ("stock_size",
- "Size",
- "The size of the rendered icon",
- GTK_TYPE_ICON_SIZE,
- GTK_ICON_SIZE_MENU,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_STOCK_DETAIL,
- g_param_spec_string ("stock_detail",
- "Detail",
- "Render detail to pass to the theme engine",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_PIXBUF_EMBLEM,
- g_param_spec_object ("pixbuf_emblem",
- "Pixbuf Emblem Object",
- "The emblem to overlay",
- GDK_TYPE_PIXBUF,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
-}
-
-static void
-caja_cell_renderer_pixbuf_emblem_finalize (GObject *object)
-{
- CajaCellRendererPixbufEmblem *cellpixbuf = CAJA_CELL_RENDERER_PIXBUF_EMBLEM (object);
- CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY);
-
- if (cellpixbuf->pixbuf && cellinfo->stock_id)
- {
- g_object_unref (cellpixbuf->pixbuf);
- }
-
- if (cellinfo->stock_id)
- {
- g_free (cellinfo->stock_id);
- }
-
- if (cellinfo->stock_detail)
- {
- g_free (cellinfo->stock_detail);
- }
-
- g_free (cellinfo);
- g_object_set_data (object, CELLINFO_KEY, NULL);
-
- (* G_OBJECT_CLASS (caja_cell_renderer_pixbuf_emblem_parent_class)->finalize) (object);
-}
-
-static void
-caja_cell_renderer_pixbuf_emblem_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- CajaCellRendererPixbufEmblem *cellpixbuf = CAJA_CELL_RENDERER_PIXBUF_EMBLEM (object);
- CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY);
-
- switch (param_id)
- {
- case PROP_PIXBUF:
- g_value_set_object (value,
- cellpixbuf->pixbuf ? G_OBJECT (cellpixbuf->pixbuf) : NULL);
- break;
- case PROP_PIXBUF_EXPANDER_OPEN:
- g_value_set_object (value,
- cellpixbuf->pixbuf_expander_open ? G_OBJECT (cellpixbuf->pixbuf_expander_open) : NULL);
- break;
- case PROP_PIXBUF_EXPANDER_CLOSED:
- g_value_set_object (value,
- cellpixbuf->pixbuf_expander_closed ? G_OBJECT (cellpixbuf->pixbuf_expander_closed) : NULL);
- break;
- case PROP_STOCK_ID:
- g_value_set_string (value, cellinfo->stock_id);
- break;
- case PROP_STOCK_SIZE:
- g_value_set_enum (value, cellinfo->stock_size);
- break;
- case PROP_STOCK_DETAIL:
- g_value_set_string (value, cellinfo->stock_detail);
- break;
- case PROP_PIXBUF_EMBLEM:
- g_value_set_object (value,
- cellpixbuf->pixbuf_emblem ? G_OBJECT (cellpixbuf->pixbuf_emblem) : NULL);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-caja_cell_renderer_pixbuf_emblem_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdkPixbuf *pixbuf;
- CajaCellRendererPixbufEmblem *cellpixbuf = CAJA_CELL_RENDERER_PIXBUF_EMBLEM (object);
- CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY);
-
- switch (param_id)
- {
- case PROP_PIXBUF:
- pixbuf = (GdkPixbuf*) g_value_get_object (value);
- if (pixbuf)
- {
- g_object_ref (pixbuf);
- }
- if (cellpixbuf->pixbuf)
- {
- g_object_unref (cellpixbuf->pixbuf);
- }
- cellpixbuf->pixbuf = pixbuf;
- break;
- case PROP_PIXBUF_EXPANDER_OPEN:
- pixbuf = (GdkPixbuf*) g_value_get_object (value);
- if (pixbuf)
- {
- g_object_ref (pixbuf);
- }
- if (cellpixbuf->pixbuf_expander_open)
- {
- g_object_unref (cellpixbuf->pixbuf_expander_open);
- }
- cellpixbuf->pixbuf_expander_open = pixbuf;
- break;
- case PROP_PIXBUF_EXPANDER_CLOSED:
- pixbuf = (GdkPixbuf*) g_value_get_object (value);
- if (pixbuf)
- {
- g_object_ref (pixbuf);
- }
- if (cellpixbuf->pixbuf_expander_closed)
- {
- g_object_unref (cellpixbuf->pixbuf_expander_closed);
- }
- cellpixbuf->pixbuf_expander_closed = pixbuf;
- break;
- case PROP_STOCK_ID:
- if (cellinfo->stock_id)
- {
- g_free (cellinfo->stock_id);
- }
- cellinfo->stock_id = g_strdup (g_value_get_string (value));
- break;
- case PROP_STOCK_SIZE:
- cellinfo->stock_size = g_value_get_enum (value);
- break;
- case PROP_STOCK_DETAIL:
- if (cellinfo->stock_detail)
- {
- g_free (cellinfo->stock_detail);
- }
- cellinfo->stock_detail = g_strdup (g_value_get_string (value));
- break;
- case PROP_PIXBUF_EMBLEM:
- pixbuf = (GdkPixbuf *) g_value_get_object (value);
- if (pixbuf)
- {
- g_object_ref (pixbuf);
- }
- if (cellpixbuf->pixbuf_emblem)
- {
- g_object_unref (cellpixbuf->pixbuf_emblem);
- }
- cellpixbuf->pixbuf_emblem = pixbuf;
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-GtkCellRenderer *
-caja_cell_renderer_pixbuf_emblem_new (void)
-{
- return g_object_new (CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, NULL);
-}
-
-static void
-caja_cell_renderer_pixbuf_emblem_create_stock_pixbuf (CajaCellRendererPixbufEmblem *cellpixbuf,
- GtkWidget *widget)
-{
- CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (G_OBJECT (cellpixbuf), CELLINFO_KEY);
-
- if (cellpixbuf->pixbuf)
- {
- g_object_unref (cellpixbuf->pixbuf);
- }
-
- cellpixbuf->pixbuf = gtk_widget_render_icon (widget,
- cellinfo->stock_id,
- cellinfo->stock_size,
- cellinfo->stock_detail);
-}
-
-static void
-caja_cell_renderer_pixbuf_emblem_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- GdkRectangle *cell_area,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height)
-{
- CajaCellRendererPixbufEmblem *cellpixbuf = (CajaCellRendererPixbufEmblem *) cell;
- CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY);
- gint pixbuf_width = 0;
- gint pixbuf_height = 0;
- gint calc_width;
- gint calc_height;
- gint xpad, ypad;
-
- if (!cellpixbuf->pixbuf && cellinfo->stock_id)
- caja_cell_renderer_pixbuf_emblem_create_stock_pixbuf (cellpixbuf, widget);
-
- if (cellpixbuf->pixbuf)
- {
- pixbuf_width = gdk_pixbuf_get_width (cellpixbuf->pixbuf);
- pixbuf_height = gdk_pixbuf_get_height (cellpixbuf->pixbuf);
- }
- if (cellpixbuf->pixbuf_expander_open)
- {
- pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_open));
- pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_open));
- }
- if (cellpixbuf->pixbuf_expander_closed)
- {
- pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_closed));
- pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_closed));
- }
-
- gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
- calc_width = xpad * 2 + pixbuf_width;
- calc_height = ypad * 2 + pixbuf_height;
-
- if (x_offset) *x_offset = 0;
- if (y_offset) *y_offset = 0;
-
- if (cell_area && pixbuf_width > 0 && pixbuf_height > 0)
- {
- gfloat xalign, yalign;
-
- gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
- if (x_offset)
- {
- *x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
- 1.0 - xalign : xalign) *
- (cell_area->width - calc_width - 2 * xpad));
- *x_offset = MAX (*x_offset, 0) + xpad;
- }
- if (y_offset)
- {
- *y_offset = (yalign *
- (cell_area->height - calc_height - 2 * ypad));
- *y_offset = MAX (*y_offset, 0) + ypad;
- }
- }
-
- if (width)
- *width = calc_width;
-
- if (height)
- *height = calc_height;
-}
-
-static void
-caja_cell_renderer_pixbuf_emblem_render (GtkCellRenderer *cell,
- GdkWindow *window,
- GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
- GtkCellRendererState flags)
-
-{
- CajaCellRendererPixbufEmblem *cellpixbuf = (CajaCellRendererPixbufEmblem *) cell;
- CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY);
- GdkPixbuf *pixbuf;
- GdkRectangle pix_rect;
- GdkRectangle pix_emblem_rect;
- GdkRectangle draw_rect;
- gboolean stock_pixbuf = FALSE;
- gint xpad, ypad;
- gboolean is_expander, is_expanded;
-
- pixbuf = cellpixbuf->pixbuf;
- g_object_get (cell,
- "is-expander", &is_expander,
- "is-expanded", &is_expanded,
- NULL);
- if (is_expander)
- {
- if (is_expanded &&
- cellpixbuf->pixbuf_expander_open != NULL)
- {
- pixbuf = cellpixbuf->pixbuf_expander_open;
- }
- else if (!is_expanded &&
- cellpixbuf->pixbuf_expander_closed != NULL)
- {
- pixbuf = cellpixbuf->pixbuf_expander_closed;
- }
- }
-
- if (!pixbuf && !cellinfo->stock_id)
- {
- return;
- }
- else if (!pixbuf && cellinfo->stock_id)
- {
- stock_pixbuf = TRUE;
- }
-
- caja_cell_renderer_pixbuf_emblem_get_size (cell, widget, cell_area,
- &pix_rect.x,
- &pix_rect.y,
- &pix_rect.width,
- &pix_rect.height);
-
- if (stock_pixbuf)
- pixbuf = cellpixbuf->pixbuf;
-
- gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
- pix_rect.x += cell_area->x;
- pix_rect.y += cell_area->y;
- pix_rect.width -= xpad * 2;
- pix_rect.height -= ypad * 2;
-
- if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect) &&
- gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
- {
- gdk_draw_pixbuf (window,
- gtk_widget_get_style (widget)->black_gc,
- pixbuf,
- /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */
- draw_rect.x - pix_rect.x,
- draw_rect.y - pix_rect.y,
- draw_rect.x,
- draw_rect.y,
- draw_rect.width,
- draw_rect.height,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- }
-
- if (cellpixbuf->pixbuf_emblem)
- {
- pix_emblem_rect.width = gdk_pixbuf_get_width (cellpixbuf->pixbuf_emblem);
- pix_emblem_rect.height = gdk_pixbuf_get_height (cellpixbuf->pixbuf_emblem);
- pix_emblem_rect.x = pix_rect.x;
- pix_emblem_rect.y = pix_rect.y + pix_rect.height - pix_emblem_rect.height;
- if (gdk_rectangle_intersect (cell_area, &pix_emblem_rect, &draw_rect) &&
- gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
- {
- gdk_draw_pixbuf (window,
- gtk_widget_get_style (widget)->black_gc,
- cellpixbuf->pixbuf_emblem,
- /* pixbuf 0, 0 is at pix_emblem_rect.x, pix_emblem_rect.y */
- draw_rect.x - pix_emblem_rect.x,
- draw_rect.y - pix_emblem_rect.y,
- draw_rect.x,
- draw_rect.y,
- draw_rect.width,
- draw_rect.height,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- }
- }
-}
diff --git a/libcaja-private/caja-cell-renderer-pixbuf-emblem.h b/libcaja-private/caja-cell-renderer-pixbuf-emblem.h
deleted file mode 100644
index cfdf93d4..00000000
--- a/libcaja-private/caja-cell-renderer-pixbuf-emblem.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- caja-cell-renderer-pixbuf-emblem.h: cell renderer which can render
- an emblem on top of a pixbuf (for use in FMListView and FMTreeView)
-
- Copyright (C) 2003 Juerg Billeter
-
- 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 St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This is based on GtkCellRendererPixbuf written by
- Jonathan Blandford <[email protected]>
-
- Author: Juerg Billeter <[email protected]>
-*/
-
-#ifndef CAJA_CELL_RENDERER_PIXBUF_EMBLEM_H
-#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM_H
-
-#include <gtk/gtk.h>
-
-#define CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM caja_cell_renderer_pixbuf_emblem_get_type()
-#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, CajaCellRendererPixbufEmblem))
-#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, CajaCellRendererPixbufEmblemClass))
-#define CAJA_IS_CELL_RENDERER_PIXBUF_EMBLEM(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM))
-#define CAJA_IS_CELL_RENDERER_PIXBUF_EMBLEM_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM))
-#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, CajaCellRendererPixbufEmblemClass))
-
-typedef struct _CajaCellRendererPixbufEmblem CajaCellRendererPixbufEmblem;
-typedef struct _CajaCellRendererPixbufEmblemClass CajaCellRendererPixbufEmblemClass;
-
-struct _CajaCellRendererPixbufEmblem
-{
- GtkCellRenderer parent;
-
- /*< private >*/
- GdkPixbuf *pixbuf;
- GdkPixbuf *pixbuf_expander_open;
- GdkPixbuf *pixbuf_expander_closed;
- GdkPixbuf *pixbuf_emblem;
-};
-
-struct _CajaCellRendererPixbufEmblemClass
-{
- GtkCellRendererClass parent_class;
-};
-
-GType caja_cell_renderer_pixbuf_emblem_get_type (void);
-GtkCellRenderer *caja_cell_renderer_pixbuf_emblem_new (void);
-
-#endif /* CAJA_CELL_RENDERER_PIXBUF_EMBLEM_H */
diff --git a/libcaja-private/caja-cell-renderer-text-ellipsized.c b/libcaja-private/caja-cell-renderer-text-ellipsized.c
index 4c3cd443..ad535a5d 100644
--- a/libcaja-private/caja-cell-renderer-text-ellipsized.c
+++ b/libcaja-private/caja-cell-renderer-text-ellipsized.c
@@ -26,55 +26,81 @@
#include "caja-cell-renderer-text-ellipsized.h"
-#define ELLIPSIZE_PROP "ellipsize"
-
-static void caja_cell_renderer_text_ellipsized_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- GdkRectangle *rectangle,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height);
-
G_DEFINE_TYPE (CajaCellRendererTextEllipsized, caja_cell_renderer_text_ellipsized,
GTK_TYPE_CELL_RENDERER_TEXT);
+#if GTK_CHECK_VERSION(3,0,0)
static void
caja_cell_renderer_text_ellipsized_init (CajaCellRendererTextEllipsized *cell)
{
- g_object_set (cell, ELLIPSIZE_PROP, PANGO_ELLIPSIZE_END, NULL);
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "ellipsize-set", TRUE,
+ NULL);
}
static void
-caja_cell_renderer_text_ellipsized_class_init (CajaCellRendererTextEllipsizedClass *klass)
+nautilus_cell_renderer_text_ellipsized_get_preferred_width (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
-
- cell_class->get_size = caja_cell_renderer_text_ellipsized_get_size;
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_NONE,
+ "ellipsize-set", FALSE,
+ NULL);
+
+ GTK_CELL_RENDERER_CLASS
+ (nautilus_cell_renderer_text_ellipsized_parent_class)->get_preferred_width (cell, widget,
+ minimum_size, natural_size);
+
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "ellipsize-set", TRUE,
+ NULL);
}
-
-GtkCellRenderer *
-caja_cell_renderer_text_ellipsized_new (void)
+#else /* GTK_CHECK_VERSION(3,0,0) */
+static void
+caja_cell_renderer_text_ellipsized_init (CajaCellRendererTextEllipsized *cell)
{
- return g_object_new (CAJA_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NULL);
+ g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
}
static void
caja_cell_renderer_text_ellipsized_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- GdkRectangle *cell_area,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height)
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
{
- g_object_set (cell, ELLIPSIZE_PROP, PANGO_ELLIPSIZE_NONE, NULL);
+ g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL);
- (* GTK_CELL_RENDERER_CLASS (caja_cell_renderer_text_ellipsized_parent_class)->get_size)
- (cell, widget, cell_area,
- x_offset, y_offset,
- width, height);
+ GTK_CELL_RENDERER_CLASS
+ (caja_cell_renderer_text_ellipsized_parent_class)->get_size (cell, widget,
+ cell_area,
+ x_offset, y_offset,
+ width, height);
- g_object_set (cell, ELLIPSIZE_PROP, PANGO_ELLIPSIZE_END, NULL);
+ g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
}
+#endif /* GTK_CHECK_VERSION(3,0,0) */
+static void
+caja_cell_renderer_text_ellipsized_class_init (CajaCellRendererTextEllipsizedClass *klass)
+{
+ GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cell_class->get_preferred_width = caja_cell_renderer_text_ellipsized_get_preferred_width;
+#else
+ cell_class->get_size = caja_cell_renderer_text_ellipsized_get_size;
+#endif
+}
+
+GtkCellRenderer *
+caja_cell_renderer_text_ellipsized_new (void)
+{
+ return g_object_new (CAJA_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NULL);
+}
diff --git a/libcaja-private/caja-clipboard.c b/libcaja-private/caja-clipboard.c
index b1614509..bce5d552 100644
--- a/libcaja-private/caja-clipboard.c
+++ b/libcaja-private/caja-clipboard.c
@@ -33,7 +33,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <eel/eel-glib-extensions.h>
#include <string.h>
typedef struct _TargetCallbackData TargetCallbackData;
@@ -432,7 +431,7 @@ owner_change_callback (GtkClipboard *clipboard,
}
static void
-target_destroy_callback (GtkObject *object,
+target_destroy_callback (GtkWidget *object,
gpointer callback_data)
{
TargetCallbackData *target_data;
@@ -440,7 +439,7 @@ target_destroy_callback (GtkObject *object,
g_assert (callback_data != NULL);
target_data = callback_data;
- if (clipboard_items_are_merged_in (GTK_WIDGET(object)))
+ if (clipboard_items_are_merged_in (object))
{
merge_out_clipboard_menu_items (G_OBJECT (object), callback_data);
}
@@ -662,31 +661,27 @@ caja_clipboard_clear_if_colliding_uris (GtkWidget *widget,
collision = FALSE;
data = gtk_clipboard_wait_for_contents (caja_clipboard_get (widget),
copied_files_atom);
- if (data == NULL)
- {
+ if (data == NULL) {
return;
}
clipboard_item_uris = caja_clipboard_get_uri_list_from_selection_data (data, NULL,
copied_files_atom);
- for (l = (GList *) item_uris; l; l = l->next)
- {
+ for (l = (GList *) item_uris; l; l = l->next) {
if (g_list_find_custom ((GList *) item_uris, l->data,
- (GCompareFunc) g_strcmp0))
- {
+ (GCompareFunc) g_strcmp0)) {
collision = TRUE;
break;
}
}
- if (collision)
- {
+ if (collision) {
gtk_clipboard_clear (caja_clipboard_get (widget));
}
- if (clipboard_item_uris)
- {
- eel_g_list_free_deep (clipboard_item_uris);
+ if (clipboard_item_uris) {
+ g_list_foreach (clipboard_item_uris, (GFunc) g_free, NULL);
+ g_list_free(clipboard_item_uris);
}
}
diff --git a/libcaja-private/caja-column-utilities.c b/libcaja-private/caja-column-utilities.c
index 3b789221..1ba570df 100644
--- a/libcaja-private/caja-column-utilities.c
+++ b/libcaja-private/caja-column-utilities.c
@@ -113,6 +113,7 @@ get_builtin_columns (void)
"label", _("MIME Type"),
"description", _("The mime type of the file."),
NULL));
+#ifdef HAVE_SELINUX
columns = g_list_append (columns,
g_object_new (CAJA_TYPE_COLUMN,
"name", "selinux_context",
@@ -120,13 +121,13 @@ get_builtin_columns (void)
"label", _("SELinux Context"),
"description", _("The SELinux security context of the file."),
NULL));
+#endif
columns = g_list_append (columns,
g_object_new (CAJA_TYPE_COLUMN,
"name", "where",
"attribute", "where",
"label", _("Location"),
- /* TODO: Change after string freeze over */
- "description", _("Location"),
+ "description", _("The location of the file."),
NULL));
return columns;
diff --git a/libcaja-private/caja-customization-data.c b/libcaja-private/caja-customization-data.c
index f29eee40..01521d0a 100644
--- a/libcaja-private/caja-customization-data.c
+++ b/libcaja-private/caja-customization-data.c
@@ -31,12 +31,9 @@
#include "caja-file-utilities.h"
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-extensions.h>
-#include <eel/eel-pango-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-vfs-extensions.h>
-#include <eel/eel-string.h>
#include <eel/eel-xml-extensions.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>
@@ -261,7 +258,7 @@ caja_customization_data_get_next_element_for_display (CajaCustomizationData *dat
label_out);
}
- is_reset_image = eel_strcmp(g_file_info_get_name (current_file_info), RESET_IMAGE_NAME) == 0;
+ is_reset_image = g_strcmp0(g_file_info_get_name (current_file_info), RESET_IMAGE_NAME) == 0;
*emblem_name = g_strdup (g_file_info_get_name (current_file_info));
@@ -307,8 +304,10 @@ caja_customization_data_destroy (CajaCustomizationData *data)
g_object_unref (data->pattern_frame);
}
- eel_g_object_list_free (data->public_file_list);
- eel_g_object_list_free (data->private_file_list);
+ g_list_foreach(data->public_file_list, (GFunc) g_object_unref, NULL);
+ g_list_free(data->public_file_list);
+ g_list_foreach(data->private_file_list, (GFunc) g_object_unref, NULL);
+ g_list_free(data->private_file_list);
if (data->name_map_hash != NULL)
{
@@ -428,7 +427,7 @@ format_name_for_display (CajaCustomizationData *data, const char* name)
{
char *formatted_str, *mapped_name;
- if (!eel_strcmp(name, RESET_IMAGE_NAME))
+ if (!g_strcmp0(name, RESET_IMAGE_NAME))
{
return g_strdup (_("Reset"));
}
diff --git a/libcaja-private/caja-debug-log.c b/libcaja-private/caja-debug-log.c
index 89ff6933..1ccfed0b 100644
--- a/libcaja-private/caja-debug-log.c
+++ b/libcaja-private/caja-debug-log.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <time.h>
#include <sys/time.h>
-#include <eel/eel-glib-extensions.h>
#include "caja-debug-log.h"
#include "caja-file.h"
@@ -309,7 +308,8 @@ caja_debug_log_with_file_list (gboolean is_milestone, const char *domain, GList
caja_debug_logv (is_milestone, domain, uris, format, args);
va_end (args);
- eel_g_list_free_deep (uris);
+ g_list_foreach (uris, (GFunc) g_free, NULL);
+ g_list_free(uris);
}
gboolean
diff --git a/libcaja-private/caja-directory-async.c b/libcaja-private/caja-directory-async.c
index a20d90d7..9694b1b0 100644
--- a/libcaja-private/caja-directory-async.c
+++ b/libcaja-private/caja-directory-async.c
@@ -34,7 +34,6 @@
#include "caja-link.h"
#include "caja-marshal.h"
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
#include <gtk/gtk.h>
#include <libxml/parser.h>
#include <stdio.h>
@@ -1080,7 +1079,8 @@ dequeue_pending_idle_callback (gpointer callback_data)
file->details->got_mime_list = TRUE;
file->details->mime_list_is_up_to_date = TRUE;
- eel_g_list_free_deep (file->details->mime_list);
+ g_list_foreach (file->details->mime_list, (GFunc) g_free, NULL);
+ g_list_free(file->details->mime_list);
file->details->mime_list = istr_set_get_as_list
(dir_load_state->load_mime_list_hash);
@@ -1093,7 +1093,8 @@ dequeue_pending_idle_callback (gpointer callback_data)
}
drain:
- eel_g_object_list_free (pending_file_info);
+ g_list_foreach (pending_file_info, (GFunc) g_object_unref, NULL);
+ g_list_free(pending_file_info);
/* Get the state machine running again. */
caja_directory_async_state_changed (directory);
@@ -1181,7 +1182,8 @@ file_list_cancel (CajaDirectory *directory)
if (directory->details->pending_file_info != NULL)
{
- eel_g_object_list_free (directory->details->pending_file_info);
+ g_list_foreach (directory->details->pending_file_info, (GFunc) g_object_unref, NULL);
+ g_list_free(directory->details->pending_file_info);
directory->details->pending_file_info = NULL;
}
@@ -2786,7 +2788,8 @@ count_more_files_callback (GObject *source_object,
state);
}
- eel_g_object_list_free (files);
+ g_list_foreach (files, (GFunc) g_object_unref, NULL);
+ g_list_free(files);
if (error)
{
@@ -3011,7 +3014,8 @@ deep_count_state_free (DeepCountState *state)
{
g_object_unref (state->deep_count_location);
}
- eel_g_object_list_free (state->deep_count_subdirectories);
+ g_list_foreach (state->deep_count_subdirectories, (GFunc) g_object_unref, NULL);
+ g_list_free(state->deep_count_subdirectories);
g_array_free (state->seen_deep_count_inodes, TRUE);
g_free (state);
}
@@ -3319,7 +3323,8 @@ mime_list_done (MimeListState *state, gboolean success)
file = state->mime_list_file;
file->details->mime_list_is_up_to_date = TRUE;
- eel_g_list_free_deep (file->details->mime_list);
+ g_list_foreach(file->details->mime_list, (GFunc) g_free, NULL);
+ g_list_free(file->details->mime_list);
if (success)
{
file->details->mime_list_failed = TRUE;
@@ -4574,7 +4579,8 @@ get_mount_at (GFile *target)
g_object_unref (root);
}
- eel_g_object_list_free (mounts);
+ g_list_foreach (mounts, (GFunc) g_object_unref, NULL);
+ g_list_free(mounts);
g_object_unref (monitor);
diff --git a/libcaja-private/caja-directory-background.c b/libcaja-private/caja-directory-background.c
index 05a0f8e5..a445aab7 100644
--- a/libcaja-private/caja-directory-background.c
+++ b/libcaja-private/caja-directory-background.c
@@ -126,8 +126,6 @@ read_color (const char *key, GdkColor *color)
{
gdk_color_parse ("black", color);
}
-
- gdk_rgb_find_color (gdk_rgb_get_colormap (), color);
}
static void
@@ -298,11 +296,12 @@ desktop_background_settings_notify_cb (GSettings *settings, gchar *key, gpointer
}
static void
-desktop_background_destroyed_callback (EelBackground *background, void *georgeWBush)
+desktop_background_weak_notify (gpointer data,
+ GObject *object)
{
g_signal_handlers_disconnect_by_func(mate_background_preferences,
G_CALLBACK (desktop_background_settings_notify_cb),
- background);
+ object);
}
static void
@@ -311,10 +310,10 @@ caja_file_background_receive_settings_changes (EelBackground *background)
g_signal_connect (mate_background_preferences,
"changed",
G_CALLBACK (desktop_background_settings_notify_cb),
- background);
+ G_OBJECT (background));
- g_signal_connect (background, "destroy",
- G_CALLBACK (desktop_background_destroyed_callback), NULL);
+ g_object_weak_ref (G_OBJECT (background),
+ desktop_background_weak_notify, NULL);
}
/* return true if the background is not in the default state */
@@ -565,9 +564,11 @@ background_reset_callback (EelBackground *background,
/* handle the background destroyed signal */
static void
-background_destroyed_callback (EelBackground *background,
- CajaFile *file)
+background_weak_notify (gpointer data,
+ GObject *background)
{
+ CajaFile *file = CAJA_FILE (data);
+
g_signal_handlers_disconnect_by_func
(file,
G_CALLBACK (saved_settings_changed_callback), background);
@@ -600,23 +601,26 @@ caja_connect_background_to_file_metadata (GtkWidget *widget,
if (old_file != NULL)
{
g_assert (CAJA_IS_FILE (old_file));
- g_signal_handlers_disconnect_by_func
- (background,
- G_CALLBACK (background_changed_callback), old_file);
- g_signal_handlers_disconnect_by_func
- (background,
- G_CALLBACK (background_destroyed_callback), old_file);
- g_signal_handlers_disconnect_by_func
- (background,
- G_CALLBACK (background_reset_callback), old_file);
- g_signal_handlers_disconnect_by_func
- (old_file,
- G_CALLBACK (saved_settings_changed_callback), background);
+
+ g_signal_handlers_disconnect_by_func (background,
+ G_CALLBACK (background_changed_callback),
+ old_file);
+
+ g_signal_handlers_disconnect_by_func (background,
+ G_CALLBACK (background_reset_callback),
+ old_file);
+
+ g_object_weak_unref (G_OBJECT (background), background_weak_notify, old_file);
+
+ g_signal_handlers_disconnect_by_func (old_file,
+ G_CALLBACK (saved_settings_changed_callback),
+ background);
+
caja_file_monitor_remove (old_file, background);
+
g_signal_handlers_disconnect_by_func (caja_preferences,
caja_file_background_theme_changed,
background);
-
}
/* Attach the new directory. */
@@ -631,13 +635,15 @@ caja_connect_background_to_file_metadata (GtkWidget *widget,
{
g_signal_connect_object (background, "settings_changed",
G_CALLBACK (background_changed_callback), file, 0);
- g_signal_connect_object (background, "destroy",
- G_CALLBACK (background_destroyed_callback), file, 0);
+
g_signal_connect_object (background, "reset",
G_CALLBACK (background_reset_callback), file, 0);
+
g_signal_connect_object (file, "changed",
G_CALLBACK (saved_settings_changed_callback), background, 0);
+ g_object_weak_ref (G_OBJECT (background), background_weak_notify, file);
+
/* arrange to receive file metadata */
caja_file_monitor_add (file,
background,
diff --git a/libcaja-private/caja-directory.c b/libcaja-private/caja-directory.c
index 6479b38a..38d73794 100644
--- a/libcaja-private/caja-directory.c
+++ b/libcaja-private/caja-directory.c
@@ -32,14 +32,13 @@
#include "caja-search-directory.h"
#include "caja-global-preferences.h"
#include "caja-lib-self-check-functions.h"
-#include "caja-marshal.h"
#include "caja-metadata.h"
#include "caja-desktop-directory.h"
#include "caja-vfs-directory.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-string.h>
#include <gtk/gtk.h>
+#include <string.h>
enum
{
@@ -176,7 +175,8 @@ caja_directory_finalize (GObject *object)
if (directory->details->monitor_list != NULL)
{
g_warning ("destroying a CajaDirectory while it's being monitored");
- eel_g_list_free_deep (directory->details->monitor_list);
+ g_list_foreach(directory->details->monitor_list, (GFunc) g_free, NULL);
+ g_list_free(directory->details->monitor_list);
}
if (directory->details->monitor != NULL)
@@ -213,7 +213,8 @@ caja_directory_finalize (GObject *object)
g_assert (directory->details->directory_load_in_progress == NULL);
g_assert (directory->details->count_in_progress == NULL);
g_assert (directory->details->dequeue_pending_idle_id == 0);
- eel_g_object_list_free (directory->details->pending_file_info);
+ g_list_foreach(directory->details->pending_file_info, (GFunc) g_object_unref, NULL);
+ g_list_free(directory->details->pending_file_info);
EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
@@ -759,7 +760,7 @@ caja_directory_find_file_by_internal_filename (CajaDirectory *directory,
{
CajaFile *result;
- if (eel_strcmp (internal_filename, ".") == 0)
+ if (g_strcmp0 (internal_filename, ".") == 0)
{
result = caja_directory_get_existing_corresponding_file (directory);
if (result != NULL)
@@ -1093,7 +1094,8 @@ caja_directory_notify_files_added_by_uri (GList *uris)
files = caja_file_list_from_uris (uris);
caja_directory_notify_files_added (files);
- eel_g_object_list_free (files);
+ g_list_foreach(files, (GFunc) g_object_unref, NULL);
+ g_list_free(files);
}
void
@@ -1142,7 +1144,8 @@ caja_directory_notify_files_changed_by_uri (GList *uris)
files = caja_file_list_from_uris (uris);
caja_directory_notify_files_changed (files);
- eel_g_object_list_free (files);
+ g_list_foreach(files, (GFunc) g_object_unref, NULL);
+ g_list_free(files);
}
void
@@ -1203,7 +1206,8 @@ caja_directory_notify_files_removed_by_uri (GList *uris)
files = caja_file_list_from_uris (uris);
caja_directory_notify_files_changed (files);
- eel_g_object_list_free (files);
+ g_list_foreach(files, (GFunc) g_object_unref, NULL);
+ g_list_free(files);
}
static void
diff --git a/libcaja-private/caja-dnd.c b/libcaja-private/caja-dnd.c
index 87617a77..feea5ca8 100644
--- a/libcaja-private/caja-dnd.c
+++ b/libcaja-private/caja-dnd.c
@@ -129,7 +129,8 @@ caja_drag_uri_array_from_selection_list (const GList *selection_list)
uri_list = caja_drag_uri_list_from_selection_list (selection_list);
uris = caja_drag_uri_array_from_list (uri_list);
- eel_g_list_free_deep (uri_list);
+ g_list_foreach(uri_list, (GFunc) g_free, NULL);
+ g_list_free(uri_list);
return uris;
}
@@ -1315,7 +1316,9 @@ slot_proxy_handle_drop (GtkWidget *widget,
uri_list,
target_uri,
gdk_drag_context_get_selected_action (context));
- eel_g_list_free_deep (uri_list);
+ g_list_foreach(uri_list, (GFunc) g_free, NULL);
+ g_list_free(uri_list);
+
}
else if (drag_info->info == CAJA_ICON_DND_URI_LIST)
{
diff --git a/libcaja-private/caja-emblem-utils.c b/libcaja-private/caja-emblem-utils.c
index 3c41a016..dd70dbc3 100644
--- a/libcaja-private/caja-emblem-utils.c
+++ b/libcaja-private/caja-emblem-utils.c
@@ -37,7 +37,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-stock-dialogs.h>
@@ -120,7 +119,8 @@ is_reserved_keyword (const char *keyword)
result = g_list_find_custom (available,
(char *) icon_name,
(GCompareFunc) g_ascii_strcasecmp) != NULL;
- eel_g_list_free_deep (available);
+ g_list_foreach(available, (GFunc) g_free, NULL);
+ g_list_free(available);
g_free (icon_name);
return result;
}
diff --git a/libcaja-private/caja-entry.c b/libcaja-private/caja-entry.c
index 31b590c3..fb9ac38c 100644
--- a/libcaja-private/caja-entry.c
+++ b/libcaja-private/caja-entry.c
@@ -35,6 +35,10 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#if !GTK_CHECK_VERSION(3, 0, 0)
+#define GtkEditableInterface GtkEditableClass
+#endif
+
struct CajaEntryDetails
{
gboolean user_edit;
@@ -51,13 +55,13 @@ enum
};
static guint signals[LAST_SIGNAL];
-static void caja_entry_editable_init (GtkEditableClass *iface);
+static void caja_entry_editable_init (GtkEditableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (CajaEntry, caja_entry, GTK_TYPE_ENTRY,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
caja_entry_editable_init));
-static GtkEditableClass *parent_editable_interface = NULL;
+static GtkEditableInterface *parent_editable_interface = NULL;
static void
caja_entry_init (CajaEntry *entry)
@@ -123,7 +127,7 @@ caja_entry_key_press (GtkWidget *widget, GdkEventKey *event)
switch (event->keyval)
{
- case GDK_Tab:
+ case GDK_KEY_Tab:
/* The location bar entry wants TAB to work kind of
* like it does in the shell for command completion,
* so if we get a tab and there's a selection, we
@@ -373,7 +377,7 @@ caja_entry_selection_clear (GtkWidget *widget,
}
static void
-caja_entry_editable_init (GtkEditableClass *iface)
+caja_entry_editable_init (GtkEditableInterface *iface)
{
parent_editable_interface = g_type_interface_peek_parent (iface);
@@ -391,12 +395,10 @@ static void
caja_entry_class_init (CajaEntryClass *class)
{
GtkWidgetClass *widget_class;
- GtkObjectClass *object_class;
GObjectClass *gobject_class;
widget_class = GTK_WIDGET_CLASS (class);
gobject_class = G_OBJECT_CLASS (class);
- object_class = GTK_OBJECT_CLASS (class);
widget_class->button_press_event = caja_entry_button_press;
widget_class->button_release_event = caja_entry_button_release;
@@ -409,19 +411,17 @@ caja_entry_class_init (CajaEntryClass *class)
/* Set up signals */
signals[USER_CHANGED] = g_signal_new
("user_changed",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CajaEntryClass,
- user_changed),
+ G_STRUCT_OFFSET (CajaEntryClass, user_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SELECTION_CHANGED] = g_signal_new
("selection_changed",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CajaEntryClass,
- selection_changed),
+ G_STRUCT_OFFSET (CajaEntryClass, selection_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
diff --git a/libcaja-private/caja-file-changes-queue.c b/libcaja-private/caja-file-changes-queue.c
index b3cd1db0..39cf123e 100644
--- a/libcaja-private/caja-file-changes-queue.c
+++ b/libcaja-private/caja-file-changes-queue.c
@@ -24,7 +24,6 @@
#include "caja-file-changes-queue.h"
#include "caja-directory-notify.h"
-#include <eel/eel-glib-extensions.h>
#ifdef G_THREADS_ENABLED
#define MUTEX_LOCK(a) if ((a) != NULL) g_mutex_lock (a)
@@ -289,7 +288,8 @@ pairs_list_free (GList *pairs)
}
/* delete the list and the now empty pair structs */
- eel_g_list_free_deep (pairs);
+ g_list_foreach(pairs, (GFunc) g_free, NULL);
+ g_list_free(pairs);
}
static void
@@ -304,7 +304,8 @@ position_set_list_free (GList *list)
g_object_unref (item->location);
}
/* delete the list and the now empty structs */
- eel_g_list_free_deep (list);
+ g_list_foreach(list, (GFunc) g_free, NULL);
+ g_list_free(list);
}
/* go through changes in the change queue, send ones with the same kind
@@ -386,7 +387,8 @@ caja_file_changes_consume_changes (gboolean consume_all)
{
deletions = g_list_reverse (deletions);
caja_directory_notify_files_removed (deletions);
- eel_g_object_list_free (deletions);
+ g_list_foreach(deletions, (GFunc) g_object_unref, NULL);
+ g_list_free(deletions);
deletions = NULL;
}
if (moves != NULL)
@@ -400,14 +402,16 @@ caja_file_changes_consume_changes (gboolean consume_all)
{
additions = g_list_reverse (additions);
caja_directory_notify_files_added (additions);
- eel_g_object_list_free (additions);
+ g_list_foreach(additions, (GFunc) g_object_unref, NULL);
+ g_list_free(additions);
additions = NULL;
}
if (changes != NULL)
{
changes = g_list_reverse (changes);
caja_directory_notify_files_changed (changes);
- eel_g_object_list_free (changes);
+ g_list_foreach(changes, (GFunc) g_object_unref, NULL);
+ g_list_free(changes);
changes = NULL;
}
if (position_set_requests != NULL)
diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c
index c1769960..e3419c7c 100644
--- a/libcaja-private/caja-file-conflict-dialog.c
+++ b/libcaja-private/caja-file-conflict-dialog.c
@@ -657,7 +657,6 @@ caja_file_conflict_dialog_init (CajaFileConflictDialog *fcd)
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (dialog)), 14);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_dialog_set_has_separator (dialog, FALSE);
gtk_widget_show_all (dialog_area);
}
diff --git a/libcaja-private/caja-file-dnd.c b/libcaja-private/caja-file-dnd.c
index a44d42f3..2c239643 100644
--- a/libcaja-private/caja-file-dnd.c
+++ b/libcaja-private/caja-file-dnd.c
@@ -30,7 +30,6 @@
#include "caja-dnd.h"
#include "caja-directory.h"
#include "caja-file-utilities.h"
-#include <eel/eel-glib-extensions.h>
#include <string.h>
static gboolean
@@ -182,5 +181,6 @@ caja_drag_file_receive_dropped_keyword (CajaFile *file,
}
caja_file_set_keywords (file, keywords);
- eel_g_list_free_deep (keywords);
+ g_list_foreach(keywords, (GFunc) g_free, NULL);
+ g_list_free(keywords);
}
diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c
index f89e00cc..067f52d5 100644
--- a/libcaja-private/caja-file-operations.c
+++ b/libcaja-private/caja-file-operations.c
@@ -44,9 +44,7 @@
#include "caja-progress-info.h"
-#include <eel/eel-alert-dialog.h>
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-pango-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-vfs-extensions.h>
@@ -1066,12 +1064,16 @@ do_run_simple_dialog (gpointer _data)
int response_id;
/* Create the dialog. */
- dialog = eel_alert_dialog_new (*data->parent_window,
- 0,
- data->message_type,
- GTK_BUTTONS_NONE,
- data->primary_text,
- data->secondary_text);
+ dialog = gtk_message_dialog_new (*data->parent_window,
+ 0,
+ data->message_type,
+ GTK_BUTTONS_NONE,
+ NULL);
+
+ g_object_set (dialog,
+ "text", data->primary_text,
+ "secondary-text", data->secondary_text,
+ NULL);
for (response_id = 0;
data->button_titles[response_id] != NULL;
@@ -1086,8 +1088,8 @@ do_run_simple_dialog (gpointer _data)
}
if (data->details_text) {
- eel_alert_dialog_set_details_label (EEL_ALERT_DIALOG (dialog),
- data->details_text);
+ eel_gtk_message_dialog_set_details_label (GTK_MESSAGE_DIALOG (dialog),
+ data->details_text);
}
/* Run it. */
@@ -1099,7 +1101,7 @@ do_run_simple_dialog (gpointer _data)
result = gtk_dialog_run (GTK_DIALOG (dialog));
}
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (dialog);
data->result = result;
@@ -1856,7 +1858,8 @@ delete_job_done (gpointer user_data)
job = user_data;
- eel_g_object_list_free (job->files);
+ g_list_foreach(job->files, (GFunc) g_object_unref, NULL);
+ g_list_free(job->files);
if (job->done_callback) {
debuting_uris = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
@@ -2185,7 +2188,8 @@ has_trash_files (GMount *mount)
}
}
- eel_g_object_list_free (dirs);
+ g_list_foreach(dirs, (GFunc) g_object_unref, NULL);
+ g_list_free(dirs);
return res;
}
@@ -4458,7 +4462,8 @@ copy_job_done (gpointer user_data)
job->done_callback (job->debuting_files, job->done_callback_data);
}
- eel_g_object_list_free (job->files);
+ g_list_foreach(job->files, (GFunc) g_object_unref, NULL);
+ g_list_free(job->files);
if (job->destination) {
g_object_unref (job->destination);
}
@@ -4985,7 +4990,8 @@ move_job_done (gpointer user_data)
job->done_callback (job->debuting_files, job->done_callback_data);
}
- eel_g_object_list_free (job->files);
+ g_list_foreach(job->files, (GFunc) g_object_unref, NULL);
+ g_list_free(job->files);
g_object_unref (job->destination);
g_hash_table_unref (job->debuting_files);
g_free (job->icon_positions);
@@ -5065,7 +5071,8 @@ move_job (GIOSchedulerJob *io_job,
&source_info, &transfer_info);
aborted:
- eel_g_list_free_deep (fallbacks);
+ g_list_foreach(fallbacks, (GFunc) g_free, NULL);
+ g_list_free(fallbacks);
g_free (dest_fs_id);
g_free (dest_fs_type);
@@ -5319,7 +5326,8 @@ link_job_done (gpointer user_data)
job->done_callback (job->debuting_files, job->done_callback_data);
}
- eel_g_object_list_free (job->files);
+ g_list_foreach(job->files, (GFunc) g_object_unref, NULL);
+ g_list_free(job->files);
g_object_unref (job->destination);
g_hash_table_unref (job->debuting_files);
g_free (job->icon_positions);
@@ -5771,7 +5779,8 @@ caja_file_operations_copy_move (const GList *item_uris,
done_callback, done_callback_data);
}
- eel_g_object_list_free (locations);
+ g_list_foreach(locations, (GFunc) g_object_unref, NULL);
+ g_list_free(locations);
if (dest) {
g_object_unref (dest);
}
@@ -6249,7 +6258,8 @@ empty_trash_job_done (gpointer user_data)
job = user_data;
- eel_g_object_list_free (job->trash_dirs);
+ g_list_foreach(job->trash_dirs, (GFunc) g_object_unref, NULL);
+ g_list_free(job->trash_dirs);
if (job->done_callback) {
job->done_callback (job->done_callback_data);
diff --git a/libcaja-private/caja-file-utilities.c b/libcaja-private/caja-file-utilities.c
index 61ad5c47..bfe8321e 100644
--- a/libcaja-private/caja-file-utilities.c
+++ b/libcaja-private/caja-file-utilities.c
@@ -1428,7 +1428,8 @@ caja_restore_files_from_trash (GList *files,
parent_window,
NULL, NULL);
- eel_g_object_list_free (locations);
+ g_list_foreach(locations, (GFunc) g_object_unref, NULL);
+ g_list_free(locations);
g_object_unref (original_dir_location);
}
diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c
index 31863c9c..788eec68 100644
--- a/libcaja-private/caja-file.c
+++ b/libcaja-private/caja-file.c
@@ -816,11 +816,14 @@ finalize (GObject *object)
eel_ref_str_unref (file->details->filesystem_id);
- eel_g_list_free_deep (file->details->mime_list);
-
- eel_g_list_free_deep (file->details->pending_extension_emblems);
- eel_g_list_free_deep (file->details->extension_emblems);
- eel_g_object_list_free (file->details->pending_info_providers);
+ g_list_foreach(file->details->mime_list, (GFunc) g_free, NULL);
+ g_list_free(file->details->mime_list);
+ g_list_foreach(file->details->pending_extension_emblems, (GFunc) g_free, NULL);
+ g_list_free(file->details->pending_extension_emblems);
+ g_list_foreach(file->details->extension_emblems, (GFunc) g_free, NULL);
+ g_list_free(file->details->extension_emblems);
+ g_list_foreach(file->details->pending_info_providers, (GFunc) g_object_unref, NULL);
+ g_list_free(file->details->pending_info_providers);
if (file->details->pending_extension_attributes) {
g_hash_table_destroy (file->details->pending_extension_attributes);
@@ -2994,7 +2997,8 @@ fill_emblem_cache_if_needed (CajaFile *file)
/* Zero-terminate so we can tell where the list ends. */
*scanner = 0;
- eel_g_list_free_deep (keywords);
+ g_list_foreach(keywords, (GFunc) g_free, NULL);
+ g_list_free(keywords);
}
static int
@@ -6601,7 +6605,8 @@ caja_file_get_emblem_icons (CajaFile *file,
icons = g_list_prepend (icons, icon);
}
- eel_g_list_free_deep (keywords);
+ g_list_foreach(keywords, (GFunc) g_free, NULL);
+ g_list_free(keywords);
return icons;
}
@@ -6660,7 +6665,8 @@ sort_keyword_list_and_remove_duplicates (GList *keywords)
if (strcmp ((const char *) p->data, (const char *) p->next->data) == 0) {
duplicate_link = p->next;
keywords = g_list_remove_link (keywords, duplicate_link);
- eel_g_list_free_deep (duplicate_link);
+ g_list_foreach(duplicate_link, (GFunc) g_free, NULL);
+ g_list_free(duplicate_link);
} else {
p = p->next;
}
@@ -7554,7 +7560,8 @@ void
caja_file_invalidate_extension_info_internal (CajaFile *file)
{
if (file->details->pending_info_providers)
- eel_g_object_list_free (file->details->pending_info_providers);
+ g_list_foreach(file->details->pending_info_providers, (GFunc) g_object_unref, NULL);
+ g_list_free(file->details->pending_info_providers);
file->details->pending_info_providers =
caja_module_get_extensions_for_type (CAJA_TYPE_INFO_PROVIDER);
@@ -8376,7 +8383,8 @@ caja_file_invalidate_extension_info (CajaFile *file)
void
caja_file_info_providers_done (CajaFile *file)
{
- eel_g_list_free_deep (file->details->extension_emblems);
+ g_list_foreach(file->details->extension_emblems, (GFunc) g_free, NULL);
+ g_list_free(file->details->extension_emblems);
file->details->extension_emblems = file->details->pending_extension_emblems;
file->details->pending_extension_emblems = NULL;
diff --git a/libcaja-private/caja-horizontal-splitter.c b/libcaja-private/caja-horizontal-splitter.c
deleted file mode 100644
index 0fbaa3c4..00000000
--- a/libcaja-private/caja-horizontal-splitter.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* caja-horizontal-splitter.c - A horizontal splitter with a semi gradient look
-
- Copyright (C) 1999, 2000 Eazel, Inc.
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Ramiro Estrugo <[email protected]>
-*/
-
-#include <config.h>
-#include "caja-horizontal-splitter.h"
-
-#include <eel/eel-gtk-macros.h>
-#include <stdlib.h>
-
-struct CajaHorizontalSplitterDetails
-{
- guint32 press_time;
- int press_position;
- int saved_size;
-};
-
-#define CLOSED_THRESHOLD 4
-#define NOMINAL_SIZE 148
-#define SPLITTER_CLICK_SLOP 4
-#define SPLITTER_CLICK_TIMEOUT 400
-
-static void caja_horizontal_splitter_class_init (CajaHorizontalSplitterClass *horizontal_splitter_class);
-static void caja_horizontal_splitter_init (CajaHorizontalSplitter *horizontal_splitter);
-
-EEL_CLASS_BOILERPLATE (CajaHorizontalSplitter,
- caja_horizontal_splitter,
- GTK_TYPE_HPANED)
-
-static void
-caja_horizontal_splitter_init (CajaHorizontalSplitter *horizontal_splitter)
-{
- horizontal_splitter->details = g_new0 (CajaHorizontalSplitterDetails, 1);
-}
-
-static void
-caja_horizontal_splitter_finalize (GObject *object)
-{
- CajaHorizontalSplitter *horizontal_splitter;
-
- horizontal_splitter = CAJA_HORIZONTAL_SPLITTER (object);
-
- g_free (horizontal_splitter->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-splitter_expand (CajaHorizontalSplitter *splitter, int position)
-{
- g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter));
-
- if (position >= CLOSED_THRESHOLD)
- {
- return;
- }
-
- position = splitter->details->saved_size;
- if (position < CLOSED_THRESHOLD)
- {
- position = NOMINAL_SIZE;
- }
-
- gtk_paned_set_position (GTK_PANED (splitter), position);
-}
-
-static void
-splitter_collapse (CajaHorizontalSplitter *splitter, int position)
-{
- g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter));
-
- splitter->details->saved_size = position;
- gtk_paned_set_position (GTK_PANED (splitter), 0);
-}
-
-static void
-splitter_toggle (CajaHorizontalSplitter *splitter, int position)
-{
- g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter));
-
- if (gtk_paned_get_position (GTK_PANED (splitter)) >= CLOSED_THRESHOLD)
- {
- caja_horizontal_splitter_collapse (splitter);
- }
- else
- {
- caja_horizontal_splitter_expand (splitter);
- }
-}
-
-static void
-splitter_hide (CajaHorizontalSplitter *splitter)
-{
- GtkPaned *parent;
-
- parent = GTK_PANED (splitter);
-
- gtk_widget_hide (gtk_paned_get_child1 (parent));
-}
-
-static void
-splitter_show (CajaHorizontalSplitter *splitter)
-{
- GtkPaned *parent;
-
- parent = GTK_PANED (splitter);
-
- gtk_widget_show (gtk_paned_get_child1 (parent));
-}
-
-static gboolean
-splitter_is_hidden (CajaHorizontalSplitter *splitter)
-{
- GtkPaned *parent;
-
- parent = GTK_PANED (splitter);
-
- return gtk_widget_get_visible (gtk_paned_get_child1 (parent));
-}
-
-void
-caja_horizontal_splitter_expand (CajaHorizontalSplitter *splitter)
-{
- splitter_expand (splitter, gtk_paned_get_position (GTK_PANED (splitter)));
-}
-
-void
-caja_horizontal_splitter_hide (CajaHorizontalSplitter *splitter)
-{
- splitter_hide (splitter);
-}
-
-void
-caja_horizontal_splitter_show (CajaHorizontalSplitter *splitter)
-{
- splitter_show (splitter);
-}
-
-gboolean
-caja_horizontal_splitter_is_hidden (CajaHorizontalSplitter *splitter)
-{
- return splitter_is_hidden (splitter);
-}
-
-void
-caja_horizontal_splitter_collapse (CajaHorizontalSplitter *splitter)
-{
- splitter_collapse (splitter, gtk_paned_get_position (GTK_PANED (splitter)));
-}
-
-/* routine to toggle the open/closed state of the splitter */
-void
-caja_horizontal_splitter_toggle_position (CajaHorizontalSplitter *splitter)
-{
- splitter_toggle (splitter, gtk_paned_get_position (GTK_PANED (splitter)));
-}
-
-/* CajaHorizontalSplitter public methods */
-GtkWidget *
-caja_horizontal_splitter_new (void)
-{
- return gtk_widget_new (caja_horizontal_splitter_get_type (), NULL);
-}
-
-/* handle mouse downs by remembering the position and the time */
-static gboolean
-caja_horizontal_splitter_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- gboolean result;
- CajaHorizontalSplitter *splitter;
- int position;
-
- splitter = CAJA_HORIZONTAL_SPLITTER (widget);
-
- position = gtk_paned_get_position (GTK_PANED (widget));
-
- result = EEL_CALL_PARENT_WITH_RETURN_VALUE
- (GTK_WIDGET_CLASS, button_press_event, (widget, event));
-
- if (result)
- {
- splitter->details->press_time = event->time;
- splitter->details->press_position = position;
- }
-
- return result;
-}
-
-/* handle mouse ups by seeing if it was a tap and toggling the open state accordingly */
-static gboolean
-caja_horizontal_splitter_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- gboolean result;
- CajaHorizontalSplitter *splitter;
- int position, delta, delta_time;
- splitter = CAJA_HORIZONTAL_SPLITTER (widget);
-
- position = gtk_paned_get_position (GTK_PANED (widget));
-
- result = EEL_CALL_PARENT_WITH_RETURN_VALUE
- (GTK_WIDGET_CLASS, button_release_event, (widget, event));
-
- if (result)
- {
- delta = abs (position - splitter->details->press_position);
- delta_time = event->time - splitter->details->press_time;
- if (delta < SPLITTER_CLICK_SLOP && delta_time < SPLITTER_CLICK_TIMEOUT)
- {
- caja_horizontal_splitter_toggle_position (splitter);
- }
- }
-
- return result;
-}
-
-static void
-caja_horizontal_splitter_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- gint border_width;
- GtkPaned *paned;
- GtkAllocation child_allocation;
- GtkRequisition child_requisition;
-
- paned = GTK_PANED (widget);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (paned));
-
- gtk_widget_set_allocation (widget, allocation);
-
- if (gtk_paned_get_child2 (paned) != NULL && gtk_widget_get_visible (gtk_paned_get_child2 (paned)))
- {
- EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate,
- (widget, allocation));
- }
- else if (gtk_paned_get_child1 (paned) && gtk_widget_get_visible (gtk_paned_get_child1 (paned)))
- {
-
- if (gtk_widget_get_realized (widget))
- {
- gdk_window_hide (gtk_paned_get_handle_window (paned));
- }
-
- gtk_widget_get_child_requisition (gtk_paned_get_child1 (paned),
- &child_requisition);
-
- child_allocation.x = allocation->x + border_width;
- child_allocation.y = allocation->y + border_width;
- child_allocation.width = MIN (child_requisition.width,
- allocation->width - 2 * border_width);
- child_allocation.height = MIN (child_requisition.height,
- allocation->height - 2 * border_width);
-
- gtk_widget_size_allocate (gtk_paned_get_child1 (paned), &child_allocation);
- }
- else if (gtk_widget_get_realized (widget))
- {
- gdk_window_hide (gtk_paned_get_handle_window (paned));
- }
-
-}
-
-static void
-caja_horizontal_splitter_class_init (CajaHorizontalSplitterClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = GTK_WIDGET_CLASS (class);
-
- G_OBJECT_CLASS (class)->finalize = caja_horizontal_splitter_finalize;
-
- widget_class->size_allocate = caja_horizontal_splitter_size_allocate;
- widget_class->button_press_event = caja_horizontal_splitter_button_press;
- widget_class->button_release_event = caja_horizontal_splitter_button_release;
-}
-
-void
-caja_horizontal_splitter_pack2 (CajaHorizontalSplitter *splitter,
- GtkWidget *child2)
-{
- GtkPaned *paned;
-
- g_return_if_fail (GTK_IS_WIDGET (child2));
- g_return_if_fail (CAJA_IS_HORIZONTAL_SPLITTER (splitter));
-
- paned = GTK_PANED (splitter);
- gtk_paned_pack2 (paned, child2, TRUE, FALSE);
-}
diff --git a/libcaja-private/caja-horizontal-splitter.h b/libcaja-private/caja-horizontal-splitter.h
deleted file mode 100644
index b0fdcf4a..00000000
--- a/libcaja-private/caja-horizontal-splitter.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* caja-horizontal-splitter.h - A horizontal splitter with a semi gradient look
-
- Copyright (C) 1999, 2000 Eazel, Inc.
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Ramiro Estrugo <[email protected]>
-*/
-
-#ifndef CAJA_HORIZONTAL_SPLITTER_H
-#define CAJA_HORIZONTAL_SPLITTER_H
-
-#include <gtk/gtk.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define CAJA_TYPE_HORIZONTAL_SPLITTER caja_horizontal_splitter_get_type()
-#define CAJA_HORIZONTAL_SPLITTER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitter))
-#define CAJA_HORIZONTAL_SPLITTER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitterClass))
-#define CAJA_IS_HORIZONTAL_SPLITTER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER))
-#define CAJA_IS_HORIZONTAL_SPLITTER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), CAJA_TYPE_HORIZONTAL_SPLITTER))
-#define CAJA_HORIZONTAL_SPLITTER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitterClass))
-
- typedef struct CajaHorizontalSplitterDetails CajaHorizontalSplitterDetails;
-
- typedef struct
- {
- GtkHPaned parent_slot;
- CajaHorizontalSplitterDetails *details;
- } CajaHorizontalSplitter;
-
- typedef struct
- {
- GtkHPanedClass parent_slot;
- } CajaHorizontalSplitterClass;
-
- /* CajaHorizontalSplitter public methods */
- GType caja_horizontal_splitter_get_type (void);
- GtkWidget *caja_horizontal_splitter_new (void);
-
- gboolean caja_horizontal_splitter_is_hidden (CajaHorizontalSplitter *splitter);
- void caja_horizontal_splitter_collapse (CajaHorizontalSplitter *splitter);
- void caja_horizontal_splitter_hide (CajaHorizontalSplitter *splitter);
- void caja_horizontal_splitter_show (CajaHorizontalSplitter *splitter);
- void caja_horizontal_splitter_expand (CajaHorizontalSplitter *splitter);
- void caja_horizontal_splitter_toggle_position (CajaHorizontalSplitter *splitter);
- void caja_horizontal_splitter_pack2 (CajaHorizontalSplitter *splitter,
- GtkWidget *child2);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CAJA_HORIZONTAL_SPLITTER_H */
diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c
index db0b5280..f36f2ccf 100644
--- a/libcaja-private/caja-icon-canvas-item.c
+++ b/libcaja-private/caja-icon-canvas-item.c
@@ -35,10 +35,8 @@
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-mate-extensions.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-pango-extensions.h>
#include <eel/eel-string.h>
#include <eel/eel-accessibility.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -216,42 +214,57 @@ G_DEFINE_TYPE_WITH_CODE (CajaIconCanvasItem, caja_icon_canvas_item, EEL_TYPE_CAN
/* private */
static void draw_label_text (CajaIconCanvasItem *item,
- GdkDrawable *drawable,
- gboolean create_mask,
- EelIRect icon_rect);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
+ GdkDrawable *drawable,
+#endif
+ gboolean create_mask,
+ EelIRect icon_rect);
static void measure_label_text (CajaIconCanvasItem *item);
static void get_icon_canvas_rectangle (CajaIconCanvasItem *item,
- EelIRect *rect);
-static void emblem_layout_reset (EmblemLayout *layout,
- CajaIconCanvasItem *icon_item,
- EelIRect icon_rect,
- gboolean is_rtl);
-static gboolean emblem_layout_next (EmblemLayout *layout,
- GdkPixbuf **emblem_pixbuf,
- EelIRect *emblem_rect,
- gboolean is_rtl);
-static void draw_pixbuf (GdkPixbuf *pixbuf,
- GdkDrawable *drawable,
- int x,
- int y);
-static PangoLayout *get_label_layout (PangoLayout **layout,
- CajaIconCanvasItem *item,
- const char *text);
+ EelIRect *rect);
+static void emblem_layout_reset (EmblemLayout *layout,
+ CajaIconCanvasItem *icon_item,
+ EelIRect icon_rect,
+ gboolean is_rtl);
+static gboolean emblem_layout_next (EmblemLayout *layout,
+ GdkPixbuf **emblem_pixbuf,
+ EelIRect *emblem_rect,
+ gboolean is_rtl);
+static void draw_pixbuf (GdkPixbuf *pixbuf,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
+ GdkDrawable *drawable,
+#endif
+ int x,
+ int y);
+static PangoLayout *get_label_layout (PangoLayout **layout,
+ CajaIconCanvasItem *item,
+ const char *text);
static void draw_label_layout (CajaIconCanvasItem *item,
- GdkDrawable *drawable,
- PangoLayout *layout,
- gboolean highlight,
- GdkColor *label_color,
- int x,
- int y,
- GdkGC *gc);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
+ GdkDrawable *drawable,
+#endif
+ PangoLayout *layout,
+ gboolean highlight,
+ GdkColor *label_color,
+ int x,
+ int y);
static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item,
- EelIRect canvas_rect,
- GtkCornerType *corner);
+ EelIRect canvas_rect,
+ GtkCornerType *corner);
static void draw_embedded_text (CajaIconCanvasItem *icon_item,
- GdkDrawable *drawable,
- int x,
- int y);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
+ GdkDrawable *drawable,
+#endif
+ int x,
+ int y);
static void caja_icon_canvas_item_ensure_bounds_up_to_date (CajaIconCanvasItem *icon_item);
@@ -313,7 +326,8 @@ caja_icon_canvas_item_finalize (GObject *object)
g_object_unref (details->text_util);
}
- eel_gdk_pixbuf_list_free (details->emblem_pixbufs);
+ g_list_foreach(details->emblem_pixbufs, (GFunc) g_object_unref, NULL);
+ g_list_free(details->emblem_pixbufs);
g_free (details->editable_text);
g_free (details->additional_text);
g_free (details->attach_points);
@@ -405,7 +419,7 @@ caja_icon_canvas_item_set_property (GObject *object,
{
case PROP_EDITABLE_TEXT:
- if (eel_strcmp (details->editable_text,
+ if (g_strcmp0 (details->editable_text,
g_value_get_string (value)) == 0)
{
return;
@@ -432,7 +446,7 @@ caja_icon_canvas_item_set_property (GObject *object,
break;
case PROP_ADDITIONAL_TEXT:
- if (eel_strcmp (details->additional_text,
+ if (g_strcmp0 (details->additional_text,
g_value_get_string (value)) == 0)
{
return;
@@ -540,20 +554,28 @@ caja_icon_canvas_item_get_property (GObject *object,
}
}
+#if GTK_CHECK_VERSION(3,0,0)
+cairo_surface_t *
+caja_icon_canvas_item_get_drag_surface (CajaIconCanvasItem *item)
+#else
GdkPixmap *
caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
GdkBitmap **mask,
GdkColormap *colormap)
+#endif
{
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_surface_t *surface;
+#else
GdkPixmap *pixmap;
+ GdkPixbuf *pixbuf;
+#endif
EelCanvas *canvas;
GdkScreen *screen;
- GdkGC *gc;
int width, height;
int item_offset_x, item_offset_y;
EelIRect icon_rect;
EelIRect emblem_rect;
- GdkPixbuf *pixbuf;
GdkPixbuf *emblem_pixbuf;
EmblemLayout emblem_layout;
double item_x, item_y;
@@ -563,7 +585,11 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
g_return_val_if_fail (CAJA_IS_ICON_CANVAS_ITEM (item), NULL);
canvas = EEL_CANVAS_ITEM (item)->canvas;
+#if GTK_CHECK_VERSION(3,0,0)
+ screen = gtk_widget_get_screen (GTK_WIDGET (canvas));
+#else
screen = gdk_colormap_get_screen (colormap);
+#endif
/* Assume we're updated so canvas item data is right */
@@ -580,6 +606,19 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
width = EEL_CANVAS_ITEM (item)->x2 - EEL_CANVAS_ITEM (item)->x1;
height = EEL_CANVAS_ITEM (item)->y2 - EEL_CANVAS_ITEM (item)->y1;
+#if GTK_CHECK_VERSION(3,0,0)
+ surface = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ width, height);
+
+ cr = cairo_create (surface);
+ gdk_cairo_set_source_pixbuf (cr, item->details->pixbuf,
+ item_offset_x, item_offset_y);
+ cairo_rectangle (cr, item_offset_x, item_offset_y,
+ gdk_pixbuf_get_width (item->details->pixbuf),
+ gdk_pixbuf_get_height (item->details->pixbuf));
+ cairo_fill (cr);
+#else
pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
width, height,
gdk_visual_get_depth (gdk_colormap_get_visual (colormap)));
@@ -597,16 +636,33 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
gdk_pixbuf_get_height (item->details->pixbuf),
item_offset_x, item_offset_y, 1.0, 1.0,
GDK_INTERP_BILINEAR, 255);
+#endif
icon_rect.x0 = item_offset_x;
icon_rect.y0 = item_offset_y;
icon_rect.x1 = item_offset_x + gdk_pixbuf_get_width (item->details->pixbuf);
icon_rect.y1 = item_offset_y + gdk_pixbuf_get_height (item->details->pixbuf);
-
is_rtl = caja_icon_container_is_layout_rtl (CAJA_ICON_CONTAINER (canvas));
emblem_layout_reset (&emblem_layout, item, icon_rect, is_rtl);
+#if GTK_CHECK_VERSION(3,0,0)
+ while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl))
+ {
+ gdk_cairo_set_source_pixbuf (cr, emblem_pixbuf, emblem_rect.x0, emblem_rect.y0);
+ cairo_rectangle (cr, emblem_rect.x0, emblem_rect.y0,
+ gdk_pixbuf_get_width (emblem_pixbuf),
+ gdk_pixbuf_get_height (emblem_pixbuf));
+ cairo_fill (cr);
+ }
+
+ draw_embedded_text (item, cr,
+ item_offset_x, item_offset_y);
+ draw_label_text (item, cr, FALSE, icon_rect);
+ cairo_destroy (cr);
+
+ return surface;
+#else
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl))
{
gdk_pixbuf_composite (emblem_pixbuf, pixbuf,
@@ -618,34 +674,21 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
GDK_INTERP_BILINEAR, 255);
}
- /* clear the pixmap */
+ /* draw pixbuf to mask and pixmap */
cr = gdk_cairo_create (pixmap);
- cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
- gc = gdk_gc_new (pixmap);
- gdk_draw_pixbuf (pixmap, gc, pixbuf,
- 0, 0, 0, 0,
- gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- g_object_unref (gc);
-
*mask = gdk_pixmap_new (gdk_screen_get_root_window (screen),
width, height,
1);
- gc = gdk_gc_new (*mask);
- gdk_draw_rectangle (*mask, gc,
- TRUE,
- 0, 0,
- width, height);
- g_object_unref (gc);
-
- gdk_pixbuf_render_threshold_alpha (pixbuf, *mask,
- 0, 0, 0, 0,
- gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
- 128);
+ cr = gdk_cairo_create (*mask);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
draw_embedded_text (item, GDK_DRAWABLE (pixmap),
item_offset_x, item_offset_y);
@@ -656,6 +699,7 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
g_object_unref (pixbuf);
return pixmap;
+#endif
}
void
@@ -718,8 +762,9 @@ caja_icon_canvas_item_set_emblems (CajaIconCanvasItem *item,
}
/* Take in the new list of emblems. */
- eel_gdk_pixbuf_list_ref (emblem_pixbufs);
- eel_gdk_pixbuf_list_free (item->details->emblem_pixbufs);
+ eel_g_object_list_ref (emblem_pixbufs);
+ g_list_foreach(item->details->emblem_pixbufs, (GFunc) g_object_unref, NULL);
+ g_list_free(item->details->emblem_pixbufs);
item->details->emblem_pixbufs = g_list_copy (emblem_pixbufs);
caja_icon_canvas_item_invalidate_bounds_cache (item);
@@ -1032,7 +1077,11 @@ make_round_rect (cairo_t *cr,
static void
draw_frame (CajaIconCanvasItem *item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
GdkDrawable *drawable,
+#endif
guint color,
gboolean create_mask,
int x,
@@ -1041,12 +1090,14 @@ draw_frame (CajaIconCanvasItem *item,
int height)
{
CajaIconContainer *container;
- cairo_t *cr;
container = CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas);
- /* Get a cairo context */
- cr = gdk_cairo_create (drawable);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (drawable);
+#endif
/* Set the rounded rect clip region. Magic rounding value taken
* from old code.
@@ -1070,8 +1121,11 @@ draw_frame (CajaIconCanvasItem *item,
/* Paint into drawable now that we have set up the color and opacity */
cairo_fill (cr);
- /* Clean up now that drawing is complete */
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
cairo_destroy (cr);
+#endif
}
/* Keep these for a bit while we work on performance of draw_or_measure_label_text. */
@@ -1379,7 +1433,11 @@ measure_label_text (CajaIconCanvasItem *item)
static void
draw_label_text (CajaIconCanvasItem *item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
GdkDrawable *drawable,
+#endif
gboolean create_mask,
EelIRect icon_rect)
{
@@ -1389,7 +1447,6 @@ draw_label_text (CajaIconCanvasItem *item,
PangoLayout *editable_layout;
PangoLayout *additional_layout;
GdkColor *label_color;
- GdkGC *gc;
gboolean have_editable, have_additional;
gboolean needs_frame, needs_highlight, prelight_label, is_rtl_label_beside;
EelIRect text_rect;
@@ -1400,8 +1457,6 @@ draw_label_text (CajaIconCanvasItem *item,
return;
#endif
- gc = NULL;
-
canvas_item = EEL_CANVAS_ITEM (item);
details = item->details;
@@ -1433,7 +1488,11 @@ draw_label_text (CajaIconCanvasItem *item,
if (needs_highlight && !details->is_renaming)
{
draw_frame (item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+#else
drawable,
+#endif
gtk_widget_has_focus (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba,
create_mask,
is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0,
@@ -1446,11 +1505,23 @@ draw_label_text (CajaIconCanvasItem *item,
details->is_highlighted_as_keyboard_focus))
{
/* clear the underlying icons, where the text or overlaps them. */
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0);
+ cairo_rectangle (cr,
+ text_rect.x0,
+ text_rect.y0,
+ text_rect.x1 - text_rect.x0,
+ text_rect.y1 - text_rect.y0);
+ cairo_fill (cr);
+ cairo_restore (cr);
+#else
gdk_window_clear_area (gtk_layout_get_bin_window (&EEL_CANVAS (container)->layout),
text_rect.x0,
text_rect.y0,
text_rect.x1 - text_rect.x0,
text_rect.y1 - text_rect.y0);
+#endif
}
if (container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE)
@@ -1476,7 +1547,11 @@ draw_label_text (CajaIconCanvasItem *item,
if (!(prelight_label && item->details->is_prelit))
{
draw_frame (item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+#else
drawable,
+#endif
container->details->normal_color_rgba,
create_mask,
text_rect.x0,
@@ -1487,7 +1562,11 @@ draw_label_text (CajaIconCanvasItem *item,
else
{
draw_frame (item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+#else
drawable,
+#endif
container->details->prelight_color_rgba,
create_mask,
text_rect.x0,
@@ -1497,16 +1576,21 @@ draw_label_text (CajaIconCanvasItem *item,
}
}
- gc = caja_icon_container_get_label_color_and_gc
+ caja_icon_container_get_label_color
(CAJA_ICON_CONTAINER (canvas_item->canvas),
&label_color, TRUE, needs_highlight,
prelight_label & item->details->is_prelit);
- draw_label_layout (item, drawable,
+ draw_label_layout (item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+#else
+ drawable,
+#endif
editable_layout, needs_highlight,
label_color,
x,
- text_rect.y0 + TEXT_BACK_PADDING_Y, gc);
+ text_rect.y0 + TEXT_BACK_PADDING_Y);
}
if (have_additional)
@@ -1514,22 +1598,31 @@ draw_label_text (CajaIconCanvasItem *item,
additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text);
prepare_pango_layout_for_draw (item, additional_layout);
- gc = caja_icon_container_get_label_color_and_gc
+ caja_icon_container_get_label_color
(CAJA_ICON_CONTAINER (canvas_item->canvas),
&label_color, FALSE, needs_highlight,
FALSE);
- draw_label_layout (item, drawable,
+ draw_label_layout (item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+#else
+ drawable,
+#endif
additional_layout, needs_highlight,
label_color,
x,
- text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y, gc);
+ text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y);
}
if (!create_mask && item->details->is_highlighted_as_keyboard_focus)
{
gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)),
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+#else
drawable,
+#endif
needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
NULL,
GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas),
@@ -1611,15 +1704,18 @@ get_knob_pixbuf (void)
}
static void
+#if GTK_CHECK_VERSION(3,0,0)
+draw_stretch_handles (CajaIconCanvasItem *item,
+ cairo_t *cr,
+#else
draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable,
+#endif
const EelIRect *rect)
{
GtkWidget *widget;
- GdkGC *gc;
GdkPixbuf *knob_pixbuf;
- GdkBitmap *stipple;
int knob_width, knob_height;
- GtkStyle *style;
+ double dash = { 2.0 };
if (!item->details->show_stretch_handles)
{
@@ -1627,44 +1723,45 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable,
}
widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas);
- style = gtk_widget_get_style (widget);
- gc = gdk_gc_new (drawable);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (drawable);
+#endif
knob_pixbuf = get_knob_pixbuf ();
knob_width = gdk_pixbuf_get_width (knob_pixbuf);
knob_height = gdk_pixbuf_get_height (knob_pixbuf);
- stipple = eel_stipple_bitmap_for_screen (
- gdk_drawable_get_screen (GDK_DRAWABLE (drawable)));
-
/* first draw the box */
- gdk_gc_set_rgb_fg_color (gc, &style->white);
- gdk_draw_rectangle
- (drawable, gc, FALSE,
- rect->x0,
- rect->y0,
- rect->x1 - rect->x0 - 1,
- rect->y1 - rect->y0 - 1);
-
- gdk_gc_set_rgb_fg_color (gc, &style->black);
- gdk_gc_set_stipple (gc, stipple);
- gdk_gc_set_fill (gc, GDK_STIPPLED);
- gdk_draw_rectangle
- (drawable, gc, FALSE,
- rect->x0,
- rect->y0,
- rect->x1 - rect->x0 - 1,
- rect->y1 - rect->y0 - 1);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_set_dash (cr, &dash, 1, 0);
+ cairo_set_line_width (cr, 1.0);
+ cairo_rectangle (cr,
+ rect->x0 + 0.5,
+ rect->y0 + 0.5,
+ rect->x1 - rect->x0 - 1,
+ rect->y1 - rect->y0 - 1);
+ cairo_stroke (cr);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
/* draw the stretch handles themselves */
+ draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y0);
+ draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y1 - knob_height);
+ draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y0);
+ draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y1 - knob_height);
+#else
+ cairo_destroy (cr);
draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y0);
draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y1 - knob_height);
draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y0);
draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y1 - knob_height);
- g_object_unref (knob_pixbuf);
+#endif
- g_object_unref (gc);
+ g_object_unref (knob_pixbuf);
}
static void
@@ -1825,16 +1922,25 @@ emblem_layout_next (EmblemLayout *layout,
}
static void
+#if GTK_CHECK_VERSION(3,0,0)
+draw_pixbuf (GdkPixbuf *pixbuf,
+ cairo_t *cr,
+ int x, int y)
+{
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+}
+#else
draw_pixbuf (GdkPixbuf *pixbuf, GdkDrawable *drawable, int x, int y)
{
- /* FIXME bugzilla.gnome.org 40703:
- * Dither would be better if we passed dither values.
- */
- gdk_draw_pixbuf (drawable, NULL, pixbuf, 0, 0, x, y,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf),
- GDK_RGB_DITHER_NORMAL, 0, 0);
+ cairo_t *cr = gdk_cairo_create (drawable);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
+ cairo_paint (cr);
+ cairo_destroy (cr);
}
+#endif
/* shared code to highlight or dim the passed-in pixbuf */
static GdkPixbuf *
@@ -2000,11 +2106,13 @@ map_pixbuf (CajaIconCanvasItem *icon_item)
static void
draw_embedded_text (CajaIconCanvasItem *item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
GdkDrawable *drawable,
+#endif
int x, int y)
{
- GdkGC *gc;
- GdkRectangle clip_rect;
PangoLayout *layout;
PangoContext *context;
PangoFontDescription *desc;
@@ -2036,35 +2144,49 @@ draw_embedded_text (CajaIconCanvasItem *item,
}
}
- gc = gdk_gc_new (drawable);
-
- clip_rect.x = x + item->details->embedded_text_rect.x;
- clip_rect.y = y + item->details->embedded_text_rect.y;
- clip_rect.width = item->details->embedded_text_rect.width;
- clip_rect.height = item->details->embedded_text_rect.height;
-
- gdk_gc_set_clip_rectangle (gc, &clip_rect);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (drawable);
+#endif
- gdk_draw_layout (drawable, gc,
+ cairo_rectangle (cr,
x + item->details->embedded_text_rect.x,
y + item->details->embedded_text_rect.y,
- layout);
-
- g_object_unref (gc);
- g_object_unref (layout);
+ item->details->embedded_text_rect.width,
+ item->details->embedded_text_rect.height);
+ cairo_clip (cr);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_move_to (cr,
+ x + item->details->embedded_text_rect.x,
+ y + item->details->embedded_text_rect.y);
+ pango_cairo_show_layout (cr, layout);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
+ cairo_destroy (cr);
+#endif
}
/* Draw the icon item for non-anti-aliased mode. */
static void
+#if GTK_CHECK_VERSION(3,0,0)
+caja_icon_canvas_item_draw (EelCanvasItem *item,
+ cairo_t *cr,
+ cairo_region_t *region)
+#else
caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose)
+#endif
{
CajaIconCanvasItem *icon_item;
CajaIconCanvasItemDetails *details;
EelIRect icon_rect, emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf, *temp_pixbuf;
- GdkRectangle draw_rect, pixbuf_rect;
+ GdkRectangle pixbuf_rect;
gboolean is_rtl;
icon_item = CAJA_ICON_CANVAS_ITEM (item);
@@ -2085,23 +2207,29 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
pixbuf_rect.y = icon_rect.y0;
pixbuf_rect.width = gdk_pixbuf_get_width (temp_pixbuf);
pixbuf_rect.height = gdk_pixbuf_get_height (temp_pixbuf);
- if (gdk_rectangle_intersect (&(expose->area), &pixbuf_rect, &draw_rect))
- {
- gdk_draw_pixbuf (drawable,
- NULL,
- temp_pixbuf,
- draw_rect.x - pixbuf_rect.x,
- draw_rect.y - pixbuf_rect.y,
- draw_rect.x,
- draw_rect.y,
- draw_rect.width,
- draw_rect.height,
- GDK_RGB_DITHER_NORMAL,
- 0,0);
- }
+
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (drawable);
+ gdk_cairo_rectangle (cr, &expose->area);
+ cairo_clip (cr);
+#endif
+ gdk_cairo_set_source_pixbuf (cr, temp_pixbuf, pixbuf_rect.x, pixbuf_rect.y);
+ gdk_cairo_rectangle (cr, &pixbuf_rect);
+ cairo_fill (cr);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
+ cairo_destroy (cr);
+#endif
g_object_unref (temp_pixbuf);
+#if GTK_CHECK_VERSION(3,0,0)
+ draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0);
+#else
draw_embedded_text (icon_item, drawable, icon_rect.x0, icon_rect.y0);
+#endif
is_rtl = caja_icon_container_is_layout_rtl (CAJA_ICON_CONTAINER (item->canvas));
@@ -2109,14 +2237,23 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
emblem_layout_reset (&emblem_layout, icon_item, icon_rect, is_rtl);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl))
{
+#if GTK_CHECK_VERSION(3,0,0)
+ draw_pixbuf (emblem_pixbuf, cr, emblem_rect.x0, emblem_rect.y0);
+#else
draw_pixbuf (emblem_pixbuf, drawable, emblem_rect.x0, emblem_rect.y0);
+#endif
}
+#if GTK_CHECK_VERSION(3,0,0)
/* Draw stretching handles (if necessary). */
- draw_stretch_handles (icon_item, drawable, &icon_rect);
+ draw_stretch_handles (icon_item, cr, &icon_rect);
/* Draw the label text. */
+ draw_label_text (icon_item, cr, FALSE, icon_rect);
+#else
+ draw_stretch_handles (icon_item, drawable, &icon_rect);
draw_label_text (icon_item, drawable, FALSE, icon_rect);
+#endif
}
#define ZERO_WIDTH_SPACE "\xE2\x80\x8B"
@@ -2234,18 +2371,20 @@ get_label_layout (PangoLayout **layout_cache,
static void
draw_label_layout (CajaIconCanvasItem *item,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
GdkDrawable *drawable,
+#endif
PangoLayout *layout,
gboolean highlight,
GdkColor *label_color,
int x,
- int y,
- GdkGC *gc)
+ int y)
{
- if (drawable == NULL)
- {
- return;
- }
+#if !GTK_CHECK_VERSION(3,0,0)
+ g_return_if_fail (drawable != NULL);
+#endif
if (item->details->is_renaming)
{
@@ -2255,7 +2394,11 @@ draw_label_layout (CajaIconCanvasItem *item,
if (!highlight && (CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->use_drop_shadows))
{
/* draw a drop shadow */
- eel_gdk_draw_layout_with_drop_shadow (drawable, gc,
+#if GTK_CHECK_VERSION(3,0,0)
+ eel_cairo_draw_layout_with_drop_shadow (cr,
+#else
+ eel_gdk_draw_layout_with_drop_shadow (drawable,
+#endif
label_color,
&gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black,
x, y,
@@ -2263,9 +2406,20 @@ draw_label_layout (CajaIconCanvasItem *item,
}
else
{
- gdk_draw_layout (drawable, gc,
- x, y,
- layout);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+#else
+ cairo_t *cr = gdk_cairo_create (drawable);
+#endif
+
+ gdk_cairo_set_source_color (cr, label_color);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_layout (cr, layout);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+#else
+ cairo_destroy (cr);
+#endif
}
}
diff --git a/libcaja-private/caja-icon-canvas-item.h b/libcaja-private/caja-icon-canvas-item.h
index 27d01867..14b93b63 100644
--- a/libcaja-private/caja-icon-canvas-item.h
+++ b/libcaja-private/caja-icon-canvas-item.h
@@ -74,9 +74,13 @@ extern "C" {
/* attributes */
void caja_icon_canvas_item_set_image (CajaIconCanvasItem *item,
GdkPixbuf *image);
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_surface_t* caja_icon_canvas_item_get_drag_surface (CajaIconCanvasItem *item);
+#else
GdkPixmap * caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
- GdkBitmap **mask,
- GdkColormap *colormap);
+ GdkBitmap **mask,
+ GdkColormap *colormap);
+#endif
void caja_icon_canvas_item_set_emblems (CajaIconCanvasItem *item,
GList *emblem_pixbufs);
void caja_icon_canvas_item_set_show_stretch_handles (CajaIconCanvasItem *item,
diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c
index e3457f31..6b2f18e8 100644
--- a/libcaja-private/caja-icon-container.c
+++ b/libcaja-private/caja-icon-container.c
@@ -43,7 +43,6 @@
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-art-extensions.h>
#include <eel/eel-editable-label.h>
-#include <eel/eel-marshal.h>
#include <eel/eel-string.h>
#include <eel/eel-canvas-rect-ellipse.h>
#include <gdk/gdkkeysyms.h>
@@ -53,6 +52,12 @@
#include <stdio.h>
#include <string.h>
+#if !GTK_CHECK_VERSION(3, 0, 0)
+#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment
+#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment
+#define GTK_SCROLLABLE GTK_LAYOUT
+#endif
+
#define TAB_NAVIGATION_DISABLED
/* Interval for updating the rubberband selection, in milliseconds. */
@@ -301,7 +306,7 @@ static void
icon_free (CajaIcon *icon)
{
/* Destroy this canvas item; the parent will unref it. */
- gtk_object_destroy (GTK_OBJECT (icon->item));
+ eel_canvas_item_destroy (EEL_CANVAS_ITEM (icon->item));
g_free (icon);
}
@@ -592,8 +597,8 @@ caja_icon_container_scroll (CajaIconContainer *container,
GtkAdjustment *hadj, *vadj;
int old_h_value, old_v_value;
- hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container));
- vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container));
/* Store the old ajustment values so we can tell if we
* ended up actually scrolling. We may not have in a case
@@ -755,8 +760,8 @@ reveal_icon (CajaIconContainer *container,
details = container->details;
gtk_widget_get_allocation (GTK_WIDGET (container), &allocation);
- hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container));
- vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container));
if (caja_icon_container_is_auto_layout (container))
{
@@ -1088,8 +1093,8 @@ canvas_set_scroll_region_include_visible_area (EelCanvas *canvas,
width = (allocation.width) / canvas->pixels_per_unit;
height = (allocation.height) / canvas->pixels_per_unit;
- old_scroll_x = gtk_adjustment_get_value (GTK_ADJUSTMENT (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))));
- old_scroll_y = gtk_adjustment_get_value (GTK_ADJUSTMENT (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))));
+ old_scroll_x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)));
+ old_scroll_y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)));
x1 = MIN (x1, old_x1 + old_scroll_x);
y1 = MIN (y1, old_y1 + old_scroll_y);
@@ -1213,8 +1218,8 @@ caja_icon_container_update_scroll_region (CajaIconContainer *container)
x1, y1, x2, y2);
}
- hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container));
- vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container));
/* Scroll by 1/4 icon each time you click. */
step_increment = caja_get_icon_size_for_zoom_level
@@ -2776,14 +2781,14 @@ rubberband_timeout_callback (gpointer data)
adj_changed = FALSE;
gtk_widget_get_allocation (widget, &allocation);
- adj_x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
+ adj_x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
if (adj_x != band_info->last_adj_x)
{
band_info->last_adj_x = adj_x;
adj_changed = TRUE;
}
- adj_y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
+ adj_y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
if (adj_y != band_info->last_adj_y)
{
band_info->last_adj_y = adj_y;
@@ -2832,8 +2837,8 @@ rubberband_timeout_callback (gpointer data)
/* Remember to convert from widget to scrolled window coords */
eel_canvas_window_to_world (EEL_CANVAS (container),
- x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))),
- y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))),
+ x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))),
+ y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))),
&world_x, &world_y);
if (world_x < band_info->start_x)
@@ -2954,8 +2959,8 @@ start_rubberbanding (CajaIconContainer *container,
atk_object_set_name (accessible, "selection");
atk_object_set_description (accessible, _("The selection rectangle"));
- band_info->prev_x = event->x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
- band_info->prev_y = event->y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
+ band_info->prev_x = event->x - gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
+ band_info->prev_y = event->y - gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
band_info->active = TRUE;
@@ -2991,7 +2996,7 @@ stop_rubberbanding (CajaIconContainer *container,
/* Destroy this canvas item; the parent will unref it. */
eel_canvas_item_ungrab (band_info->selection_rectangle, time);
- gtk_object_destroy (GTK_OBJECT (band_info->selection_rectangle));
+ eel_canvas_item_destroy (band_info->selection_rectangle);
band_info->selection_rectangle = NULL;
/* if only one item has been selected, use it as range
@@ -4380,10 +4385,12 @@ select_previous_or_next_icon (CajaIconContainer *container,
}
#endif
-/* GtkObject methods. */
-
static void
+#if GTK_CHECK_VERSION(3, 0, 0)
+destroy (GtkWidget *object)
+#else
destroy (GtkObject *object)
+#endif
{
CajaIconContainer *container;
@@ -4440,8 +4447,11 @@ destroy (GtkObject *object)
}
}
-
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GTK_WIDGET_CLASS (caja_icon_container_parent_class)->destroy (object);
+#else
GTK_OBJECT_CLASS (caja_icon_container_parent_class)->destroy (object);
+#endif
}
static void
@@ -4483,15 +4493,6 @@ finalize (GObject *object)
/* GtkWidget methods. */
-static void
-size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GTK_WIDGET_CLASS (caja_icon_container_parent_class)->size_request (widget, requisition);
- requisition->width = 1;
- requisition->height = 1;
-}
-
static gboolean
clear_size_allocation_count (gpointer data)
{
@@ -4565,7 +4566,6 @@ size_allocate (GtkWidget *widget,
static void
realize (GtkWidget *widget)
{
- GdkBitmap *stipple;
GtkAdjustment *vadj, *hadj;
CajaIconContainer *container;
@@ -4581,20 +4581,15 @@ realize (GtkWidget *widget)
}
/* Set up DnD. */
- caja_icon_dnd_init (container, NULL);
+ caja_icon_dnd_init (container);
setup_label_gcs (container);
- stipple = eel_stipple_bitmap_for_screen
- (gdk_drawable_get_screen (GDK_DRAWABLE (gtk_widget_get_window (widget))));
-
- caja_icon_dnd_set_stipple (container, stipple);
-
- hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (widget));
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget));
g_signal_connect (hadj, "value_changed",
G_CALLBACK (handle_hadjustment_changed), widget);
- vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (widget));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget));
g_signal_connect (vadj, "value_changed",
G_CALLBACK (handle_vadjustment_changed), widget);
@@ -4603,20 +4598,10 @@ realize (GtkWidget *widget)
static void
unrealize (GtkWidget *widget)
{
- int i;
CajaIconContainer *container;
container = CAJA_ICON_CONTAINER (widget);
- for (i = 0; i < LAST_LABEL_COLOR; i++)
- {
- if (container->details->label_gcs [i])
- {
- g_object_unref (container->details->label_gcs [i]);
- container->details->label_gcs [i] = NULL;
- }
- }
-
caja_icon_dnd_fini (container);
if (container->details->typeselect_flush_timeout)
@@ -4946,7 +4931,7 @@ start_stretching (CajaIconContainer *container)
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
if (toplevel != NULL && gtk_widget_get_realized (toplevel))
{
- eel_gdk_window_focus (gtk_widget_get_window (toplevel), GDK_CURRENT_TIME);
+ gdk_window_focus (gtk_widget_get_window (toplevel), GDK_CURRENT_TIME);
}
return TRUE;
@@ -5022,17 +5007,17 @@ keyboard_stretching (CajaIconContainer *container,
switch (event->keyval)
{
- case GDK_equal:
- case GDK_plus:
- case GDK_KP_Add:
+ case GDK_KEY_equal:
+ case GDK_KEY_plus:
+ case GDK_KEY_KP_Add:
icon_set_size (container, icon, size + 5, FALSE, FALSE);
break;
- case GDK_minus:
- case GDK_KP_Subtract:
+ case GDK_KEY_minus:
+ case GDK_KEY_KP_Subtract:
icon_set_size (container, icon, size - 5, FALSE, FALSE);
break;
- case GDK_0:
- case GDK_KP_0:
+ case GDK_KEY_0:
+ case GDK_KEY_KP_0:
caja_icon_container_move_icon (container, icon,
icon->x, icon->y,
1.0,
@@ -5258,7 +5243,7 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
cont_window = gtk_widget_get_window (GTK_WIDGET (container));
- screen = gdk_drawable_get_screen (cont_window);
+ screen = gdk_window_get_screen (cont_window);
monitor_num = gdk_screen_get_monitor_at_window (screen, cont_window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
@@ -5268,13 +5253,15 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
gdk_window_get_origin (cont_window, &cont_x, &cont_y);
#if GTK_CHECK_VERSION(3, 0, 0)
- cont_width = gdk_window_get_width(GDK_WINDOW(cont_window));
- cont_height = gdk_window_get_height(GDK_WINDOW(cont_window));
+ cont_width = gdk_window_get_width (cont_window);
+ cont_height = gdk_window_get_height (cont_window);
+
+ gtk_widget_get_preferred_size (search_dialog, &requisition, NULL);
#else
- gdk_drawable_get_size(cont_window, &cont_width, &cont_height);
-#endif
+ gdk_drawable_get_size (cont_window, &cont_width, &cont_height);
gtk_widget_size_request (search_dialog, &requisition);
+#endif
if (cont_x + cont_width - requisition.width > gdk_screen_get_width (screen))
{
@@ -5649,14 +5636,14 @@ caja_icon_container_search_key_press_event (GtkWidget *widget,
g_assert (CAJA_IS_ICON_CONTAINER (container));
/* close window and cancel the search */
- if (event->keyval == GDK_Escape || event->keyval == GDK_Tab)
+ if (event->keyval == GDK_KEY_Escape || event->keyval == GDK_KEY_Tab)
{
caja_icon_container_search_dialog_hide (widget, container);
return TRUE;
}
/* close window and activate alternate */
- if (event->keyval == GDK_Return && event->state & GDK_SHIFT_MASK)
+ if (event->keyval == GDK_KEY_Return && event->state & GDK_SHIFT_MASK)
{
caja_icon_container_search_dialog_hide (widget,
container);
@@ -5666,28 +5653,28 @@ caja_icon_container_search_key_press_event (GtkWidget *widget,
}
/* select previous matching iter */
- if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up)
+ if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up)
{
caja_icon_container_search_move (widget, container, TRUE);
retval = TRUE;
}
if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
- && (event->keyval == GDK_g || event->keyval == GDK_G))
+ && (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
{
caja_icon_container_search_move (widget, container, TRUE);
retval = TRUE;
}
/* select next matching iter */
- if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down)
+ if (event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
{
caja_icon_container_search_move (widget, container, FALSE);
retval = TRUE;
}
if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
- && (event->keyval == GDK_g || event->keyval == GDK_G))
+ && (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
{
caja_icon_container_search_move (widget, container, FALSE);
retval = TRUE;
@@ -5896,12 +5883,12 @@ key_press_event (GtkWidget *widget,
{
switch (event->keyval)
{
- case GDK_Return:
- case GDK_KP_Enter:
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter:
end_renaming_mode (container, TRUE);
handled = TRUE;
break;
- case GDK_Escape:
+ case GDK_KEY_Escape:
end_renaming_mode (container, FALSE);
handled = TRUE;
break;
@@ -5913,18 +5900,18 @@ key_press_event (GtkWidget *widget,
{
switch (event->keyval)
{
- case GDK_Home:
- case GDK_KP_Home:
+ case GDK_KEY_Home:
+ case GDK_KEY_KP_Home:
keyboard_home (container, event);
handled = TRUE;
break;
- case GDK_End:
- case GDK_KP_End:
+ case GDK_KEY_End:
+ case GDK_KEY_KP_End:
keyboard_end (container, event);
handled = TRUE;
break;
- case GDK_Left:
- case GDK_KP_Left:
+ case GDK_KEY_Left:
+ case GDK_KEY_KP_Left:
/* Don't eat Alt-Left, as that is used for history browsing */
if ((event->state & GDK_MOD1_MASK) == 0)
{
@@ -5932,8 +5919,8 @@ key_press_event (GtkWidget *widget,
handled = TRUE;
}
break;
- case GDK_Up:
- case GDK_KP_Up:
+ case GDK_KEY_Up:
+ case GDK_KEY_KP_Up:
/* Don't eat Alt-Up, as that is used for alt-shift-Up */
if ((event->state & GDK_MOD1_MASK) == 0)
{
@@ -5941,8 +5928,8 @@ key_press_event (GtkWidget *widget,
handled = TRUE;
}
break;
- case GDK_Right:
- case GDK_KP_Right:
+ case GDK_KEY_Right:
+ case GDK_KEY_KP_Right:
/* Don't eat Alt-Right, as that is used for history browsing */
if ((event->state & GDK_MOD1_MASK) == 0)
{
@@ -5950,8 +5937,8 @@ key_press_event (GtkWidget *widget,
handled = TRUE;
}
break;
- case GDK_Down:
- case GDK_KP_Down:
+ case GDK_KEY_Down:
+ case GDK_KEY_KP_Down:
/* Don't eat Alt-Down, as that is used for Open */
if ((event->state & GDK_MOD1_MASK) == 0)
{
@@ -5959,20 +5946,20 @@ key_press_event (GtkWidget *widget,
handled = TRUE;
}
break;
- case GDK_space:
+ case GDK_KEY_space:
keyboard_space (container, event);
handled = TRUE;
break;
#ifndef TAB_NAVIGATION_DISABLED
- case GDK_Tab:
- case GDK_ISO_Left_Tab:
+ case GDK_KEY_Tab:
+ case GDK_KEY_ISO_Left_Tab:
select_previous_or_next_icon (container,
(event->state & GDK_SHIFT_MASK) == 0, event);
handled = TRUE;
break;
#endif
- case GDK_Return:
- case GDK_KP_Enter:
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter:
if ((event->state & GDK_SHIFT_MASK) != 0)
{
activate_selected_items_alternate (container, NULL);
@@ -5984,22 +5971,22 @@ key_press_event (GtkWidget *widget,
handled = TRUE;
break;
- case GDK_Escape:
+ case GDK_KEY_Escape:
handled = undo_stretching (container);
break;
- case GDK_plus:
- case GDK_minus:
- case GDK_equal:
- case GDK_KP_Add:
- case GDK_KP_Subtract:
- case GDK_0:
- case GDK_KP_0:
+ case GDK_KEY_plus:
+ case GDK_KEY_minus:
+ case GDK_KEY_equal:
+ case GDK_KEY_KP_Add:
+ case GDK_KEY_KP_Subtract:
+ case GDK_KEY_0:
+ case GDK_KEY_KP_0:
if (event->state & GDK_CONTROL_MASK)
{
handled = keyboard_stretching (container, event);
}
break;
- case GDK_F10:
+ case GDK_KEY_F10:
/* handle Ctrl+F10 because we want to display the
* background popup even if something is selected.
* The other cases are handled by popup_menu().
@@ -6010,7 +5997,7 @@ key_press_event (GtkWidget *widget,
"context_click_background");
}
break;
- case GDK_v:
+ case GDK_KEY_v:
/* Eat Control + v to not enable type ahead */
if ((event->state & GDK_CONTROL_MASK) != 0)
{
@@ -6031,9 +6018,9 @@ key_press_event (GtkWidget *widget,
* start the typeahead find capabilities.
* Copied from CajaIconContainer */
if (!handled &&
- event->keyval != GDK_slash /* don't steal slash key event, used for "go to" */ &&
- event->keyval != GDK_BackSpace &&
- event->keyval != GDK_Delete)
+ event->keyval != GDK_KEY_slash /* don't steal slash key event, used for "go to" */ &&
+ event->keyval != GDK_KEY_BackSpace &&
+ event->keyval != GDK_KEY_Delete)
{
GdkEvent *new_event;
GdkWindow *window;
@@ -6122,12 +6109,17 @@ popup_menu (GtkWidget *widget)
static void
draw_canvas_background (EelCanvas *canvas,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr)
+#else
int x, int y, int width, int height)
+#endif
{
/* Don't chain up to the parent to avoid clearing and redrawing */
}
+#if !GTK_CHECK_VERSION(3,0,0)
static gboolean
expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -6139,6 +6131,7 @@ expose_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (caja_icon_container_parent_class)->expose_event (widget, event);
}
+#endif
static AtkObject *
get_accessible (GtkWidget *widget)
@@ -6230,7 +6223,12 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_OBJECT_CLASS (class)->constructor = caja_icon_container_constructor;
G_OBJECT_CLASS (class)->finalize = finalize;
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GTK_WIDGET_CLASS (class)->destroy = destroy;
+#else
GTK_OBJECT_CLASS (class)->destroy = destroy;
+#endif
/* Signals. */
@@ -6362,7 +6360,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_STRUCT_OFFSET (CajaIconContainerClass,
get_icon_uri),
NULL, NULL,
- eel_marshal_STRING__POINTER,
+ caja_marshal_STRING__POINTER,
G_TYPE_STRING, 1,
G_TYPE_POINTER);
signals[GET_ICON_DROP_TARGET_URI]
@@ -6372,7 +6370,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_STRUCT_OFFSET (CajaIconContainerClass,
get_icon_drop_target_uri),
NULL, NULL,
- eel_marshal_STRING__POINTER,
+ caja_marshal_STRING__POINTER,
G_TYPE_STRING, 1,
G_TYPE_POINTER);
signals[MOVE_COPY_ITEMS]
@@ -6455,7 +6453,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_STRUCT_OFFSET (CajaIconContainerClass,
get_container_uri),
NULL, NULL,
- eel_marshal_STRING__VOID,
+ caja_marshal_STRING__VOID,
G_TYPE_STRING, 0);
signals[CAN_ACCEPT_ITEM]
= g_signal_new ("can_accept_item",
@@ -6464,7 +6462,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_STRUCT_OFFSET (CajaIconContainerClass,
can_accept_item),
NULL, NULL,
- eel_marshal_INT__POINTER_STRING,
+ caja_marshal_INT__POINTER_STRING,
G_TYPE_INT, 2,
G_TYPE_POINTER,
G_TYPE_STRING);
@@ -6475,7 +6473,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_STRUCT_OFFSET (CajaIconContainerClass,
get_stored_icon_position),
NULL, NULL,
- eel_marshal_BOOLEAN__POINTER_POINTER,
+ caja_marshal_BOOLEAN__POINTER_POINTER,
G_TYPE_BOOLEAN, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
@@ -6486,7 +6484,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_STRUCT_OFFSET (CajaIconContainerClass,
get_stored_layout_timestamp),
NULL, NULL,
- eel_marshal_BOOLEAN__POINTER_POINTER,
+ caja_marshal_BOOLEAN__POINTER_POINTER,
G_TYPE_BOOLEAN, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
@@ -6497,7 +6495,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
G_STRUCT_OFFSET (CajaIconContainerClass,
store_layout_timestamp),
NULL, NULL,
- eel_marshal_BOOLEAN__POINTER_POINTER,
+ caja_marshal_BOOLEAN__POINTER_POINTER,
G_TYPE_BOOLEAN, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
@@ -6581,7 +6579,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
/* GtkWidget class. */
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->size_request = size_request;
widget_class->size_allocate = size_allocate;
widget_class->realize = realize;
widget_class->unrealize = unrealize;
@@ -6592,7 +6589,9 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
widget_class->popup_menu = popup_menu;
widget_class->get_accessible = get_accessible;
widget_class->style_set = style_set;
+#if !GTK_CHECK_VERSION(3,0,0)
widget_class->expose_event = expose_event;
+#endif
widget_class->grab_notify = grab_notify_cb;
canvas_class = EEL_CANVAS_CLASS (class);
@@ -6733,8 +6732,8 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set, GDK_f, GDK_CONTROL_MASK, "start_interactive_search", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_F, GDK_CONTROL_MASK, "start_interactive_search", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "start_interactive_search", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_F, GDK_CONTROL_MASK, "start_interactive_search", 0);
}
static void
@@ -7189,9 +7188,9 @@ caja_icon_container_get_first_visible_icon (CajaIconContainer *container)
gboolean better_icon;
gboolean compare_lt;
- hadj_v = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
- vadj_v = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
- h_page_size = gtk_adjustment_get_page_size (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
+ hadj_v = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
+ vadj_v = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
+ h_page_size = gtk_adjustment_get_page_size (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
if (caja_icon_container_is_layout_rtl (container))
{
@@ -7280,8 +7279,8 @@ caja_icon_container_scroll_to_icon (CajaIconContainer *container,
EelIRect bounds;
GtkAllocation allocation;
- hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container));
- vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container));
gtk_widget_get_allocation (GTK_WIDGET (container), &allocation);
/* We need to force a relayout now if there are updates queued
@@ -7613,8 +7612,8 @@ caja_icon_container_update_visible_icons (CajaIconContainer *container)
gboolean visible;
GtkAllocation allocation;
- hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container));
- vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container));
gtk_widget_get_allocation (GTK_WIDGET (container), &allocation);
min_x = gtk_adjustment_get_value (hadj);
@@ -7776,7 +7775,7 @@ caja_icon_container_update_icon (CajaIconContainer *container,
* happened to be typing at that moment.
*/
if (icon == get_icon_being_renamed (container) &&
- eel_strcmp (editable_text,
+ g_strcmp0 (editable_text,
caja_icon_canvas_item_get_editable_text (icon->item)) != 0)
{
end_renaming_mode (container, FALSE);
@@ -7796,7 +7795,8 @@ caja_icon_container_update_icon (CajaIconContainer *container,
/* Let the pixbufs go. */
g_object_unref (pixbuf);
- eel_gdk_pixbuf_list_free (emblem_pixbufs);
+ g_list_foreach(emblem_pixbufs, (GFunc) g_object_unref, NULL);
+ g_list_free(emblem_pixbufs);
g_free (editable_text);
g_free (additional_text);
@@ -9331,8 +9331,8 @@ caja_icon_container_set_single_click_mode (CajaIconContainer *container,
/* update the label color when the background changes */
-GdkGC *
-caja_icon_container_get_label_color_and_gc (CajaIconContainer *container,
+void
+caja_icon_container_get_label_color (CajaIconContainer *container,
GdkColor **color,
gboolean is_name,
gboolean is_highlight,
@@ -9388,28 +9388,12 @@ caja_icon_container_get_label_color_and_gc (CajaIconContainer *container,
{
*color = &container->details->label_colors [idx];
}
-
- return container->details->label_gcs [idx];
}
static void
setup_gc_with_fg (CajaIconContainer *container, int idx, guint32 color)
{
- GdkGC *gc;
- GdkColor gcolor;
-
- gcolor = eel_gdk_rgb_to_color (color);
- container->details->label_colors [idx] = gcolor;
-
- gc = gdk_gc_new (gtk_layout_get_bin_window (GTK_LAYOUT (container)));
- gdk_gc_set_rgb_fg_color (gc, &gcolor);
-
- if (container->details->label_gcs [idx])
- {
- g_object_unref (container->details->label_gcs [idx]);
- }
-
- container->details->label_gcs [idx] = gc;
+ container->details->label_colors [idx] = eel_gdk_rgb_to_color (color);
}
static void
@@ -9695,7 +9679,7 @@ caja_icon_container_set_font (CajaIconContainer *container,
{
g_return_if_fail (CAJA_IS_ICON_CONTAINER (container));
- if (eel_strcmp (container->details->font, font) == 0)
+ if (g_strcmp0 (container->details->font, font) == 0)
{
return;
}
diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c
index 12cc5cbf..cae6e4ee 100644
--- a/libcaja-private/caja-icon-dnd.c
+++ b/libcaja-private/caja-icon-dnd.c
@@ -60,6 +60,12 @@
#include <stdio.h>
#include <string.h>
+#if !GTK_CHECK_VERSION(3, 0, 0)
+#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment
+#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment
+#define GTK_SCROLLABLE GTK_LAYOUT
+#endif
+
static const GtkTargetEntry drag_types [] =
{
{ CAJA_ICON_DND_MATE_ICON_LIST_TYPE, 0, CAJA_ICON_DND_MATE_ICON_LIST },
@@ -98,7 +104,6 @@ create_selection_shadow (CajaIconContainer *container,
{
EelCanvasGroup *group;
EelCanvas *canvas;
- GdkBitmap *stipple;
int max_x, max_y;
int min_x, min_y;
GList *p;
@@ -115,9 +120,6 @@ create_selection_shadow (CajaIconContainer *container,
return NULL;
}
- stipple = container->details->dnd_info->stipple;
- g_return_val_if_fail (stipple != NULL, NULL);
-
canvas = EEL_CANVAS (container);
gtk_widget_get_allocation (GTK_WIDGET (container), &allocation);
@@ -164,7 +166,7 @@ create_selection_shadow (CajaIconContainer *container,
"x2", (double) x2,
"y2", (double) y2,
"outline_color", "black",
- "outline_stipple", stipple,
+ "outline-stippling", TRUE,
"width_pixels", 1,
NULL);
}
@@ -201,6 +203,10 @@ canvas_rect_world_to_widget (EelCanvas *canvas,
EelIRect *widget_rect)
{
EelDRect window_rect;
+ GtkAdjustment *hadj, *vadj;
+
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
eel_canvas_world_to_window (canvas,
world_rect->x0, world_rect->y0,
@@ -208,10 +214,10 @@ canvas_rect_world_to_widget (EelCanvas *canvas,
eel_canvas_world_to_window (canvas,
world_rect->x1, world_rect->y1,
&window_rect.x1, &window_rect.y1);
- widget_rect->x0 = (int) window_rect.x0 - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)));
- widget_rect->y0 = (int) window_rect.y0 - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)));
- widget_rect->x1 = (int) window_rect.x1 - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)));
- widget_rect->y1 = (int) window_rect.y1 - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)));
+ widget_rect->x0 = (int) window_rect.x0 - gtk_adjustment_get_value (hadj);
+ widget_rect->y0 = (int) window_rect.y0 - gtk_adjustment_get_value (vadj);
+ widget_rect->x1 = (int) window_rect.x1 - gtk_adjustment_get_value (hadj);
+ widget_rect->y1 = (int) window_rect.y1 - gtk_adjustment_get_value (vadj);
}
static void
@@ -220,8 +226,8 @@ canvas_widget_to_world (EelCanvas *canvas,
double *world_x, double *world_y)
{
eel_canvas_window_to_world (canvas,
- widget_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))),
- widget_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))),
+ widget_x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas))),
+ widget_y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas))),
world_x, world_y);
}
@@ -379,7 +385,7 @@ caja_icon_container_dropped_icon_feedback (GtkWidget *widget,
{
/* FIXME bugzilla.gnome.org 42484:
* Is a destroy really sufficient here? Who does the unref? */
- gtk_object_destroy (GTK_OBJECT (dnd_info->shadow));
+ eel_canvas_item_destroy (dnd_info->shadow);
}
/* Build the selection list and the shadow. */
@@ -944,63 +950,6 @@ stop_auto_scroll (CajaIconContainer *container)
caja_drag_autoscroll_stop (&container->details->dnd_info->drag_info);
}
-static gboolean
-confirm_switch_to_manual_layout (CajaIconContainer *container)
-{
-#if 0
- const char *message;
- const char *detail;
- GtkDialog *dialog;
- int response;
-
- /* FIXME bugzilla.gnome.org 40915: Use of the word "directory"
- * makes this FMIconView specific. Move these messages into
- * FMIconView so CajaIconContainer can be used for things
- * that are not directories?
- */
- if (caja_icon_container_has_stored_icon_positions (container))
- {
- if (eel_g_list_exactly_one_item (container->details->dnd_info->drag_info.selection_list))
- {
- message = no_translate("Do you want to switch to manual layout and leave this item where you dropped it? "
- "This will clobber the stored manual layout.");
- detail = no_translate("This folder uses automatic layout.");
- }
- else
- {
- message = no_translate("Do you want to switch to manual layout and leave these items where you dropped them? "
- "This will clobber the stored manual layout.");
- detail = no_translate("This folder uses automatic layout.");
- }
- }
- else
- {
- if (eel_g_list_exactly_one_item (container->details->dnd_info->drag_info.selection_list))
- {
- message = no_translate("Do you want to switch to manual layout and leave this item where you dropped it?");
- detail = no_translate("This folder uses automatic layout.");
- }
- else
- {
- message = no_translate("Do you want to switch to manual layout and leave these items where you dropped them?");
- detail = no_translate("This folder uses automatic layout.");
-
- }
- }
-
- dialog = eel_show_yes_no_dialog (message, detail, _("Switch to Manual Layout?"),
- GTK_STOCK_CANCEL,
- GTK_WINDOW (gtk_widget_get_toplevel(GTK_WIDGET(container))));
-
- response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
-
- return response == GTK_RESPONSE_YES;
-#else
- return FALSE;
-#endif
-}
-
static void
handle_local_move (CajaIconContainer *container,
double world_x, double world_y)
@@ -1015,11 +964,7 @@ handle_local_move (CajaIconContainer *container,
if (container->details->auto_layout)
{
- if (!confirm_switch_to_manual_layout (container))
- {
- return;
- }
- caja_icon_container_freeze_icon_positions (container);
+ return;
}
time (&now);
@@ -1332,8 +1277,8 @@ caja_icon_container_receive_dropped_icons (CajaIconContainer *container,
if (real_action > 0)
{
eel_canvas_window_to_world (EEL_CANVAS (container),
- x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))),
- y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))),
+ x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))),
+ y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))),
&world_x, &world_y);
drop_target = caja_icon_container_find_drop_target (container,
@@ -1518,7 +1463,7 @@ caja_icon_container_free_drag_data (CajaIconContainer *container)
if (dnd_info->shadow != NULL)
{
- gtk_object_destroy (GTK_OBJECT (dnd_info->shadow));
+ eel_canvas_item_destroy (dnd_info->shadow);
dnd_info->shadow = NULL;
}
@@ -1560,18 +1505,23 @@ drag_begin_callback (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_surface_t *surface;
+#else
CajaIconContainer *container;
GdkScreen *screen;
GdkColormap *colormap;
GdkPixmap *pixmap;
GdkBitmap *mask;
+ gboolean use_mask;
+#endif
double x1, y1, x2, y2, winx, winy;
int x_offset, y_offset;
int start_x, start_y;
- gboolean use_mask;
container = CAJA_ICON_CONTAINER (widget);
+#if !GTK_CHECK_VERSION(3,0,0)
screen = gtk_widget_get_screen (widget);
colormap = NULL;
if (gdk_screen_is_composited (screen))
@@ -1589,16 +1539,19 @@ drag_begin_callback (GtkWidget *widget,
colormap = gtk_widget_get_colormap (widget);
use_mask = TRUE;
}
+#endif
- start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
- start_y = container->details->dnd_info->drag_info.start_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
+ start_x = container->details->dnd_info->drag_info.start_x +
+ gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
+ start_y = container->details->dnd_info->drag_info.start_y +
+ gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
/* create a pixmap and mask to drag with */
+#if GTK_CHECK_VERSION(3,0,0)
+ surface = caja_icon_canvas_item_get_drag_surface (container->details->drag_icon->item);
+#else
pixmap = caja_icon_canvas_item_get_image (container->details->drag_icon->item, &mask, colormap);
-
- /* we want to drag semi-transparent pixbufs, but X is too slow dealing with
- stippled masks, so we had to remove the code; this comment is left as a memorial
- to it, with the hope that we get it back someday as X Windows improves */
+#endif
/* compute the image's offset */
eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (container->details->drag_icon->item),
@@ -1608,6 +1561,11 @@ drag_begin_callback (GtkWidget *widget,
x_offset = start_x - winx;
y_offset = start_y - winy;
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_surface_set_device_offset (surface, -x_offset, -y_offset);
+ gtk_drag_set_icon_surface (context, surface);
+ cairo_surface_destroy (surface);
+#else
if (!use_mask && pixmap != NULL)
{
cairo_t *cr;
@@ -1624,6 +1582,7 @@ drag_begin_callback (GtkWidget *widget,
colormap,
pixmap, (use_mask ? mask : NULL),
x_offset, y_offset);
+#endif
}
void
@@ -1646,8 +1605,10 @@ caja_icon_dnd_begin_drag (CajaIconContainer *container,
/* Notice that the event is in bin_window coordinates, because of
the way the canvas handles events.
*/
- dnd_info->drag_info.start_x = start_x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
- dnd_info->drag_info.start_y = start_y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
+ dnd_info->drag_info.start_x = start_x -
+ gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
+ dnd_info->drag_info.start_y = start_y -
+ gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
/* start the drag */
context = gtk_drag_begin (GTK_WIDGET (container),
@@ -1658,34 +1619,50 @@ caja_icon_dnd_begin_drag (CajaIconContainer *container,
}
static gboolean
+#if GTK_CHECK_VERSION(3,0,0)
+drag_highlight_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer user_data)
+#else
drag_highlight_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
+#endif
{
gint x, y, width, height;
GdkWindow *window;
- x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (widget)));
- y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (widget)));
+ x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget)));
+ y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget)));
+ window = gtk_widget_get_window (widget);
#if GTK_CHECK_VERSION(3, 0, 0)
- width = gdk_window_get_width(GDK_WINDOW(gtk_widget_get_window(widget)));
- height = gdk_window_get_height(GDK_WINDOW(gtk_widget_get_window(widget)));
-#else
- gdk_drawable_get_size(gtk_widget_get_window(widget), &width, &height);
-#endif
+ width = gdk_window_get_width (window);
+ height = gdk_window_get_height (window);
- window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
+ gtk_paint_shadow (gtk_widget_get_style (widget),
+ cr,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ widget, "dnd",
+ x, y, width, height);
+#else
+ gdk_drawable_get_size(window, &width, &height);
gtk_paint_shadow (gtk_widget_get_style (widget), window,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, widget, "dnd",
x, y, width, height);
- gdk_draw_rectangle (window,
- (gtk_widget_get_style(widget))->black_gc,
- FALSE,
- x, y, width - 1, height - 1);
+ cairo_t *cr = gdk_cairo_create (window);
+#endif
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1);
+ cairo_stroke (cr);
+#if !GTK_CHECK_VERSION(3,0,0)
+ cairo_destroy (cr);
+#endif
return FALSE;
}
@@ -1744,8 +1721,13 @@ start_dnd_highlight (GtkWidget *widget)
if (!dnd_info->highlighted)
{
dnd_info->highlighted = TRUE;
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect_after (widget, "draw",
+ G_CALLBACK (drag_highlight_draw),
+#else
g_signal_connect_after (widget, "expose_event",
G_CALLBACK (drag_highlight_expose),
+#endif
NULL);
dnd_highlight_queue_redraw (widget);
}
@@ -1761,7 +1743,11 @@ stop_dnd_highlight (GtkWidget *widget)
if (dnd_info->highlighted)
{
g_signal_handlers_disconnect_by_func (widget,
+#if GTK_CHECK_VERSION(3,0,0)
+ drag_highlight_draw,
+#else
drag_highlight_expose,
+#endif
NULL);
dnd_highlight_queue_redraw (widget);
dnd_info->highlighted = FALSE;
@@ -2029,25 +2015,7 @@ drag_data_received_callback (GtkWidget *widget,
}
void
-caja_icon_dnd_set_stipple (CajaIconContainer *container,
- GdkBitmap *stipple)
-{
- if (stipple != NULL)
- {
- g_object_ref (stipple);
- }
-
- if (container->details->dnd_info->stipple != NULL)
- {
- g_object_unref (container->details->dnd_info->stipple);
- }
-
- container->details->dnd_info->stipple = stipple;
-}
-
-void
-caja_icon_dnd_init (CajaIconContainer *container,
- GdkBitmap *stipple)
+caja_icon_dnd_init (CajaIconContainer *container)
{
GtkTargetList *targets;
int n_elements;
@@ -2096,11 +2064,6 @@ caja_icon_dnd_init (CajaIconContainer *container,
G_CALLBACK (drag_drop_callback), NULL);
g_signal_connect (container, "drag_leave",
G_CALLBACK (drag_leave_callback), NULL);
-
- if (stipple != NULL)
- {
- container->details->dnd_info->stipple = g_object_ref (stipple);
- }
}
void
@@ -2112,11 +2075,6 @@ caja_icon_dnd_fini (CajaIconContainer *container)
{
stop_auto_scroll (container);
- if (container->details->dnd_info->stipple != NULL)
- {
- g_object_unref (container->details->dnd_info->stipple);
- }
-
caja_drag_finalize (&container->details->dnd_info->drag_info);
container->details->dnd_info = NULL;
}
diff --git a/libcaja-private/caja-icon-dnd.h b/libcaja-private/caja-icon-dnd.h
index 1070c41f..6cf14aa0 100644
--- a/libcaja-private/caja-icon-dnd.h
+++ b/libcaja-private/caja-icon-dnd.h
@@ -39,19 +39,13 @@ typedef struct
gboolean highlighted;
- /* Stipple for drawing icon shadows during DnD. */
- GdkBitmap *stipple;
-
/* Shadow for the icons being dragged. */
EelCanvasItem *shadow;
} CajaIconDndInfo;
-void caja_icon_dnd_init (CajaIconContainer *container,
- GdkBitmap *stipple);
+void caja_icon_dnd_init (CajaIconContainer *container);
void caja_icon_dnd_fini (CajaIconContainer *container);
-void caja_icon_dnd_set_stipple (CajaIconContainer *container,
- GdkBitmap *stipple);
void caja_icon_dnd_begin_drag (CajaIconContainer *container,
GdkDragAction actions,
gint button,
diff --git a/libcaja-private/caja-icon-info.c b/libcaja-private/caja-icon-info.c
index e504a557..5d783877 100644
--- a/libcaja-private/caja-icon-info.c
+++ b/libcaja-private/caja-icon-info.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* caja-icon-info.c
* Copyright (C) 2007 Red Hat, Inc., Alexander Larsson <[email protected]>
*
@@ -20,6 +21,7 @@
#include <config.h>
#include <string.h>
#include "caja-icon-info.h"
+#include "caja-icon-names.h"
#include "caja-default-file-icon.h"
#include <gtk/gtk.h>
#include <gio/gio.h>
@@ -757,3 +759,49 @@ caja_icon_get_emblem_size_for_icon_size (guint size)
return 0; /* no emblems for smaller sizes */
}
+
+gboolean
+caja_icon_theme_can_render (GThemedIcon *icon)
+{
+ GtkIconTheme *icon_theme;
+ const gchar * const *names;
+ gint idx;
+
+ names = g_themed_icon_get_names (icon);
+
+ icon_theme = gtk_icon_theme_get_default ();
+
+ for (idx = 0; names[idx] != NULL; idx++) {
+ if (gtk_icon_theme_has_icon (icon_theme, names[idx])) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+GIcon *
+caja_user_special_directory_get_gicon (GUserDirectory directory)
+{
+
+ #define ICON_CASE(x) \
+ case G_USER_DIRECTORY_ ## x:\
+ return g_themed_icon_new (CAJA_ICON_FOLDER_ ## x);
+
+ switch (directory) {
+
+ ICON_CASE (DESKTOP);
+ ICON_CASE (DOCUMENTS);
+ ICON_CASE (DOWNLOAD);
+ ICON_CASE (MUSIC);
+ ICON_CASE (PICTURES);
+ ICON_CASE (PUBLIC_SHARE);
+ ICON_CASE (TEMPLATES);
+ ICON_CASE (VIDEOS);
+
+ default:
+ return g_themed_icon_new ("folder");
+ }
+
+ #undef ICON_CASE
+}
diff --git a/libcaja-private/caja-icon-info.h b/libcaja-private/caja-icon-info.h
index 7c2a75d2..d4523d1a 100644
--- a/libcaja-private/caja-icon-info.h
+++ b/libcaja-private/caja-icon-info.h
@@ -90,6 +90,10 @@ extern "C" {
gint caja_get_icon_size_for_stock_size (GtkIconSize size);
guint caja_icon_get_emblem_size_for_icon_size (guint size);
+gboolean caja_icon_theme_can_render (GThemedIcon *icon);
+GIcon * caja_user_special_directory_get_gicon (GUserDirectory directory);
+
+
#ifdef __cplusplus
}
diff --git a/libcaja-private/caja-icon-names.h b/libcaja-private/caja-icon-names.h
index d0598749..20aee326 100644
--- a/libcaja-private/caja-icon-names.h
+++ b/libcaja-private/caja-icon-names.h
@@ -20,6 +20,15 @@
#define CAJA_ICON_EMBLEM_UNREADABLE "emblem-unreadable"
#define CAJA_ICON_EMBLEM_SYMLINK "emblem-symbolic-link"
+#define CAJA_ICON_FOLDER_DESKTOP "user-desktop"
+#define CAJA_ICON_FOLDER_DOCUMENTS "folder-documents"
+#define CAJA_ICON_FOLDER_DOWNLOAD "folder-download"
+#define CAJA_ICON_FOLDER_MUSIC "folder-music"
+#define CAJA_ICON_FOLDER_PICTURES "folder-pictures"
+#define CAJA_ICON_FOLDER_PUBLIC_SHARE "folder-publicshare"
+#define CAJA_ICON_FOLDER_TEMPLATES "folder-templates"
+#define CAJA_ICON_FOLDER_VIDEOS "folder-videos"
+
/* Other icons */
#define CAJA_ICON_TEMPLATE "text-x-generic-template"
diff --git a/libcaja-private/caja-icon-private.h b/libcaja-private/caja-icon-private.h
index 8258ca15..cf7ef592 100644
--- a/libcaja-private/caja-icon-private.h
+++ b/libcaja-private/caja-icon-private.h
@@ -219,7 +219,6 @@ struct CajaIconContainerDetails
guint32 normal_icon_color_rgba;
/* colors for text labels */
- GdkGC *label_gcs [LAST_LABEL_COLOR];
GdkColor label_colors [LAST_LABEL_COLOR];
/* State used so arrow keys don't wander if icons aren't lined up.
@@ -327,10 +326,10 @@ gboolean caja_icon_container_scroll (CajaIconContainer
void caja_icon_container_update_scroll_region (CajaIconContainer *container);
/* label color for items */
-GdkGC *caja_icon_container_get_label_color_and_gc (CajaIconContainer *container,
+void caja_icon_container_get_label_color (CajaIconContainer *container,
GdkColor **color,
gboolean first_line,
gboolean needs_highlight,
- gboolean is_prelit);
+ gboolean is_prelit);
#endif /* CAJA_ICON_CONTAINER_PRIVATE_H */
diff --git a/libcaja-private/caja-iso9660.h b/libcaja-private/caja-iso9660.h
deleted file mode 100644
index d8352cc2..00000000
--- a/libcaja-private/caja-iso9660.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Header file iso9660.h - assorted structure definitions and typecasts.
- * specific to iso9660 filesystem.
-
- Written by Eric Youngdale (1993).
-
- Copyright 1993 Yggdrasil Computing, Incorporated
-
- 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, 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 St, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#ifndef _ISOFS_FS_H
-#define _ISOFS_FS_H
-
-/*
- * The isofs filesystem constants/structures
- */
-
-#define ISODCL(from, to) (to - from + 1)
-
-struct iso_volume_descriptor
-{
- char type[ISODCL(1,1)]; /* 711 */
- char id[ISODCL(2,6)];
- char version[ISODCL(7,7)];
- char data[ISODCL(8,2048)];
-};
-
-/* volume descriptor types */
-#define ISO_VD_PRIMARY 1
-#define ISO_VD_END 255
-
-#define ISO_STANDARD_ID "CD001"
-
-struct iso_primary_descriptor
-{
- char type [ISODCL ( 1, 1)]; /* 711 */
- char id [ISODCL ( 2, 6)];
- char version [ISODCL ( 7, 7)]; /* 711 */
- char unused1 [ISODCL ( 8, 8)];
- char system_id [ISODCL ( 9, 40)]; /* achars */
- char volume_id [ISODCL ( 41, 72)]; /* dchars */
- char unused2 [ISODCL ( 73, 80)];
- char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
- char unused3 [ISODCL ( 89, 120)];
- char volume_set_size [ISODCL (121, 124)]; /* 723 */
- char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
- char logical_block_size [ISODCL (129, 132)]; /* 723 */
- char path_table_size [ISODCL (133, 140)]; /* 733 */
- char type_l_path_table [ISODCL (141, 144)]; /* 731 */
- char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
- char type_m_path_table [ISODCL (149, 152)]; /* 732 */
- char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
- char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
- char volume_set_id [ISODCL (191, 318)]; /* dchars */
- char publisher_id [ISODCL (319, 446)]; /* achars */
- char preparer_id [ISODCL (447, 574)]; /* achars */
- char application_id [ISODCL (575, 702)]; /* achars */
- char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
- char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
- char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
- char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
- char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
- char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
- char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
- char file_structure_version [ISODCL (882, 882)]; /* 711 */
- char unused4 [ISODCL (883, 883)];
- char application_data [ISODCL (884, 1395)];
- char unused5 [ISODCL (1396, 2048)];
-};
-
-/* We use this to help us look up the parent inode numbers. */
-
-struct iso_path_table
-{
- unsigned char name_len[2]; /* 721 */
- char extent[4]; /* 731 */
- char parent[2]; /* 721 */
- char name[1];
-};
-
-struct iso_directory_record
-{
- unsigned char length [ISODCL (1, 1)]; /* 711 */
- char ext_attr_length [ISODCL (2, 2)]; /* 711 */
- char extent [ISODCL (3, 10)]; /* 733 */
- char size [ISODCL (11, 18)]; /* 733 */
- char date [ISODCL (19, 25)]; /* 7 by 711 */
- char flags [ISODCL (26, 26)];
- char file_unit_size [ISODCL (27, 27)]; /* 711 */
- char interleave [ISODCL (28, 28)]; /* 711 */
- char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
- unsigned char name_len [ISODCL (33, 33)]; /* 711 */
- char name [34]; /* Not really, but we need something here */
-};
-#endif
-
-
-
diff --git a/libcaja-private/caja-keep-last-vertical-box.c b/libcaja-private/caja-keep-last-vertical-box.c
index 51c709ce..212fcc93 100644
--- a/libcaja-private/caja-keep-last-vertical-box.c
+++ b/libcaja-private/caja-keep-last-vertical-box.c
@@ -26,14 +26,13 @@
#include <config.h>
#include "caja-keep-last-vertical-box.h"
-#include <eel/eel-gtk-macros.h>
-
static void caja_keep_last_vertical_box_class_init (CajaKeepLastVerticalBoxClass *class);
static void caja_keep_last_vertical_box_init (CajaKeepLastVerticalBox *box);
static void caja_keep_last_vertical_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-EEL_CLASS_BOILERPLATE (CajaKeepLastVerticalBox, caja_keep_last_vertical_box, GTK_TYPE_VBOX)
+G_DEFINE_TYPE (CajaKeepLastVerticalBox, caja_keep_last_vertical_box, GTK_TYPE_VBOX)
+#define parent_class caja_keep_last_vertical_box_parent_class
/* Standard class initialization function */
static void
@@ -96,10 +95,10 @@ caja_keep_last_vertical_box_size_allocate (GtkWidget *widget,
g_return_if_fail (CAJA_IS_KEEP_LAST_VERTICAL_BOX (widget));
g_return_if_fail (allocation != NULL);
- EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
+ GTK_WIDGET_CLASS (caja_keep_last_vertical_box_parent_class)->size_allocate (widget, allocation);
box = GTK_BOX (widget);
- children = gtk_container_get_children (GTK_CONTAINER(widget));
+ children = gtk_container_get_children (GTK_CONTAINER (widget));
l = g_list_last (children);
if (l != NULL)
diff --git a/libcaja-private/caja-marshal.c b/libcaja-private/caja-marshal.c
deleted file mode 100644
index 59c9ddcc..00000000
--- a/libcaja-private/caja-marshal.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "caja-marshal.h"
-#include "caja-marshal-guts.c"
diff --git a/libcaja-private/caja-marshal.list b/libcaja-private/caja-marshal.list
deleted file mode 100644
index 787dcc52..00000000
--- a/libcaja-private/caja-marshal.list
+++ /dev/null
@@ -1,23 +0,0 @@
-BOOLEAN:POINTER
-BOOLEAN:VOID
-INT:POINTER,BOOLEAN
-INT:POINTER,INT
-INT:POINTER,POINTER
-OBJECT:BOXED
-POINTER:VOID
-STRING:VOID
-VOID:DOUBLE
-VOID:INT,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN
-VOID:INT,STRING
-VOID:OBJECT,BOOLEAN
-VOID:OBJECT,OBJECT
-VOID:POINTER,ENUM
-VOID:POINTER,POINTER
-VOID:POINTER,POINTER
-VOID:POINTER,POINTER,POINTER,ENUM,INT,INT
-VOID:POINTER,STRING
-VOID:POINTER,STRING,ENUM,INT,INT
-VOID:STRING,STRING,ENUM,INT,INT
-VOID:STRING,ENUM,INT,INT
-VOID:STRING,STRING
-VOID:POINTER,INT,STRING,STRING,ENUM,INT,INT
diff --git a/libcaja-private/caja-merged-directory.c b/libcaja-private/caja-merged-directory.c
index 0dc1b10c..a3e2a9b2 100644
--- a/libcaja-private/caja-merged-directory.c
+++ b/libcaja-private/caja-merged-directory.c
@@ -589,7 +589,8 @@ real_directory_notify_files_removed (CajaDirectory *real_directory)
caja_directory_notify_files_removed_by_uri (files);
}
- eel_g_list_free_deep (files);
+ g_list_foreach(files, (GFunc) g_free, NULL);
+ g_list_free(files);
}
static void
diff --git a/libcaja-private/caja-mime-actions.c b/libcaja-private/caja-mime-actions.c
index 501263f0..4668e0ac 100644
--- a/libcaja-private/caja-mime-actions.c
+++ b/libcaja-private/caja-mime-actions.c
@@ -27,7 +27,6 @@
#include <eel/eel-glib-extensions.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-alert-dialog.h>
#include <eel/eel-string.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
@@ -231,7 +230,8 @@ static void
application_launch_parameters_free (ApplicationLaunchParameters *parameters)
{
g_object_unref (parameters->application);
- eel_g_list_free_deep (parameters->uris);
+ g_list_foreach(parameters->uris, (GFunc) g_free, NULL);
+ g_list_free(parameters->uris);
g_free (parameters);
}
@@ -513,7 +513,8 @@ caja_mime_has_any_applications_for_file (CajaFile *file)
if (apps)
{
result = TRUE;
- eel_g_object_list_free (apps);
+ g_list_foreach(apps, (GFunc) g_object_unref, NULL);
+ g_list_free(apps);
}
else
{
@@ -734,7 +735,8 @@ trash_or_delete_files (GtkWindow *parent_window,
caja_file_operations_trash_or_delete (locations,
parent_window,
NULL, NULL);
- eel_g_object_list_free (locations);
+ g_list_foreach(locations, (GFunc) g_object_unref, NULL);
+ g_list_free(locations);
}
static void
@@ -794,7 +796,7 @@ report_broken_symbolic_link (GtkWindow *parent_window, CajaFile *file)
*/
response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
if (response == GTK_RESPONSE_YES)
{
@@ -861,7 +863,7 @@ get_executable_text_file_action (GtkWindow *parent_window, CajaFile *file)
g_free (detail);
response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
switch (response)
{
@@ -1224,7 +1226,7 @@ confirm_multiple_windows (GtkWindow *parent_window,
g_free (detail);
response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
return response == GTK_RESPONSE_YES;
}
@@ -1372,26 +1374,29 @@ show_unhandled_type_error (ActivateParametersInstall *parameters)
char *mime_type = caja_file_get_mime_type (parameters->file);
char *error_message = get_application_no_mime_type_handler_message (parameters->file, parameters->uri);
- if (g_content_type_is_unknown (mime_type))
- {
- dialog = eel_alert_dialog_new (parameters->parent_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- 0,
- error_message,
- _("The file is of an unknown type"));
- }
- else
- {
+ if (g_content_type_is_unknown (mime_type)) {
+ dialog = gtk_message_dialog_new (parameters->parent_window,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ 0,
+ NULL);
+ g_object_set (dialog,
+ "text", error_message,
+ "secondary-text", _("The file is of an unknown type"),
+ NULL);
+ } else {
char *text;
text = g_strdup_printf (_("There is no application installed for %s files"), g_content_type_get_description (mime_type));
- dialog = eel_alert_dialog_new (parameters->parent_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- 0,
- error_message,
- text);
+ dialog = gtk_message_dialog_new (parameters->parent_window,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ 0,
+ NULL);
+ g_object_set (dialog,
+ "text", error_message,
+ "secondary-text", text,
+ NULL);
g_free (text);
}
@@ -1734,12 +1739,15 @@ activate_desktop_file (ActivateParameters *parameters,
),
display_name);
- dialog = eel_alert_dialog_new (parameters->parent_window,
- 0,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- primary,
- secondary);
+ dialog = gtk_message_dialog_new (parameters->parent_window,
+ 0,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ NULL);
+ g_object_set (dialog,
+ "text", primary,
+ "secondary-text", secondary,
+ NULL);
gtk_dialog_add_button (GTK_DIALOG (dialog),
_("_Launch Anyway"), RESPONSE_RUN);
if (caja_file_can_set_permissions (file))
diff --git a/libcaja-private/caja-mime-application-chooser.c b/libcaja-private/caja-mime-application-chooser.c
index 3f458dba..dd8af544 100644
--- a/libcaja-private/caja-mime-application-chooser.c
+++ b/libcaja-private/caja-mime-application-chooser.c
@@ -32,8 +32,6 @@
#include "caja-signaller.h"
#include "caja-file.h"
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
#include <string.h>
#include <glib/gi18n-lib.h>
@@ -108,22 +106,12 @@ caja_mime_application_chooser_finalize (GObject *object)
}
static void
-caja_mime_application_chooser_destroy (GtkObject *object)
-{
- GTK_OBJECT_CLASS (caja_mime_application_chooser_parent_class)->destroy (object);
-}
-
-static void
caja_mime_application_chooser_class_init (CajaMimeApplicationChooserClass *class)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = caja_mime_application_chooser_finalize;
-
- object_class = GTK_OBJECT_CLASS (class);
- object_class->destroy = caja_mime_application_chooser_destroy;
}
static void
@@ -575,7 +563,8 @@ refresh_model (CajaMimeApplicationChooser *chooser)
g_object_unref (default_app);
}
- eel_g_object_list_free (applications);
+ g_list_foreach(applications, (GFunc) g_object_unref, NULL);
+ g_list_free(applications);
}
static void
@@ -683,8 +672,7 @@ set_uri_and_type_for_multiple_files (CajaMimeApplicationChooser *chooser,
char *extension_current;
extension_current = get_extension_from_file (CAJA_FILE (iter->data));
- if (eel_strcmp (first_extension, extension_current))
- {
+ if (g_strcmp0 (first_extension, extension_current)) {
same_extension = FALSE;
g_free (extension_current);
break;
diff --git a/libcaja-private/caja-open-with-dialog.c b/libcaja-private/caja-open-with-dialog.c
index 8f236d5e..50ca03ef 100644
--- a/libcaja-private/caja-open-with-dialog.c
+++ b/libcaja-private/caja-open-with-dialog.c
@@ -29,7 +29,6 @@
#include "caja-open-with-dialog.h"
#include "caja-signaller.h"
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <string.h>
@@ -120,12 +119,6 @@ caja_open_with_dialog_finalize (GObject *object)
G_OBJECT_CLASS (caja_open_with_dialog_parent_class)->finalize (object);
}
-static void
-caja_open_with_dialog_destroy (GtkObject *object)
-{
- GTK_OBJECT_CLASS (caja_open_with_dialog_parent_class)->destroy (object);
-}
-
/* An application is valid if:
*
* 1) The file exists
@@ -297,7 +290,8 @@ add_or_find_application (CajaOpenWithDialog *dialog)
if (applications != NULL)
{
- eel_g_object_list_free (applications);
+ g_list_foreach(applications, (GFunc) g_object_unref, NULL);
+ g_list_free(applications);
}
}
@@ -397,17 +391,13 @@ static void
caja_open_with_dialog_class_init (CajaOpenWithDialogClass *class)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = caja_open_with_dialog_finalize;
- object_class = GTK_OBJECT_CLASS (class);
- object_class->destroy = caja_open_with_dialog_destroy;
-
signals[APPLICATION_SELECTED] =
g_signal_new ("application_selected",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CajaOpenWithDialogClass,
application_selected),
@@ -850,7 +840,6 @@ caja_open_with_dialog_init (CajaOpenWithDialog *dialog)
dialog->details = g_new0 (CajaOpenWithDialogDetails, 1);
gtk_window_set_title (GTK_WINDOW (dialog), _("Open With"));
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
diff --git a/libcaja-private/caja-program-choosing.c b/libcaja-private/caja-program-choosing.c
index a31746ec..f7b3fa42 100644
--- a/libcaja-private/caja-program-choosing.c
+++ b/libcaja-private/caja-program-choosing.c
@@ -31,10 +31,8 @@
#include "caja-icon-info.h"
#include "caja-recent.h"
#include "caja-desktop-icon-file.h"
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-mate-extensions.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
@@ -98,7 +96,7 @@ application_cannot_open_location (GAppInfo *application,
GTK_STOCK_CANCEL,
parent_window);
response = gtk_dialog_run (message_dialog);
- gtk_object_destroy (GTK_OBJECT (message_dialog));
+ gtk_widget_destroy (GTK_WIDGET (message_dialog));
if (response == GTK_RESPONSE_YES)
{
@@ -165,7 +163,8 @@ caja_launch_application (GAppInfo *application,
uris = g_list_reverse (uris);
caja_launch_application_by_uri (application, uris,
parent_window);
- eel_g_list_free_deep (uris);
+ g_list_foreach(uris, (GFunc) g_free, NULL);
+ g_list_free(uris);
}
void
@@ -274,7 +273,8 @@ caja_launch_application_by_uri (GAppInfo *application,
}
}
- eel_g_object_list_free (locations);
+ g_list_foreach(locations, (GFunc) g_object_unref, NULL);
+ g_list_free(locations);
}
/**
@@ -450,7 +450,8 @@ caja_launch_desktop_file (GdkScreen *screen,
" drop them again."),
parent_window);
- eel_g_object_list_free (files);
+ g_list_foreach(files, (GFunc) g_object_unref, NULL);
+ g_list_free(files);
g_object_unref (app_info);
return;
}
@@ -502,7 +503,8 @@ caja_launch_desktop_file (GdkScreen *screen,
g_free (message);
}
- eel_g_object_list_free (files);
+ g_list_foreach(files, (GFunc) g_object_unref, NULL);
+ g_list_free(files);
g_object_unref (context);
g_object_unref (app_info);
}
diff --git a/libcaja-private/caja-progress-info.c b/libcaja-private/caja-progress-info.c
index b547ead8..789b5de0 100644
--- a/libcaja-private/caja-progress-info.c
+++ b/libcaja-private/caja-progress-info.c
@@ -26,9 +26,9 @@
#include <math.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <eel/eel-string.h>
#include <eel/eel-glib-extensions.h>
#include "caja-progress-info.h"
+#include <string.h>
enum
{
@@ -800,7 +800,7 @@ caja_progress_info_take_status (CajaProgressInfo *info,
{
G_LOCK (progress_info);
- if (eel_strcmp (info->status, status) != 0)
+ if (g_strcmp0 (info->status, status) != 0)
{
g_free (info->status);
info->status = status;
@@ -822,7 +822,7 @@ caja_progress_info_set_status (CajaProgressInfo *info,
{
G_LOCK (progress_info);
- if (eel_strcmp (info->status, status) != 0)
+ if (g_strcmp0 (info->status, status) != 0)
{
g_free (info->status);
info->status = g_strdup (status);
@@ -841,7 +841,7 @@ caja_progress_info_take_details (CajaProgressInfo *info,
{
G_LOCK (progress_info);
- if (eel_strcmp (info->details, details) != 0)
+ if (g_strcmp0 (info->details, details) != 0)
{
g_free (info->details);
info->details = details;
@@ -863,7 +863,7 @@ caja_progress_info_set_details (CajaProgressInfo *info,
{
G_LOCK (progress_info);
- if (eel_strcmp (info->details, details) != 0)
+ if (g_strcmp0 (info->details, details) != 0)
{
g_free (info->details);
info->details = g_strdup (details);
diff --git a/libcaja-private/caja-query.c b/libcaja-private/caja-query.c
index 42804eda..9c6044af 100644
--- a/libcaja-private/caja-query.c
+++ b/libcaja-private/caja-query.c
@@ -118,7 +118,10 @@ caja_query_get_mime_types (CajaQuery *query)
void
caja_query_set_mime_types (CajaQuery *query, GList *mime_types)
{
- eel_g_list_free_deep (query->details->mime_types);
+ g_list_foreach(query->details->mime_types, (GFunc) g_free, NULL);
+ g_list_free(query->details->mime_types);
+ g_list_foreach(query->details->mime_types, (GFunc) g_free, NULL);
+ g_list_free(query->details->mime_types);
query->details->mime_types = eel_g_str_list_copy (mime_types);
}
diff --git a/libcaja-private/caja-search-engine-beagle.c b/libcaja-private/caja-search-engine-beagle.c
index 0a2c34ff..6e59b060 100644
--- a/libcaja-private/caja-search-engine-beagle.c
+++ b/libcaja-private/caja-search-engine-beagle.c
@@ -25,7 +25,6 @@
#include "caja-search-engine-beagle.h"
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-glib-extensions.h>
#include <gmodule.h>
typedef struct _BeagleHit BeagleHit;
@@ -342,7 +341,8 @@ caja_search_engine_beagle_start (CajaSearchEngine *engine)
/* These must live during the lifetime of the query */
g_free (text);
- eel_g_list_free_deep (mimetypes);
+ g_list_foreach(mimetypes, (GFunc) g_free, NULL);
+ g_list_free(mimetypes);
}
static void
diff --git a/libcaja-private/caja-search-engine-simple.c b/libcaja-private/caja-search-engine-simple.c
index 5e906334..cf50497f 100644
--- a/libcaja-private/caja-search-engine-simple.c
+++ b/libcaja-private/caja-search-engine-simple.c
@@ -28,7 +28,6 @@
#include <glib.h>
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-glib-extensions.h>
#include <gio/gio.h>
#define BATCH_SIZE 500
@@ -138,8 +137,10 @@ search_thread_data_free (SearchThreadData *data)
g_hash_table_destroy (data->visited);
g_object_unref (data->cancellable);
g_strfreev (data->words);
- eel_g_list_free_deep (data->mime_types);
- eel_g_list_free_deep (data->uri_hits);
+ g_list_foreach(data->mime_types, (GFunc) g_free, NULL);
+ g_list_free(data->mime_types);
+ g_list_foreach(data->uri_hits, (GFunc) g_free, NULL);
+ g_list_free(data->uri_hits);
g_free (data);
}
@@ -181,7 +182,8 @@ search_thread_add_hits_idle (gpointer user_data)
hits->uris);
}
- eel_g_list_free_deep (hits->uris);
+ g_list_foreach(hits->uris, (GFunc) g_free, NULL);
+ g_list_free(hits->uris);
g_free (hits);
return FALSE;
diff --git a/libcaja-private/caja-search-engine-tracker.c b/libcaja-private/caja-search-engine-tracker.c
index ea56a924..e47af045 100644
--- a/libcaja-private/caja-search-engine-tracker.c
+++ b/libcaja-private/caja-search-engine-tracker.c
@@ -24,7 +24,6 @@
#include <config.h>
#include "caja-search-engine-tracker.h"
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-glib-extensions.h>
#include <gmodule.h>
#include <string.h>
@@ -462,7 +461,8 @@ caja_search_engine_tracker_start (CajaSearchEngine *engine)
tracker->details->query_pending = TRUE;
g_free (search_text);
- eel_g_list_free_deep (mimetypes);
+ g_list_foreach(mimetypes, (GFunc) g_free, NULL);
+ g_list_free(mimetypes);
}
static void
diff --git a/libcaja-private/caja-thumbnails.c b/libcaja-private/caja-thumbnails.c
index ef62edba..cbb5f7dc 100644
--- a/libcaja-private/caja-thumbnails.c
+++ b/libcaja-private/caja-thumbnails.c
@@ -277,6 +277,8 @@ thumbnail_thread_notify_file_changed (gpointer image_uri)
{
CajaFile *file;
+ gdk_threads_enter ();
+
file = caja_file_get_by_uri ((char *) image_uri);
#ifdef DEBUG_THUMBNAILS
g_message ("(Thumbnail Thread) Notifying file changed file:%p uri: %s\n", file, (char*) image_uri);
@@ -292,6 +294,8 @@ thumbnail_thread_notify_file_changed (gpointer image_uri)
}
g_free (image_uri);
+ gdk_threads_leave ();
+
return FALSE;
}
diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c
index 1c25c452..56e9a1cd 100644
--- a/libcaja-private/caja-tree-view-drag-dest.c
+++ b/libcaja-private/caja-tree-view-drag-dest.c
@@ -110,9 +110,9 @@ gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view)
window = gtk_tree_view_get_bin_window (tree_view);
#if GTK_CHECK_VERSION(3, 0, 0)
- vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(tree_view));
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE(tree_view));
#else
- vadjustment = gtk_tree_view_get_vadjustment(tree_view);
+ vadjustment = gtk_tree_view_get_vadjustment (tree_view);
#endif
gdk_window_get_pointer (window, NULL, &y, NULL);
@@ -186,35 +186,42 @@ remove_expand_timeout (CajaTreeViewDragDest *dest)
}
static gboolean
+#if GTK_CHECK_VERSION(3,0,0)
+highlight_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
+#else
highlight_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
+#endif
{
GdkWindow *bin_window;
int width;
int height;
- if (gtk_widget_is_drawable (widget))
- {
- bin_window =
- gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
+ /* FIXMEchpe: is bin window right here??? */
+ bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
#if GTK_CHECK_VERSION(3, 0, 0)
- width = gdk_window_get_width(GDK_WINDOW(bin_window));
- height = gdk_window_get_height(GDK_WINDOW(bin_window));
+ width = gdk_window_get_width(bin_window);
+ height = gdk_window_get_height(bin_window);
#else
- gdk_drawable_get_size(bin_window, &width, &height);
+ gdk_drawable_get_size(bin_window, &width, &height);
#endif
-
- gtk_paint_focus (gtk_widget_get_style (widget),
- bin_window,
- gtk_widget_get_state (widget),
- NULL,
- widget,
- "treeview-drop-indicator",
- 0, 0, width, height);
- }
+ gtk_paint_focus (gtk_widget_get_style (widget),
+#if GTK_CHECK_VERSION(3,0,0)
+ cr,
+ gtk_widget_get_state (widget),
+#else
+ bin_window,
+ gtk_widget_get_state (widget),
+ NULL,
+#endif
+ widget,
+ "treeview-drop-indicator",
+ 0, 0, width, height);
return FALSE;
}
@@ -234,8 +241,13 @@ set_widget_highlight (CajaTreeViewDragDest *dest, gboolean highlight)
{
dest->details->highlight_id =
g_signal_connect_object (dest->details->tree_view,
+#if GTK_CHECK_VERSION(3,0,0)
+ "draw",
+ G_CALLBACK (highlight_draw),
+#else
"expose_event",
G_CALLBACK (highlight_expose),
+#endif
dest, 0);
gtk_widget_queue_draw (GTK_WIDGET (dest->details->tree_view));
}
diff --git a/libcaja-private/caja-undostack-manager.c b/libcaja-private/caja-undostack-manager.c
index 465e35e1..0a19934e 100644
--- a/libcaja-private/caja-undostack-manager.c
+++ b/libcaja-private/caja-undostack-manager.c
@@ -33,7 +33,6 @@
#include <glib/gi18n.h>
#include <locale.h>
#include <gdk/gdk.h>
-#include <eel/eel-glib-extensions.h>
/* *****************************************************************
Private fields
@@ -432,7 +431,8 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager,
uris = construct_gfile_list (action->sources, action->src_dir);
caja_file_operations_copy (uris, NULL,
action->dest_dir, NULL, undo_redo_done_transfer_callback, action);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
break;
case CAJA_UNDOSTACK_CREATEFILEFROMTEMPLATE:
puri = get_uri_parent (action->target_uri);
@@ -448,14 +448,16 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager,
uris = construct_gfile_list (action->sources, action->src_dir);
caja_file_operations_duplicate (uris, NULL, NULL,
undo_redo_done_transfer_callback, action);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
break;
case CAJA_UNDOSTACK_RESTOREFROMTRASH:
case CAJA_UNDOSTACK_MOVE:
uris = construct_gfile_list (action->sources, action->src_dir);
caja_file_operations_move (uris, NULL,
action->dest_dir, NULL, undo_redo_done_transfer_callback, action);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
break;
case CAJA_UNDOSTACK_RENAME:
new_name = get_uri_basename (action->new_uri);
@@ -489,14 +491,16 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager,
caja_file_operations_trash_or_delete
(uris, NULL, undo_redo_done_delete_callback, action);
g_list_free (uri_to_trash);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
}
break;
case CAJA_UNDOSTACK_CREATELINK:
uris = construct_gfile_list (action->sources, action->src_dir);
caja_file_operations_link (uris, NULL,
action->dest_dir, NULL, undo_redo_done_transfer_callback, action);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
break;
case CAJA_UNDOSTACK_SETPERMISSIONS:
file = caja_file_get_by_uri (action->target_uri);
@@ -579,7 +583,8 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager,
if (priv->confirm_delete) {
caja_file_operations_delete (uris, NULL,
undo_redo_done_delete_callback, action);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
} else {
/* We skip the confirmation message
*/
@@ -600,7 +605,8 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager,
uris = construct_gfile_list (action->destinations, action->dest_dir);
caja_file_operations_trash_or_delete (uris, NULL,
undo_redo_done_delete_callback, action);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
break;
case CAJA_UNDOSTACK_MOVETOTRASH:
files_to_restore = retrieve_files_to_restore (action->trashed);
@@ -630,7 +636,8 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager,
uris = construct_gfile_list (action->destinations, action->dest_dir);
caja_file_operations_move (uris, NULL,
action->src_dir, NULL, undo_redo_done_transfer_callback, action);
- eel_g_object_list_free (uris);
+ g_list_foreach(uris, (GFunc) g_object_unref, NULL);
+ g_list_free(uris);
break;
case CAJA_UNDOSTACK_RENAME:
new_name = get_uri_basename (action->old_uri);
diff --git a/libcaja-private/caja-window-info.h b/libcaja-private/caja-window-info.h
index fb39c73f..7cced147 100644
--- a/libcaja-private/caja-window-info.h
+++ b/libcaja-private/caja-window-info.h
@@ -28,7 +28,6 @@
#include <glib-object.h>
#include <libcaja-private/caja-view.h>
#include <gtk/gtk.h>
-#include "../src/caja-bookmark-list.h"
#ifdef __cplusplus
extern "C" {
@@ -89,6 +88,10 @@ extern "C" {
typedef struct _CajaWindowInfoIface CajaWindowInfoIface;
+ typedef void (* CajaWindowGoToCallback) (CajaWindow *window,
+ GError *error,
+ gpointer user_data);
+
struct _CajaWindowInfoIface
{
GTypeInterface g_iface;
diff --git a/libcaja-private/caja-window-slot-info.c b/libcaja-private/caja-window-slot-info.c
index f0193980..01a38a80 100644
--- a/libcaja-private/caja-window-slot-info.c
+++ b/libcaja-private/caja-window-slot-info.c
@@ -108,11 +108,13 @@ caja_window_slot_info_make_hosting_pane_active (CajaWindowSlotInfo *slot)
}
void
-caja_window_slot_info_open_location (CajaWindowSlotInfo *slot,
+caja_window_slot_info_open_location_full (CajaWindowSlotInfo *slot,
GFile *location,
- CajaWindowOpenMode mode,
- CajaWindowOpenFlags flags,
- GList *selection)
+ CajaWindowOpenMode mode,
+ CajaWindowOpenFlags flags,
+ GList *selection,
+ CajaWindowGoToCallback callback,
+ gpointer user_data)
{
g_assert (CAJA_IS_WINDOW_SLOT_INFO (slot));
@@ -120,7 +122,9 @@ caja_window_slot_info_open_location (CajaWindowSlotInfo *slot,
location,
mode,
flags,
- selection);
+ selection,
+ callback,
+ user_data);
}
char *
diff --git a/libcaja-private/caja-window-slot-info.h b/libcaja-private/caja-window-slot-info.h
index 2d8b21d2..49804820 100644
--- a/libcaja-private/caja-window-slot-info.h
+++ b/libcaja-private/caja-window-slot-info.h
@@ -72,18 +72,27 @@ struct _CajaWindowSlotInfoIface
GFile *location,
CajaWindowOpenMode mode,
CajaWindowOpenFlags flags,
- GList *selection);
+ GList *selection,
+ CajaWindowGoToCallback callback,
+ gpointer user_data);
void (* make_hosting_pane_active) (CajaWindowSlotInfo *slot);
};
GType caja_window_slot_info_get_type (void);
CajaWindowInfo * caja_window_slot_info_get_window (CajaWindowSlotInfo *slot);
-void caja_window_slot_info_open_location (CajaWindowSlotInfo *slot,
+#define caja_window_slot_info_open_location(slot, location, mode, flags, selection) \
+ caja_window_slot_info_open_location_full(slot, location, mode, \
+ flags, selection, NULL, NULL)
+
+void caja_window_slot_info_open_location_full
+ (CajaWindowSlotInfo *slot,
GFile *location,
- CajaWindowOpenMode mode,
- CajaWindowOpenFlags flags,
- GList *selection);
+ CajaWindowOpenMode mode,
+ CajaWindowOpenFlags flags,
+ GList *selection,
+ CajaWindowGoToCallback callback,
+ gpointer user_data);
void caja_window_slot_info_set_status (CajaWindowSlotInfo *slot,
const char *status);
void caja_window_slot_info_make_hosting_pane_active (CajaWindowSlotInfo *slot);
diff --git a/src/Makefile.am b/src/Makefile.am
index c929e6d3..c5b60ede 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -52,6 +52,11 @@ desktopdir = $(datadir)/mate/network/
schemedir = $(datadir)/applications
scheme_DATA = mate-network-scheme.desktop
+BUILT_SOURCES = \
+ caja-src-marshal.c \
+ caja-src-marshal.h \
+ $(NULL)
+
caja_SOURCES = \
caja-actions.h \
caja-application.c \
@@ -63,6 +68,8 @@ caja_SOURCES = \
caja-connect-server-dialog.c \
caja-connect-server-dialog.h \
caja-connect-server-dialog-nonmain.c \
+ caja-connect-server-operation.c \
+ caja-connect-server-operation.h \
caja-desktop-window.c \
caja-desktop-window.h \
caja-emblem-sidebar.c \
@@ -141,6 +148,28 @@ caja_SOURCES = \
caja-zoom-control.h \
$(NULL)
+nodist_caja_SOURCES = \
+ $(BUILT_SOURCES) \
+ $(NULL)
+
+caja-src-marshal.list: $(caja_SOURCES) Makefile.am
+ $(AM_V_GEN)( cd $(srcdir) && \
+ sed -n -e 's/.*caja_src_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \
+ $(caja_SOURCES) ) \
+ | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > [email protected]
+ @if cmp -s [email protected] $@; then \
+ else \
+ fi
+
+%-marshal.c: %-marshal.list Makefile
+ $(AM_V_GEN)echo "#include \"caja-src-marshal.h\"" > $@ && \
+ $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c
+
+%-marshal.h: %-marshal.list Makefile
+ $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
+
caja_file_management_properties_SOURCES = \
caja-file-management-properties.c \
caja-file-management-properties.h \
@@ -157,8 +186,8 @@ caja_connect_server_SOURCES = \
caja-connect-server-dialog.c \
caja-connect-server-dialog.h \
caja-connect-server-dialog-main.c \
- caja-location-entry.c \
- caja-location-entry.h \
+ caja-connect-server-operation.c \
+ caja-connect-server-operation.h \
$(NULL)
caja_convert_metadata_SOURCES = \
@@ -179,19 +208,19 @@ ui_DATA = \
$(NULL)
CLEANFILES = \
+ caja-src-marshal.list \
+ $(BUILT_SOURCES) \
$(desktop_files) \
$(server_DATA) \
$(NULL)
EXTRA_DIST = \
+ caja-src-marshal.list \
$(server_in_files) \
$(ui_DATA) \
check-caja \
$(desktop_in_files) \
$(NULL)
-BUILT_SOURCES = \
- $(NULL)
-
dist-hook:
cd $(distdir); rm -f $(CLEANFILES)
diff --git a/src/caja-application.c b/src/caja-application.c
index 5881facd..edba1d5c 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -257,7 +257,8 @@ automount_all_volumes (CajaApplication *application)
/* pass NULL as GMountOperation to avoid user interaction */
g_volume_mount (volume, 0, NULL, NULL, startup_volume_mount_cb, NULL);
}
- eel_g_object_list_free (volumes);
+ g_list_foreach(volumes, (GFunc) g_object_unref, NULL);
+ g_list_free(volumes);
}
}
@@ -432,7 +433,7 @@ check_required_directories (CajaApplication *application)
dialog = eel_show_error_dialog (error_string, detail_string, NULL);
/* We need the main event loop so the user has a chance to see the dialog. */
- caja_main_event_loop_register (GTK_OBJECT (dialog));
+ caja_main_event_loop_register (GTK_WIDGET (dialog));
g_string_free (directories_as_string, TRUE);
g_free (error_string);
@@ -777,43 +778,34 @@ open_window (CajaApplication *application,
{
GFile *location;
CajaWindow *window;
+ gboolean existing;
+
+ if (uri == NULL) {
+ location = g_file_new_for_path (g_get_home_dir ());
+ } else {
+ location = g_file_new_for_uri (uri);
+ }
+
+ existing = FALSE;
if (browser_window ||
- g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER))
- {
+ g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = caja_application_create_navigation_window (application,
startup_id,
screen);
- if (uri == NULL)
- {
- caja_window_go_home (window);
- }
- else
- {
- location = g_file_new_for_uri (uri);
- caja_window_go_to (window, location);
- g_object_unref (location);
- }
- }
- else
- {
- if (uri == NULL)
- {
- location = g_file_new_for_path (g_get_home_dir ());
- }
- else
- {
- location = g_file_new_for_uri (uri);
- }
-
- window = caja_application_present_spatial_window (application,
+ } else {
+ window = caja_application_get_spatial_window (application,
NULL,
startup_id,
location,
- screen);
- g_object_unref (location);
+ screen,
+ NULL);
}
+ caja_window_go_to (window, location);
+
+ g_object_unref (location);
+
if (geometry != NULL && !gtk_widget_get_visible (GTK_WIDGET (window)))
{
/* never maximize windows opened from shell if a
@@ -1225,22 +1217,25 @@ caja_application_get_existing_spatial_window (GFile *location)
{
GList *l;
CajaWindowSlot *slot;
+ GFile *window_location;
for (l = caja_application_get_spatial_window_list ();
- l != NULL; l = l->next)
- {
- GFile *window_location;
-
+ l != NULL; l = l->next) {
slot = CAJA_WINDOW (l->data)->details->active_pane->active_slot;
- window_location = slot->location;
- if (window_location != NULL)
- {
- if (g_file_equal (location, window_location))
- {
- return CAJA_SPATIAL_WINDOW (l->data);
+
+ window_location = slot->pending_location;
+
+ if (window_location == NULL) {
+ window_location = slot->location;
+ }
+
+ if (window_location != NULL) {
+ if (g_file_equal (location, window_location)) {
+ return CAJA_SPATIAL_WINDOW (l->data);
}
}
}
+
return NULL;
}
@@ -1352,7 +1347,11 @@ caja_application_close_all_spatial_windows (void)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+caja_application_destroyed_window (GtkWidget *object, CajaApplication *application)
+#else
caja_application_destroyed_window (GtkObject *object, CajaApplication *application)
+#endif
{
caja_application_window_list = g_list_remove (caja_application_window_list, object);
}
@@ -1416,68 +1415,32 @@ spatial_window_destroyed_callback (void *user_data, GObject *window)
}
CajaWindow *
-caja_application_present_spatial_window (CajaApplication *application,
- CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GdkScreen *screen)
-{
- return caja_application_present_spatial_window_with_selection (application,
- requesting_window,
- startup_id,
- location,
- NULL,
- screen);
-}
-
-CajaWindow *
-caja_application_present_spatial_window_with_selection (CajaApplication *application,
- CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GList *new_selection,
- GdkScreen *screen)
+caja_application_get_spatial_window (CajaApplication *application,
+ CajaWindow *requesting_window,
+ const char *startup_id,
+ GFile *location,
+ GdkScreen *screen,
+ gboolean *existing)
{
CajaWindow *window;
- GList *l;
- char *uri;
+ gchar *uri;
g_return_val_if_fail (CAJA_IS_APPLICATION (application), NULL);
+ window = CAJA_WINDOW
+ (caja_application_get_existing_spatial_window (location));
- for (l = caja_application_get_spatial_window_list ();
- l != NULL; l = l->next)
- {
- CajaWindow *existing_window;
- CajaWindowSlot *slot;
- GFile *existing_location;
-
- existing_window = CAJA_WINDOW (l->data);
- slot = existing_window->details->active_pane->active_slot;
- existing_location = slot->pending_location;
-
- if (existing_location == NULL)
- {
- existing_location = slot->location;
+ if (window != NULL) {
+ if (existing != NULL) {
+ *existing = TRUE;
}
- if (g_file_equal (existing_location, location))
- {
- gtk_window_present (GTK_WINDOW (existing_window));
- if (new_selection &&
- slot->content_view != NULL)
- {
- caja_view_set_selection (slot->content_view, new_selection);
- }
-
- uri = g_file_get_uri (location);
- caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
- "present EXISTING spatial window=%p: %s",
- existing_window, uri);
- g_free (uri);
- return existing_window;
- }
+ return window;
}
+ if (existing != NULL) {
+ *existing = FALSE;
+ }
+
window = create_window (application, CAJA_TYPE_SPATIAL_WINDOW, startup_id, screen);
if (requesting_window)
{
@@ -1508,8 +1471,6 @@ caja_application_present_spatial_window_with_selection (CajaApplication *applica
g_object_weak_ref (G_OBJECT (window),
spatial_window_destroyed_callback, NULL);
- caja_window_go_to_with_selection (window, location, new_selection);
-
uri = g_file_get_uri (location);
caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
"present NEW spatial window=%p: %s",
@@ -1704,27 +1665,30 @@ autorun_show_window (GMount *mount, gpointer user_data)
{
GFile *location;
CajaApplication *application = user_data;
+ CajaWindow *window;
+ gboolean existing;
location = g_mount_get_root (mount);
+ existing = FALSE;
/* There should probably be an easier way to do this */
- if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER))
- {
- CajaWindow *window;
+ if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = caja_application_create_navigation_window (application,
- NULL,
- gdk_screen_get_default ());
- caja_window_go_to (window, location);
-
+ NULL,
+ gdk_screen_get_default ());
}
else
{
- caja_application_present_spatial_window (application,
- NULL,
- NULL,
- location,
- gdk_screen_get_default ());
+ window = caja_application_get_spatial_window (application,
+ NULL,
+ NULL,
+ location,
+ gdk_screen_get_default (),
+ NULL);
}
+
+ caja_window_go_to (window, location);
+
g_object_unref (location);
}
@@ -2285,7 +2249,12 @@ caja_application_load_session (CajaApplication *application)
else if (!strcmp (type, "spatial"))
{
location = g_file_new_for_uri (location_uri);
- window = caja_application_present_spatial_window (application, NULL, NULL, location, gdk_screen_get_default ());
+ window = caja_application_get_spatial_window (application, NULL, NULL,
+ location, gdk_screen_get_default (),
+ NULL);
+
+ caja_window_go_to (window, location);
+
g_object_unref (location);
}
else
diff --git a/src/caja-application.h b/src/caja-application.h
index 5c5b94d0..426f2c09 100644
--- a/src/caja-application.h
+++ b/src/caja-application.h
@@ -88,17 +88,12 @@ GList * caja_application_get_window_list (void);
GList * caja_application_get_spatial_window_list (void);
unsigned int caja_application_get_n_windows (void);
-CajaWindow * caja_application_present_spatial_window (CajaApplication *application,
+CajaWindow * caja_application_get_spatial_window (CajaApplication *application,
CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GdkScreen *screen);
-CajaWindow * caja_application_present_spatial_window_with_selection (CajaApplication *application,
- CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GList *new_selection,
- GdkScreen *screen);
+ const char *startup_id,
+ GFile *location,
+ GdkScreen *screen,
+ gboolean *existing);
CajaWindow * caja_application_create_navigation_window (CajaApplication *application,
const char *startup_id,
diff --git a/src/caja-bookmark-list.c b/src/caja-bookmark-list.c
index cde07a1c..db594cf7 100644
--- a/src/caja-bookmark-list.c
+++ b/src/caja-bookmark-list.c
@@ -31,9 +31,9 @@
#include <libcaja-private/caja-file-utilities.h>
#include <libcaja-private/caja-file.h>
#include <libcaja-private/caja-icon-names.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
+
#include <gio/gio.h>
+#include <string.h>
#define MAX_BOOKMARK_LENGTH 80
#define LOAD_JOB 1
@@ -167,7 +167,8 @@ static void
clear (CajaBookmarkList *bookmarks)
{
g_list_foreach (bookmarks->list, stop_monitoring_one, bookmarks);
- eel_g_object_list_free (bookmarks->list);
+ g_list_foreach(bookmarks->list, (GFunc) g_object_unref, NULL);
+ g_list_free(bookmarks->list);
bookmarks->list = NULL;
}
@@ -407,7 +408,7 @@ caja_bookmark_list_delete_items_with_uri (CajaBookmarkList *bookmarks,
next = node->next;
bookmark_uri = caja_bookmark_get_uri (CAJA_BOOKMARK (node->data));
- if (eel_strcmp (bookmark_uri, uri) == 0)
+ if (g_strcmp0 (bookmark_uri, uri) == 0)
{
bookmarks->list = g_list_remove_link (bookmarks->list, node);
stop_monitoring_bookmark (bookmarks, CAJA_BOOKMARK (node->data));
diff --git a/src/caja-bookmarks-window.c b/src/caja-bookmarks-window.c
index 49f66850..4b13a1ee 100644
--- a/src/caja-bookmarks-window.c
+++ b/src/caja-bookmarks-window.c
@@ -229,9 +229,9 @@ static void
edit_bookmarks_dialog_reset_signals (gpointer data,
GObject *obj)
{
- g_signal_handler_disconnect (GTK_OBJECT (jump_button),
+ g_signal_handler_disconnect (jump_button,
jump_button_signal_id);
- g_signal_handler_disconnect (GTK_OBJECT (bookmark_list_widget),
+ g_signal_handler_disconnect (bookmark_list_widget,
row_activated_signal_id);
jump_button_signal_id =
g_signal_connect (jump_button, "clicked",
@@ -415,9 +415,9 @@ void
edit_bookmarks_dialog_set_signals (CajaWindow *window)
{
- g_signal_handler_disconnect (GTK_OBJECT (jump_button),
+ g_signal_handler_disconnect (jump_button,
jump_button_signal_id);
- g_signal_handler_disconnect (GTK_OBJECT (bookmark_list_widget),
+ g_signal_handler_disconnect (bookmark_list_widget,
row_activated_signal_id);
jump_button_signal_id =
@@ -582,35 +582,35 @@ open_selected_bookmark (gpointer user_data, GdkScreen *screen)
if (CAJA_IS_NAVIGATION_WINDOW (user_data))
{
- caja_window_go_to (CAJA_WINDOW (user_data), location);
+ window = user_data;
}
else if (CAJA_IS_SPATIAL_WINDOW (user_data))
{
- window = caja_application_present_spatial_window (application,
- NULL,
- NULL,
- location,
- screen);
- }
- else /* window that opened bookmarks window has been closed */
- {
- if (parent_is_browser_window || g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER))
- {
+ window = caja_application_get_spatial_window (application,
+ NULL,
+ NULL,
+ location,
+ screen,
+ NULL);
+ } else { /* window that opened bookmarks window has been closed */
+ if (parent_is_browser_window || g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = caja_application_create_navigation_window (application,
NULL,
screen);
- caja_window_go_to (window, location);
}
else
{
- window = caja_application_present_spatial_window (application,
- NULL,
- NULL,
- location,
- screen);
+ window = caja_application_get_spatial_window (application,
+ NULL,
+ NULL,
+ location,
+ screen,
+ NULL);
}
}
+ caja_window_go_to (window, location);
+
g_object_unref (location);
}
@@ -749,7 +749,7 @@ on_key_pressed (GtkTreeView *view,
GdkEventKey *event,
gpointer user_data)
{
- if (event->keyval == GDK_Delete || event->keyval == GDK_KP_Delete)
+ if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete)
{
bookmarks_delete_bookmark ();
return TRUE;
@@ -1082,8 +1082,7 @@ handle_close_accelerator (GtkWindow *window,
g_assert (event != NULL);
g_assert (user_data == NULL);
- if (eel_gtk_window_event_is_close_accelerator (window, event))
- {
+ if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_KEY_w) {
gtk_widget_hide (GTK_WIDGET (window));
return TRUE;
}
diff --git a/src/caja-bookmarks-window.ui b/src/caja-bookmarks-window.ui
index 3c5e47e6..b57adcb1 100644
--- a/src/caja-bookmarks-window.ui
+++ b/src/caja-bookmarks-window.ui
@@ -9,7 +9,6 @@
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
diff --git a/src/caja-connect-server-dialog-main.c b/src/caja-connect-server-dialog-main.c
index 44c57980..4c80fc16 100644
--- a/src/caja-connect-server-dialog-main.c
+++ b/src/caja-connect-server-dialog-main.c
@@ -22,6 +22,7 @@
*
* Authors:
* Vincent Untz <[email protected]>
+ * Cosimo Cecchi <[email protected]>
*/
#include <config.h>
@@ -38,10 +39,9 @@
#include <libcaja-private/caja-icon-names.h>
#include <libcaja-private/caja-global-preferences.h>
-#include "caja-window.h"
#include "caja-connect-server-dialog.h"
-static int open_dialogs;
+static GSimpleAsyncResult *display_location_res = NULL;
static void
main_dialog_destroyed (GtkWidget *widget,
@@ -53,117 +53,53 @@ main_dialog_destroyed (GtkWidget *widget,
gtk_main_quit ();
}
-static void
-error_dialog_destroyed (GtkWidget *widget,
- GtkWidget *main_dialog)
-{
- if (--open_dialogs <= 0)
- gtk_widget_destroy (main_dialog);
-}
-
-static void
-display_error_dialog (GError *error,
- const char *uri,
- GtkWidget *parent)
+gboolean
+caja_connect_server_dialog_display_location_finish (CajaConnectServerDialog *self,
+ GAsyncResult *res,
+ GError **error)
{
- GtkDialog *error_dialog;
- char *error_message;
-
- error_message = g_strdup_printf (_("Cannot display location \"%s\""),
- uri);
- error_dialog = eel_show_error_dialog (error_message,
- error->message,
- NULL);
-
- open_dialogs++;
-
- g_signal_connect (error_dialog, "destroy",
- G_CALLBACK (error_dialog_destroyed), parent);
-
- gtk_window_set_screen (GTK_WINDOW (error_dialog),
- gtk_widget_get_screen (parent));
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) {
+ return FALSE;
+ }
- g_free (error_message);
+ return TRUE;
}
-static void
-show_uri (const char *uri,
- GtkWidget *widget)
+void
+caja_connect_server_dialog_display_location_async (CajaConnectServerDialog *self,
+ CajaApplication *application,
+ GFile *location,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- GError *error;
+ GError *error;
GdkAppLaunchContext *launch_context;
+ gchar *uri;
+
+ display_location_res = g_simple_async_result_new (G_OBJECT (self),
+ callback, user_data,
+ caja_connect_server_dialog_display_location_async);
+ error = NULL;
+ uri = g_file_get_uri (location);
launch_context = gdk_app_launch_context_new ();
gdk_app_launch_context_set_screen (launch_context,
- gtk_widget_get_screen (widget));
+ gtk_widget_get_screen (GTK_WIDGET (self)));
- error = NULL;
g_app_info_launch_default_for_uri (uri,
G_APP_LAUNCH_CONTEXT (launch_context),
&error);
g_object_unref (launch_context);
- if (error)
- {
- display_error_dialog (error, uri, widget);
- g_error_free (error);
- }
- else
- {
- /* everything is OK, destroy the main dialog and quit */
- gtk_widget_destroy (widget);
- }
-}
-
-static void
-mount_enclosing_ready_cb (GFile *location,
- GAsyncResult *res,
- GtkWidget *widget)
-{
- char *uri;
- gboolean success;
- GError *error = NULL;
-
- uri = g_file_get_uri (location);
- success = g_file_mount_enclosing_volume_finish (location,
- res, &error);
-
- if (success ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED))
- {
- /* volume is mounted, show it */
- show_uri (uri, widget);
- }
- else
- {
- display_error_dialog (error, uri, widget);
- }
-
- if (error)
- {
+ if (error != NULL) {
+ g_simple_async_result_set_from_error (display_location_res, error);
g_error_free (error);
}
+ g_simple_async_result_complete_in_idle (display_location_res);
- g_object_unref (location);
- g_free (uri);
-}
-
-void
-caja_connect_server_dialog_present_uri (CajaApplication *application,
- GFile *location,
- GtkWidget *widget)
-{
- GMountOperation *op;
-
- op = gtk_mount_operation_new (GTK_WINDOW (widget));
- g_mount_operation_set_password_save (op, G_PASSWORD_SAVE_FOR_SESSION);
- g_file_mount_enclosing_volume (location,
- 0, op,
- NULL,
- (GAsyncReadyCallback) mount_enclosing_ready_cb,
- widget);
- g_object_unref (op);
+ g_object_unref (display_location_res);
+ display_location_res = NULL;
}
int
@@ -171,26 +107,16 @@ main (int argc, char *argv[])
{
GtkWidget *dialog;
GOptionContext *context;
- const char **args;
- GFile *location;
GError *error;
- const GOptionEntry options[] =
- {
- { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &args, NULL, N_("[URI]") },
- { NULL }
- };
bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- args = NULL;
error = NULL;
/* Translators: This is the --help description for the connect to server app,
the initial newlines are between the command line arg and the description */
context = g_option_context_new (N_("\n\nAdd connect to server mount"));
- g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
-
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
@@ -208,22 +134,8 @@ main (int argc, char *argv[])
gtk_window_set_default_icon_name (CAJA_ICON_FOLDER);
+ dialog = caja_connect_server_dialog_new (NULL);
- /* command line arguments, null terminated array */
- location = NULL;
- if (args)
- {
- location = g_file_new_for_commandline_arg (*args);
- }
-
- dialog = caja_connect_server_dialog_new (NULL, location);
-
- if (location)
- {
- g_object_unref (location);
- }
-
- open_dialogs = 0;
g_signal_connect (dialog, "destroy",
G_CALLBACK (main_dialog_destroyed), NULL);
diff --git a/src/caja-connect-server-dialog-nonmain.c b/src/caja-connect-server-dialog-nonmain.c
index 0f196ca0..78015f3e 100644
--- a/src/caja-connect-server-dialog-nonmain.c
+++ b/src/caja-connect-server-dialog-nonmain.c
@@ -31,29 +31,69 @@
* caja-connect-server-dialog-main.c for the standalone version.
*/
+static GSimpleAsyncResult *display_location_res = NULL;
+
+static void
+window_go_to_cb (CajaWindow *window,
+ GError *error,
+ gpointer user_data)
+{
+ CajaConnectServerDialog *self;
+
+ self = user_data;
+
+ if (error != NULL) {
+ g_simple_async_result_set_from_error (display_location_res, error);
+ }
+
+ g_simple_async_result_complete (display_location_res);
+
+ g_object_unref (display_location_res);
+ display_location_res = NULL;
+}
+
+gboolean
+caja_connect_server_dialog_display_location_finish (CajaConnectServerDialog *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
-caja_connect_server_dialog_present_uri (CajaApplication *application,
- GFile *location,
- GtkWidget *widget)
+caja_connect_server_dialog_display_location_async (CajaConnectServerDialog *self,
+ CajaApplication *application,
+ GFile *location,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
CajaWindow *window;
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (self);
- if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER))
- {
+ display_location_res =
+ g_simple_async_result_new (G_OBJECT (self),
+ callback, user_data,
+ caja_connect_server_dialog_display_location_async);
+
+ if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = caja_application_create_navigation_window (application,
- NULL,
- gtk_widget_get_screen (widget));
- caja_window_go_to (window, location);
- }
- else
- {
- caja_application_present_spatial_window (application,
- NULL,
- NULL,
- location,
- gtk_widget_get_screen (widget));
+ NULL,
+ gtk_widget_get_screen (widget));
+ } else {
+ window = caja_application_get_spatial_window (application,
+ NULL,
+ NULL,
+ location,
+ gtk_widget_get_screen (widget),
+ NULL);
}
- gtk_widget_destroy (widget);
- g_object_unref (location);
+ caja_window_go_to_full (window, location,
+ window_go_to_cb, self);
}
diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c
index 3737a15b..6c6036fe 100644
--- a/src/caja-connect-server-dialog.c
+++ b/src/caja-connect-server-dialog.c
@@ -4,6 +4,7 @@
* Caja
*
* Copyright (C) 2003 Red Hat, Inc.
+ * Copyright (C) 2010 Cosimo Cecchi <[email protected]>
*
* Caja is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -22,56 +23,68 @@
*/
#include <config.h>
+
#include "caja-connect-server-dialog.h"
#include <string.h>
-#include <eel/eel-gtk-macros.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-vfs-extensions.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
-#include "caja-location-entry.h"
+
+#include "caja-application.h"
+#include "caja-bookmark-list.h"
+#include "caja-connect-server-operation.h"
+#include "caja-window.h"
+
#include <libcaja-private/caja-global-preferences.h>
#include <libcaja-private/caja-icon-names.h>
/* TODO:
- * - dns-sd fill out servers
- * - pre-fill user?
* - name entry + pre-fill
- * - folder browse function
- */
-
-/* TODO gio port:
- * - see FIXME here
- * - see FIXME in caja-connect-server-dialog-main.c
+ * - NetworkManager integration
*/
struct _CajaConnectServerDialogDetails
{
CajaApplication *application;
- GtkWidget *table;
+ GtkWidget *primary_table;
+ GtkWidget *user_details;
+ GtkWidget *port_spinbutton;
+
+ GtkWidget *info_bar;
+ GtkWidget *info_bar_content;
GtkWidget *type_combo;
- GtkWidget *uri_entry;
GtkWidget *server_entry;
GtkWidget *share_entry;
- GtkWidget *port_entry;
GtkWidget *folder_entry;
GtkWidget *domain_entry;
GtkWidget *user_entry;
+ GtkWidget *password_entry;
+ GtkWidget *remember_checkbox;
+ GtkWidget *connect_button;
- GtkWidget *bookmark_check;
- GtkWidget *name_entry;
+ GList *iconized_entries;
+
+ GSimpleAsyncResult *fill_details_res;
+ GAskPasswordFlags fill_details_flags;
+ GMountOperation *fill_operation;
+
+ gboolean last_password_set;
+ gulong password_sensitive_id;
+ gboolean should_destroy;
};
-static void caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class);
-static void caja_connect_server_dialog_init (CajaConnectServerDialog *dialog);
+G_DEFINE_TYPE (CajaConnectServerDialog, caja_connect_server_dialog,
+ GTK_TYPE_DIALOG)
+
+static void sensitive_entry_changed_callback (GtkEditable *editable,
+ GtkWidget *widget);
+static void iconized_entry_changed_cb (GtkEditable *entry,
+ CajaConnectServerDialog *dialog);
-EEL_CLASS_BOILERPLATE (CajaConnectServerDialog,
- caja_connect_server_dialog,
- GTK_TYPE_DIALOG)
enum
{
RESPONSE_CONNECT
@@ -81,345 +94,435 @@ struct MethodInfo
{
const char *scheme;
guint flags;
+ guint default_port;
};
/* A collection of flags for MethodInfo.flags */
enum
{
- DEFAULT_METHOD = 0x00000001,
+ DEFAULT_METHOD = (1 << 0),
- /* Widgets to display in setup_for_type */
- SHOW_SHARE = 0x00000010,
- SHOW_PORT = 0x00000020,
- SHOW_USER = 0x00000040,
- SHOW_DOMAIN = 0x00000080,
+ /* Widgets to display in connect_dialog_setup_for_type */
+ SHOW_SHARE = (1 << 1),
+ SHOW_PORT = (1 << 2),
+ SHOW_USER = (1 << 3),
+ SHOW_DOMAIN = (1 << 4),
- IS_ANONYMOUS = 0x00001000
+ IS_ANONYMOUS = (1 << 5)
};
/* Remember to fill in descriptions below */
static struct MethodInfo methods[] =
{
/* FIXME: we need to alias ssh to sftp */
- { "sftp", SHOW_PORT | SHOW_USER },
- { "ftp", SHOW_PORT | SHOW_USER },
- { "ftp", DEFAULT_METHOD | IS_ANONYMOUS | SHOW_PORT},
- { "smb", SHOW_SHARE | SHOW_USER | SHOW_DOMAIN },
- { "dav", SHOW_PORT | SHOW_USER },
+ { "sftp", SHOW_PORT | SHOW_USER, 22 },
+ { "ftp", SHOW_PORT | SHOW_USER, 21 },
+ { "ftp", DEFAULT_METHOD | IS_ANONYMOUS | SHOW_PORT, 21 },
+ { "smb", SHOW_SHARE | SHOW_USER | SHOW_DOMAIN, 0 },
+ { "dav", SHOW_PORT | SHOW_USER, 80 },
/* FIXME: hrm, shouldn't it work? */
- { "davs", SHOW_PORT | SHOW_USER },
- { NULL, 0 }, /* Custom URI method */
+ { "davs", SHOW_PORT | SHOW_USER, 443 },
};
/* To get around non constant gettext strings */
static const char*
get_method_description (struct MethodInfo *meth)
{
- if (!meth->scheme)
- {
- return _("Custom Location");
- }
- else if (strcmp (meth->scheme, "sftp") == 0)
- {
+ if (strcmp (meth->scheme, "sftp") == 0) {
return _("SSH");
- }
- else if (strcmp (meth->scheme, "ftp") == 0)
- {
- if (meth->flags & IS_ANONYMOUS)
- {
+ } else if (strcmp (meth->scheme, "ftp") == 0) {
+ if (meth->flags & IS_ANONYMOUS) {
return _("Public FTP");
- }
- else
- {
+ } else {
return _("FTP (with login)");
}
- }
- else if (strcmp (meth->scheme, "smb") == 0)
- {
+ } else if (strcmp (meth->scheme, "smb") == 0) {
return _("Windows share");
- }
- else if (strcmp (meth->scheme, "dav") == 0)
- {
+ } else if (strcmp (meth->scheme, "dav") == 0) {
return _("WebDAV (HTTP)");
- }
- else if (strcmp (meth->scheme, "davs") == 0)
- {
+ } else if (strcmp (meth->scheme, "davs") == 0) {
return _("Secure WebDAV (HTTPS)");
/* No descriptive text */
- }
- else
- {
+ } else {
return meth->scheme;
}
}
static void
-caja_connect_server_dialog_finalize (GObject *object)
+connect_dialog_restore_info_bar (CajaConnectServerDialog *dialog,
+ GtkMessageType message_type)
+{
+ if (dialog->details->info_bar_content != NULL) {
+ gtk_widget_destroy (dialog->details->info_bar_content);
+ dialog->details->info_bar_content = NULL;
+ }
+
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (dialog->details->info_bar),
+ message_type);
+}
+
+static void
+connect_dialog_set_connecting (CajaConnectServerDialog *dialog)
{
- CajaConnectServerDialog *dialog;
+ GtkWidget *hbox;
+ GtkWidget *widget;
+ GtkWidget *content_area;
+ gint width, height;
+
+ connect_dialog_restore_info_bar (dialog, GTK_MESSAGE_INFO);
+ gtk_widget_show (dialog->details->info_bar);
- dialog = CAJA_CONNECT_SERVER_DIALOG (object);
+ content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar));
- g_object_unref (dialog->details->uri_entry);
- g_object_unref (dialog->details->server_entry);
- g_object_unref (dialog->details->share_entry);
- g_object_unref (dialog->details->port_entry);
- g_object_unref (dialog->details->folder_entry);
- g_object_unref (dialog->details->domain_entry);
- g_object_unref (dialog->details->user_entry);
- g_object_unref (dialog->details->bookmark_check);
- g_object_unref (dialog->details->name_entry);
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (content_area), hbox);
+ gtk_widget_show (hbox);
- g_free (dialog->details);
+ dialog->details->info_bar_content = hbox;
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ widget = gtk_spinner_new ();
+ gtk_icon_size_lookup (GTK_ICON_SIZE_SMALL_TOOLBAR, &width, &height);
+ gtk_widget_set_size_request (widget, width, height);
+ gtk_spinner_start (GTK_SPINNER (widget));
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (_("Connecting..."));
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_sensitive (dialog->details->connect_button, FALSE);
}
static void
-caja_connect_server_dialog_destroy (GtkObject *object)
+connect_dialog_gvfs_error (CajaConnectServerDialog *dialog)
{
- CajaConnectServerDialog *dialog;
+ GtkWidget *hbox, *image, *content_area, *label;
+
+ connect_dialog_restore_info_bar (dialog, GTK_MESSAGE_ERROR);
- dialog = CAJA_CONNECT_SERVER_DIALOG (object);
+ content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar));
- EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (content_area), hbox);
+ gtk_widget_show (hbox);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 6);
+ gtk_widget_show (image);
+
+ label = gtk_label_new (_("Can't load the supported server method list.\n"
+ "Please check your GVfs installation."));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6);
+ gtk_widget_show (label);
+
+ gtk_widget_set_sensitive (dialog->details->connect_button, FALSE);
+ gtk_widget_set_sensitive (dialog->details->primary_table, FALSE);
+
+ gtk_widget_show (dialog->details->info_bar);
}
static void
-connect_to_server (CajaConnectServerDialog *dialog)
+iconized_entry_restore (gpointer data,
+ gpointer user_data)
{
- struct MethodInfo *meth;
- char *uri;
- GFile *location;
- int index;
- GtkTreeIter iter;
+ GtkEntry *entry;
+ CajaConnectServerDialog *dialog;
- /* Get our method info */
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), &iter);
- gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->details->type_combo)),
- &iter, 0, &index, -1);
- g_assert (index < G_N_ELEMENTS (methods) && index >= 0);
- meth = &(methods[index]);
-
- uri = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->server_entry), 0, -1);
- if (strlen (uri) == 0)
- {
- eel_show_error_dialog (_("Cannot Connect to Server. You must enter a name for the server."),
- _("Please enter a name and try again."),
- GTK_WINDOW (dialog));
- g_free (uri);
- return;
- }
+ entry = data;
+ dialog = user_data;
- if (meth->scheme == NULL)
- {
- uri = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->uri_entry), 0, -1);
- /* FIXME: we should validate it in some way? */
- }
- else
- {
- char *user, *port, *initial_path, *server, *folder, *domain;
- char *t, *join;
- gboolean free_initial_path, free_user, free_domain, free_port;
-
- server = uri;
- uri = NULL;
-
- user = "";
- port = "";
- initial_path = "";
- domain = "";
- free_initial_path = FALSE;
- free_user = FALSE;
- free_domain = FALSE;
- free_port = FALSE;
-
- /* FTP special case */
- if (meth->flags & IS_ANONYMOUS)
- {
- user = "anonymous";
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ NULL);
- /* SMB special case */
- }
- else if (strcmp (meth->scheme, "smb") == 0)
- {
- t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->share_entry), 0, -1);
- initial_path = g_strconcat ("/", t, NULL);
- free_initial_path = TRUE;
- g_free (t);
- }
-
- if (gtk_widget_get_parent (dialog->details->port_entry) != NULL)
- {
- free_port = TRUE;
- port = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->port_entry), 0, -1);
- }
- folder = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->folder_entry), 0, -1);
- if (gtk_widget_get_parent (dialog->details->user_entry) != NULL)
- {
- free_user = TRUE;
+ g_signal_handlers_disconnect_by_func (entry,
+ iconized_entry_changed_cb,
+ dialog);
+}
- t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->user_entry), 0, -1);
+static void
+iconized_entry_changed_cb (GtkEditable *entry,
+ CajaConnectServerDialog *dialog)
+{
+ dialog->details->iconized_entries =
+ g_list_remove (dialog->details->iconized_entries, entry);
- user = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO, FALSE);
+ iconized_entry_restore (entry, dialog);
+}
- g_free (t);
- }
- if (gtk_widget_get_parent (dialog->details->domain_entry) != NULL)
- {
- free_domain = TRUE;
+static void
+iconize_entry (CajaConnectServerDialog *dialog,
+ GtkWidget *entry)
+{
+ if (!g_list_find (dialog->details->iconized_entries, entry)) {
+ dialog->details->iconized_entries =
+ g_list_prepend (dialog->details->iconized_entries, entry);
- domain = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->domain_entry), 0, -1);
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ GTK_STOCK_DIALOG_WARNING);
- if (strlen (domain) != 0)
- {
- t = user;
+ gtk_widget_grab_focus (entry);
- user = g_strconcat (domain , ";" , t, NULL);
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (iconized_entry_changed_cb), dialog);
+ }
+}
- if (free_user)
- {
- g_free (t);
- }
+static void
+connect_dialog_set_info_bar_error (CajaConnectServerDialog *dialog,
+ GError *error)
+{
+ GtkWidget *content_area, *label, *entry, *hbox, *icon;
+ gchar *str;
+ const gchar *folder, *server;
+
+ connect_dialog_restore_info_bar (dialog, GTK_MESSAGE_WARNING);
+
+ content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar));
+ entry = NULL;
+
+ switch (error->code) {
+ case G_IO_ERROR_FAILED_HANDLED:
+ return;
+ case G_IO_ERROR_NOT_FOUND:
+ folder = gtk_entry_get_text (GTK_ENTRY (dialog->details->folder_entry));
+ server = gtk_entry_get_text (GTK_ENTRY (dialog->details->server_entry));
+ str = g_strdup_printf (_("The folder \"%s\" cannot be opened on \"%s\"."),
+ folder, server);
+ label = gtk_label_new (str);
+ entry = dialog->details->folder_entry;
+
+ g_free (str);
+
+ break;
+ case G_IO_ERROR_HOST_NOT_FOUND:
+ server = gtk_entry_get_text (GTK_ENTRY (dialog->details->server_entry));
+ str = g_strdup_printf (_("The server at \"%s\" cannot be found."), server);
+ label = gtk_label_new (str);
+ entry = dialog->details->server_entry;
+
+ g_free (str);
+
+ break;
+ case G_IO_ERROR_FAILED:
+ default:
+ label = gtk_label_new (error->message);
+ break;
+ }
+
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_widget_show (dialog->details->info_bar);
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 6);
+ gtk_widget_show (hbox);
+
+ icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 6);
+ gtk_widget_show (icon);
+
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6);
+ gtk_widget_show (label);
+
+ if (entry != NULL) {
+ iconize_entry (dialog, entry);
+ }
+
+ dialog->details->info_bar_content = hbox;
+
+ gtk_button_set_label (GTK_BUTTON (dialog->details->connect_button),
+ _("Try Again"));
+ gtk_widget_set_sensitive (dialog->details->connect_button, TRUE);
+}
- free_user = TRUE;
- }
- }
+static void
+connect_dialog_finish_fill (CajaConnectServerDialog *dialog)
+{
+ GAskPasswordFlags flags;
+ GMountOperation *op;
- if (folder[0] != 0 &&
- folder[0] != '/')
- {
- join = "/";
- }
- else
- {
- join = "";
- }
+ flags = dialog->details->fill_details_flags;
+ op = G_MOUNT_OPERATION (dialog->details->fill_operation);
- t = folder;
- folder = g_strconcat (initial_path, join, t, NULL);
- g_free (t);
+ if (flags & G_ASK_PASSWORD_NEED_PASSWORD) {
+ g_mount_operation_set_password (op, gtk_entry_get_text (GTK_ENTRY (dialog->details->password_entry)));
+ }
- t = folder;
- folder = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
- g_free (t);
+ if (flags & G_ASK_PASSWORD_NEED_USERNAME) {
+ g_mount_operation_set_username (op, gtk_entry_get_text (GTK_ENTRY (dialog->details->user_entry)));
+ }
- uri = g_strdup_printf ("%s://%s%s%s%s%s%s",
- meth->scheme,
- user, (user[0] != 0) ? "@" : "",
- server,
- (port[0] != 0) ? ":" : "", port,
- folder);
+ if (flags & G_ASK_PASSWORD_NEED_DOMAIN) {
+ g_mount_operation_set_domain (op, gtk_entry_get_text (GTK_ENTRY (dialog->details->domain_entry)));
+ }
- if (free_initial_path)
- {
- g_free (initial_path);
- }
- g_free (server);
- if (free_port)
- {
- g_free (port);
- }
- g_free (folder);
- if (free_user)
- {
- g_free (user);
- }
- if (free_domain)
- {
- g_free (domain);
- }
- }
+ if (flags & G_ASK_PASSWORD_SAVING_SUPPORTED &&
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->remember_checkbox))) {
+ g_mount_operation_set_password_save (op, G_PASSWORD_SAVE_PERMANENTLY);
+ }
- gtk_widget_hide (GTK_WIDGET (dialog));
+ connect_dialog_set_connecting (dialog);
- location = g_file_new_for_uri (uri);
- g_free (uri);
+ g_simple_async_result_set_op_res_gboolean (dialog->details->fill_details_res, TRUE);
+ g_simple_async_result_complete (dialog->details->fill_details_res);
- /* FIXME: sensitivity */
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->bookmark_check)))
- {
- char *name;
- CajaBookmark *bookmark;
- CajaBookmarkList *list;
- GIcon *icon;
-
- name = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->name_entry), 0, -1);
- icon = g_themed_icon_new (CAJA_ICON_FOLDER_REMOTE);
- bookmark = caja_bookmark_new (location, strlen (name) ? name : NULL,
- TRUE, icon);
- list = caja_bookmark_list_new ();
- if (!caja_bookmark_list_contains (list, bookmark))
- {
- caja_bookmark_list_append (list, bookmark);
- }
+ g_object_unref (dialog->details->fill_details_res);
+ dialog->details->fill_details_res = NULL;
- g_object_unref (bookmark);
- g_object_unref (list);
- g_object_unref (icon);
- g_free (name);
- }
+ g_object_unref (dialog->details->fill_operation);
+ dialog->details->fill_operation = NULL;
+}
- caja_connect_server_dialog_present_uri (dialog->details->application,
- location,
- GTK_WIDGET (dialog));
+static void
+connect_dialog_request_additional_details (CajaConnectServerDialog *self,
+ GAskPasswordFlags flags,
+ const gchar *default_user,
+ const gchar *default_domain)
+{
+ GtkWidget *content_area, *label, *entry, *hbox, *icon;
+
+ self->details->fill_details_flags = flags;
+
+ connect_dialog_restore_info_bar (self, GTK_MESSAGE_WARNING);
+
+ content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (self->details->info_bar));
+ entry = NULL;
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 6);
+ gtk_widget_show (hbox);
+
+ icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 6);
+ gtk_widget_show (icon);
+
+ label = gtk_label_new (_("Please verify your user details."));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6);
+ gtk_widget_show (label);
+
+ if (flags & G_ASK_PASSWORD_NEED_PASSWORD) {
+ iconize_entry (self, self->details->password_entry);
+ }
+
+ if (flags & G_ASK_PASSWORD_NEED_USERNAME) {
+ if (default_user != NULL && g_strcmp0 (default_user, "") != 0) {
+ gtk_entry_set_text (GTK_ENTRY (self->details->user_entry),
+ default_user);
+ } else {
+ iconize_entry (self, self->details->user_entry);
+ }
+ }
+
+ if (flags & G_ASK_PASSWORD_NEED_DOMAIN) {
+ if (default_domain != NULL && g_strcmp0 (default_domain, "") != 0) {
+ gtk_entry_set_text (GTK_ENTRY (self->details->domain_entry),
+ default_domain);
+ } else {
+ iconize_entry (self, self->details->domain_entry);
+ }
+ }
+
+ self->details->info_bar_content = hbox;
+
+ gtk_widget_set_sensitive (self->details->connect_button, TRUE);
+ gtk_button_set_label (GTK_BUTTON (self->details->connect_button),
+ _("Continue"));
+
+ if (!(flags & G_ASK_PASSWORD_SAVING_SUPPORTED)) {
+ g_signal_handler_disconnect (self->details->password_entry,
+ self->details->password_sensitive_id);
+ self->details->password_sensitive_id = 0;
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->details->remember_checkbox),
+ FALSE);
+ gtk_widget_set_sensitive (self->details->remember_checkbox, FALSE);
+ }
}
static void
-response_callback (CajaConnectServerDialog *dialog,
- int response_id,
- gpointer data)
+display_location_async_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
{
- GError *error;
+ CajaConnectServerDialog *dialog;
+ GError *error;
- switch (response_id)
- {
- case RESPONSE_CONNECT:
- connect_to_server (dialog);
- break;
- case GTK_RESPONSE_NONE:
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CANCEL:
- gtk_widget_destroy (GTK_WIDGET (dialog));
- break;
- case GTK_RESPONSE_HELP :
- error = NULL;
- gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog)),
- "ghelp:user-guide#caja-server-connect",
- gtk_get_current_event_time (), &error);
- if (error)
- {
- eel_show_error_dialog (_("There was an error displaying help."), error->message,
- GTK_WINDOW (dialog));
- g_error_free (error);
- }
- break;
- default :
- g_assert_not_reached ();
- }
+ dialog = CAJA_CONNECT_SERVER_DIALOG (source);
+ error = NULL;
+
+ caja_connect_server_dialog_display_location_finish (dialog,
+ res, &error);
+
+ if (error != NULL) {
+ connect_dialog_set_info_bar_error (dialog, error);
+ g_error_free (error);
+ } else {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
}
static void
-caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class)
+mount_enclosing_ready_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
{
- GObjectClass *gobject_class;
- GtkObjectClass *object_class;
+ GFile *location;
+ CajaConnectServerDialog *dialog;
+ GError *error;
+
+ error = NULL;
+ location = G_FILE (source);
+ dialog = user_data;
+
+ g_file_mount_enclosing_volume_finish (location, res, &error);
+
+ if (!error || g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED)) {
+ /* volume is mounted, show it */
+ caja_connect_server_dialog_display_location_async (dialog,
+ dialog->details->application, location,
+ display_location_async_cb, NULL);
+ } else {
+ if (dialog->details->should_destroy) {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ } else {
+ connect_dialog_set_info_bar_error (dialog, error);
+ }
+ }
+
+ if (error != NULL) {
+ g_error_free (error);
+ }
+}
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = caja_connect_server_dialog_finalize;
+static void
+connect_dialog_present_uri_async (CajaConnectServerDialog *self,
+ CajaApplication *application,
+ GFile *location)
+{
+ GMountOperation *op;
- object_class = GTK_OBJECT_CLASS (class);
- object_class->destroy = caja_connect_server_dialog_destroy;
+ op = caja_connect_server_operation_new (self);
+ g_file_mount_enclosing_volume (location,
+ 0, op, NULL,
+ mount_enclosing_ready_cb, self);
+ g_object_unref (op);
}
static void
-setup_for_type (CajaConnectServerDialog *dialog)
+connect_dialog_connect_to_server (CajaConnectServerDialog *dialog)
{
struct MethodInfo *meth;
- int index, i;
- GtkWidget *label, *table;
+ GFile *location;
+ int index;
GtkTreeIter iter;
+ char *user, *initial_path, *server, *folder, *domain, *port_str;
+ char *t, *join, *uri;
+ double port;
/* Get our method info */
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), &iter);
@@ -428,483 +531,394 @@ setup_for_type (CajaConnectServerDialog *dialog)
g_assert (index < G_N_ELEMENTS (methods) && index >= 0);
meth = &(methods[index]);
- if (gtk_widget_get_parent (dialog->details->uri_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->uri_entry);
- }
- if (gtk_widget_get_parent (dialog->details->server_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->server_entry);
- }
- if (gtk_widget_get_parent (dialog->details->share_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->share_entry);
- }
- if (gtk_widget_get_parent (dialog->details->port_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->port_entry);
- }
- if (gtk_widget_get_parent (dialog->details->folder_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->folder_entry);
- }
- if (gtk_widget_get_parent (dialog->details->user_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->user_entry);
- }
- if (gtk_widget_get_parent (dialog->details->domain_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->domain_entry);
- }
- if (gtk_widget_get_parent (dialog->details->bookmark_check) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->bookmark_check);
- }
- if (gtk_widget_get_parent (dialog->details->name_entry) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (dialog->details->table),
- dialog->details->name_entry);
- }
- /* Destroy all labels */
- gtk_container_foreach (GTK_CONTAINER (dialog->details->table),
- (GtkCallback) gtk_widget_destroy, NULL);
+ server = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->server_entry), 0, -1);
+ user = NULL;
+ initial_path = g_strdup ("");
+ domain = NULL;
+ folder = NULL;
- i = 1;
- table = dialog->details->table;
+ /* FTP special case */
+ if (meth->flags & IS_ANONYMOUS) {
+ user = g_strdup ("anonymous");
- if (meth->scheme == NULL)
- {
- label = gtk_label_new_with_mnemonic (_("_Location (URI):"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->uri_entry);
- gtk_widget_show (dialog->details->uri_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->uri_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
-
- i++;
-
- goto connection_name;
- }
+ /* SMB special case */
+ } else if (strcmp (meth->scheme, "smb") == 0) {
+ g_free (initial_path);
- label = gtk_label_new_with_mnemonic (_("_Server:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->server_entry);
- gtk_widget_show (dialog->details->server_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->server_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
-
- i++;
+ t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->share_entry), 0, -1);
+ initial_path = g_strconcat ("/", t, NULL);
- label = gtk_label_new (_("Optional information:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 2,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-
- i++;
-
- if (meth->flags & SHOW_SHARE)
- {
- label = gtk_label_new_with_mnemonic (_("_Share:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->share_entry);
- gtk_widget_show (dialog->details->share_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->share_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
-
- i++;
+ g_free (t);
}
- if (meth->flags & SHOW_PORT)
- {
- label = gtk_label_new_with_mnemonic (_("_Port:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->port_entry);
- gtk_widget_show (dialog->details->port_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->port_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
-
- i++;
+ /* username */
+ if (!user) {
+ t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->user_entry), 0, -1);
+ user = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO, FALSE);
+ g_free (t);
}
- label = gtk_label_new_with_mnemonic (_("_Folder:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
+ /* domain */
+ domain = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->domain_entry), 0, -1);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->folder_entry);
- gtk_widget_show (dialog->details->folder_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->folder_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
-
- i++;
+ if (strlen (domain) != 0) {
+ t = user;
- if (meth->flags & SHOW_USER)
- {
- label = gtk_label_new_with_mnemonic (_("_User Name:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->user_entry);
- gtk_widget_show (dialog->details->user_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->user_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
-
- i++;
+ user = g_strconcat (domain , ";" , t, NULL);
+ g_free (t);
}
- if (meth->flags & SHOW_DOMAIN)
- {
- label = gtk_label_new_with_mnemonic (_("_Domain Name:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->domain_entry);
- gtk_widget_show (dialog->details->domain_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->domain_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
-
- i++;
+ /* folder */
+ folder = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->folder_entry), 0, -1);
+
+ if (folder[0] != 0 &&
+ folder[0] != '/') {
+ join = "/";
+ } else {
+ join = "";
}
+ t = folder;
+ folder = g_strconcat (initial_path, join, t, NULL);
+ g_free (t);
+ t = folder;
+ folder = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
+ g_free (t);
-connection_name:
+ /* port */
+ port = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->details->port_spinbutton));
- gtk_widget_show (dialog->details->bookmark_check);
- gtk_table_attach (GTK_TABLE (table), dialog->details->bookmark_check,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
- i++;
+ if (port != 0 && port != meth->default_port) {
+ port_str = g_strdup_printf ("%d", (int) port);
+ } else {
+ port_str = NULL;
+ }
- label = gtk_label_new_with_mnemonic (_("Bookmark _name:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1,
- i, i+1,
- GTK_FILL, GTK_FILL,
- 0, 0);
+ /* final uri */
+ uri = g_strdup_printf ("%s://%s%s%s%s%s%s",
+ meth->scheme,
+ (user != NULL) ? user : "",
+ (user[0] != 0) ? "@" : "",
+ server,
+ (port_str != NULL) ? ":" : "",
+ (port_str != NULL) ? port_str : "",
+ (folder != NULL) ? folder : "");
+
+ g_free (initial_path);
+ g_free (server);
+ g_free (folder);
+ g_free (user);
+ g_free (domain);
+ g_free (port_str);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->name_entry);
- gtk_widget_show (dialog->details->name_entry);
- gtk_table_attach (GTK_TABLE (table), dialog->details->name_entry,
- 1, 2,
- i, i+1,
- GTK_FILL | GTK_EXPAND, GTK_FILL,
- 0, 0);
+ location = g_file_new_for_uri (uri);
+ g_free (uri);
- i++;
+ connect_dialog_set_connecting (dialog);
+ connect_dialog_present_uri_async (dialog,
+ dialog->details->application,
+ location);
+ g_object_unref (location);
}
static void
-display_server_location (CajaConnectServerDialog *dialog, GFile *location)
+connect_to_server_or_finish_fill (CajaConnectServerDialog *dialog)
{
-#if 0 /*FIXME */
- struct MethodInfo *meth = NULL;
- char *scheme;
- int i, index = 0;
- char *folder;
- const char *t;
+ if (dialog->details->fill_details_res != NULL) {
+ connect_dialog_finish_fill (dialog);
+ } else {
+ connect_dialog_connect_to_server (dialog);
+ }
+}
- /* Find an appropriate method */
- scheme = g_file_get_uri_scheme (location);
- g_return_if_fail (scheme != NULL);
+static gboolean
+connect_dialog_abort_mount_operation (CajaConnectServerDialog *dialog)
+{
+ if (dialog->details->fill_details_res != NULL) {
+ g_simple_async_result_set_op_res_gboolean (dialog->details->fill_details_res, FALSE);
+ g_simple_async_result_complete (dialog->details->fill_details_res);
- for (i = 0; i < G_N_ELEMENTS (methods); i++)
- {
-
- /* The default is 'Custom URI' */
- if (methods[i].scheme == NULL)
- {
- meth = &(methods[i]);
- index = i;
+ g_object_unref (dialog->details->fill_details_res);
+ dialog->details->fill_details_res = NULL;
+ if (dialog->details->fill_operation) {
+ g_object_unref (dialog->details->fill_operation);
+ dialog->details->fill_operation = NULL;
}
- else if (strcmp (methods[i].scheme, scheme) == 0)
- {
- /* FTP Special case: If no user keep searching for public ftp */
- if (strcmp (scheme, "ftp") == 0)
- {
- t = mate_vfs_uri_get_user_name (uri);
- if ((!t || !t[0] || strcmp (t, "anonymous") == 0) &&
- (!(methods[i].flags & IS_ANONYMOUS)))
- {
- continue;
- }
- }
-
- meth = &(methods[i]);
- index = i;
- break;
- }
+ return TRUE;
}
- g_free (scheme);
- g_assert (meth);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->details->type_combo), index);
- setup_for_type (dialog);
+ return FALSE;
+}
- /* Custom URI */
- if (meth->scheme == NULL)
- {
- gchar *uri;
+static void
+connect_dialog_destroy (CajaConnectServerDialog *dialog)
+{
+ if (connect_dialog_abort_mount_operation (dialog)) {
+ dialog->details->should_destroy = TRUE;
+ } else {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
+}
- /* FIXME: with mate-vfs, we had MATE_VFS_URI_HIDE_PASSWORD |
- * MATE_VFS_URI_HIDE_FRAGMENT_IDENTIFIER */
- uri = g_file_get_uri (location)
- gtk_entry_set_text (GTK_ENTRY (dialog->details->uri_entry), uri);
- g_free (uri);
+static void
+connect_dialog_response_cb (CajaConnectServerDialog *dialog,
+ int response_id,
+ gpointer data)
+{
+ GError *error;
- }
- else
+ switch (response_id)
{
-
- folder = g_file_get_path (location);
- if (!folder)
- {
- folder = "";
- }
- else if (folder[0] == '/')
+ case RESPONSE_CONNECT:
+ connect_to_server_or_finish_fill (dialog);
+ break;
+ case GTK_RESPONSE_NONE:
+ case GTK_RESPONSE_DELETE_EVENT:
+ case GTK_RESPONSE_CANCEL:
+ connect_dialog_destroy (dialog);
+ break;
+ case GTK_RESPONSE_HELP :
+ error = NULL;
+ gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog)),
+ "ghelp:user-guide#caja-server-connect",
+ gtk_get_current_event_time (), &error);
+ if (error)
{
- folder++;
+ eel_show_error_dialog (_("There was an error displaying help."), error->message,
+ GTK_WINDOW (dialog));
+ g_error_free (error);
}
+ break;
+ default :
+ g_assert_not_reached ();
+ }
+}
- /* Server */
- t = mate_vfs_uri_get_host_name (uri);
- gtk_entry_set_text (GTK_ENTRY (dialog->details->server_entry),
- t ? t : "");
+static void
+connect_dialog_cleanup (CajaConnectServerDialog *dialog)
+{
+ /* hide the infobar */
+ gtk_widget_hide (dialog->details->info_bar);
+
+ /* set the connect button label back to 'Connect' */
+ gtk_button_set_label (GTK_BUTTON (dialog->details->connect_button),
+ _("C_onnect"));
+
+ /* if there was a pending mount operation, cancel it. */
+ connect_dialog_abort_mount_operation (dialog);
+
+ /* restore password checkbox sensitivity */
+ if (dialog->details->password_sensitive_id == 0) {
+ dialog->details->password_sensitive_id =
+ g_signal_connect (dialog->details->password_entry, "changed",
+ G_CALLBACK (sensitive_entry_changed_callback),
+ dialog->details->remember_checkbox);
+ sensitive_entry_changed_callback (GTK_EDITABLE (dialog->details->password_entry),
+ dialog->details->remember_checkbox);
+ }
+
+ /* remove icons on the entries */
+ g_list_foreach (dialog->details->iconized_entries,
+ (GFunc) iconized_entry_restore, dialog);
+ g_list_free (dialog->details->iconized_entries);
+ dialog->details->iconized_entries = NULL;
+
+ dialog->details->last_password_set = FALSE;
+}
- /* Share */
- if (meth->flags & SHOW_SHARE)
- {
- t = strchr (folder, '/');
- if (t)
- {
- char *share = g_strndup (folder, t - folder);
- gtk_entry_set_text (GTK_ENTRY (dialog->details->share_entry), share);
- g_free (share);
- folder = t + 1;
- }
+static void
+connect_dialog_setup_for_type (CajaConnectServerDialog *dialog)
+{
+ struct MethodInfo *meth;
+ int index;
+ GtkTreeIter iter;
- }
+ connect_dialog_cleanup (dialog);
- /* Port */
- if (meth->flags & SHOW_PORT)
- {
- guint port = mate_vfs_uri_get_host_port (uri);
- if (port != 0)
- {
- char sport[32];
- g_snprintf (sport, sizeof (sport), "%d", port);
- gtk_entry_set_text (GTK_ENTRY (dialog->details->port_entry), sport);
- }
- }
+ /* get our method info */
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo),
+ &iter)) {
+ /* there are no entries in the combo, something is wrong
+ * with our GVfs installation.
+ */
+ connect_dialog_gvfs_error (dialog);
- /* Folder */
- gtk_entry_set_text (GTK_ENTRY (dialog->details->folder_entry), folder);
- g_free (folder);
+ return;
+ }
- /* User */
- if (meth->flags & SHOW_USER)
- {
- const char *user = mate_vfs_uri_get_user_name (uri);
- if (user)
- {
- t = strchr (user, ';');
- if (t)
- {
- user = t + 1;
- }
- gtk_entry_set_text (GTK_ENTRY (dialog->details->user_entry), user);
- }
- }
+ gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->details->type_combo)),
+ &iter, 0, &index, -1);
+ g_assert (index < G_N_ELEMENTS (methods) && index >= 0);
+ meth = &(methods[index]);
- /* Domain */
- if (meth->flags & SHOW_DOMAIN)
- {
- const char *user = mate_vfs_uri_get_user_name (uri);
- if (user)
- {
- t = strchr (user, ';');
- if (t)
- {
- char *domain = g_strndup (user, t - user);
- gtk_entry_set_text (GTK_ENTRY (dialog->details->domain_entry), domain);
- g_free (domain);
- }
- }
- }
- }
-#endif
+ g_object_set (dialog->details->share_entry,
+ "visible",
+ (meth->flags & SHOW_SHARE) != 0,
+ NULL);
+
+ g_object_set (dialog->details->port_spinbutton,
+ "sensitive",
+ (meth->flags & SHOW_PORT) != 0,
+ "value", (gdouble) meth->default_port,
+ NULL);
+
+ g_object_set (dialog->details->user_details,
+ "visible",
+ (meth->flags & SHOW_USER) != 0 ||
+ (meth->flags & SHOW_DOMAIN) != 0,
+ NULL);
+
+ g_object_set (dialog->details->user_entry,
+ "visible",
+ (meth->flags & SHOW_USER) != 0,
+ NULL);
+
+ g_object_set (dialog->details->password_entry,
+ "visible",
+ (meth->flags & SHOW_USER) != 0,
+ NULL);
+
+ g_object_set (dialog->details->domain_entry,
+ "visible",
+ (meth->flags & SHOW_DOMAIN) != 0,
+ NULL);
}
static void
-combo_changed_callback (GtkComboBox *combo_box,
- CajaConnectServerDialog *dialog)
+sensitive_entry_changed_callback (GtkEditable *editable,
+ GtkWidget *widget)
{
- setup_for_type (dialog);
-}
+ guint length;
-static void
-port_insert_text (GtkEditable *editable,
- const gchar *new_text,
- gint new_text_length,
- gint *position)
-{
- int pos;
+ length = gtk_entry_get_text_length (GTK_ENTRY (editable));
- if (new_text_length < 0)
- {
- new_text_length = strlen (new_text);
- }
-
- /* Only allow digits to be inserted as port number */
- for (pos = 0; pos < new_text_length; pos++)
- {
- if (!g_ascii_isdigit (new_text[pos]))
- {
- GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (editable));
- if (toplevel != NULL)
- {
- gdk_window_beep (gtk_widget_get_window (toplevel));
- }
- g_signal_stop_emission_by_name (editable, "insert_text");
- return;
- }
- }
+ gtk_widget_set_sensitive (widget, length > 0);
}
static void
-bookmark_checkmark_toggled (GtkToggleButton *toggle, CajaConnectServerDialog *dialog)
+bind_visibility (CajaConnectServerDialog *dialog,
+ GtkWidget *source,
+ GtkWidget *dest)
{
- gtk_widget_set_sensitive (GTK_WIDGET(dialog->details->name_entry),
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle)));
+ g_object_bind_property (source,
+ "visible",
+ dest,
+ "visible",
+ G_BINDING_DEFAULT);
}
static void
caja_connect_server_dialog_init (CajaConnectServerDialog *dialog)
{
GtkWidget *label;
- GtkWidget *table;
- GtkWidget *combo;
- GtkWidget *hbox;
- GtkWidget *vbox;
+ GtkWidget *alignment;
+ GtkWidget *content_area;
+ GtkWidget *combo ,* table;
+ GtkWidget *hbox, *connect_button, *checkbox;
GtkListStore *store;
GtkCellRenderer *renderer;
+ gchar *str;
int i;
- dialog->details = g_new0 (CajaConnectServerDialogDetails, 1);
+ dialog->details = G_TYPE_INSTANCE_GET_PRIVATE (dialog, CAJA_TYPE_CONNECT_SERVER_DIALOG,
+ CajaConnectServerDialogDetails);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ /* set dialog properties */
gtk_window_set_title (GTK_WINDOW (dialog), _("Connect to Server"));
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
+ gtk_box_set_spacing (GTK_BOX (content_area), 2);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- vbox, FALSE, TRUE, 0);
- gtk_widget_show (vbox);
+ /* infobar */
+ dialog->details->info_bar = gtk_info_bar_new ();
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (dialog->details->info_bar),
+ GTK_MESSAGE_INFO);
+ gtk_box_pack_start (GTK_BOX (content_area), dialog->details->info_bar,
+ FALSE, FALSE, 6);
+
+ /* server settings label */
+ label = gtk_label_new (NULL);
+ str = g_strdup_printf ("<b>%s</b>", _("Server Details"));
+ gtk_label_set_markup (GTK_LABEL (label), str);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 6);
+ gtk_widget_show (label);
+
+ /* server settings alignment */
+ alignment = gtk_alignment_new (0, 0, 0, 0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
+ 0, 0, 12, 0);
+ gtk_box_pack_start (GTK_BOX (content_area), alignment, TRUE, TRUE, 0);
+ gtk_widget_show (alignment);
+
+ table = gtk_table_new (4, 2, FALSE);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+ gtk_widget_show (table);
+
+ dialog->details->primary_table = table;
+
+ /* first row: server entry + port spinbutton */
+ label = gtk_label_new_with_mnemonic (_("_Server:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label,
+ 0, 1,
+ 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
+ gtk_widget_show (label);
hbox = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox),
- hbox, FALSE, TRUE, 0);
gtk_widget_show (hbox);
+ gtk_table_attach (GTK_TABLE (table), hbox,
+ 1, 2,
+ 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
- label = gtk_label_new_with_mnemonic (_("Service _type:"));
+ dialog->details->server_entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->server_entry), TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->details->server_entry, FALSE, FALSE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->server_entry);
+ gtk_widget_show (dialog->details->server_entry);
+
+ /* port */
+ label = gtk_label_new_with_mnemonic (_("_Port:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ dialog->details->port_spinbutton =
+ gtk_spin_button_new_with_range (0.0, 65535.0, 1.0);
+ g_object_set (dialog->details->port_spinbutton,
+ "digits", 0,
+ "numeric", TRUE,
+ "update-policy", GTK_UPDATE_IF_VALID,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->details->port_spinbutton,
+ FALSE, FALSE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->port_spinbutton);
+ gtk_widget_show (dialog->details->port_spinbutton);
+
+ /* second row: type combobox */
+ label = gtk_label_new (_("Type:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label,
+ 0, 1,
+ 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox),
- label, FALSE, FALSE, 0);
dialog->details->type_combo = combo = gtk_combo_box_new ();
/* each row contains: method index, textual description */
store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
- g_object_unref (G_OBJECT (store));
+ g_object_unref (store);
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
@@ -916,7 +930,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog)
const gchar * const *supported;
int j;
- /* skip methods that don't have corresponding MateVFSMethods */
+ /* skip methods that don't have corresponding gvfs uri schemes */
supported = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
if (methods[i].scheme != NULL)
@@ -960,72 +974,129 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog)
gtk_widget_show (combo);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
- gtk_box_pack_start (GTK_BOX (hbox),
- combo, TRUE, TRUE, 0);
- g_signal_connect (combo, "changed",
- G_CALLBACK (combo_changed_callback),
- dialog);
+ gtk_table_attach (GTK_TABLE (table), combo,
+ 1, 2,
+ 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND, 6, 3);
+ g_signal_connect_swapped (combo, "changed",
+ G_CALLBACK (connect_dialog_setup_for_type),
+ dialog);
+
+ /* third row: share entry */
+ label = gtk_label_new (_("Share:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label,
+ 0, 1,
+ 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
+ dialog->details->share_entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->share_entry), TRUE);
+ gtk_table_attach (GTK_TABLE (table), dialog->details->share_entry,
+ 1, 2,
+ 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox),
- hbox, FALSE, TRUE, 0);
- gtk_widget_show (hbox);
+ bind_visibility (dialog, dialog->details->share_entry, label);
- label = gtk_label_new_with_mnemonic (" ");
+ /* fourth row: folder entry */
+ label = gtk_label_new (_("Folder:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label,
+ 0, 1,
+ 3, 4,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox),
- label, FALSE, FALSE, 0);
+ dialog->details->folder_entry = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (dialog->details->folder_entry), "/");
+ gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->folder_entry), TRUE);
+ gtk_table_attach (GTK_TABLE (table), dialog->details->folder_entry,
+ 1, 2,
+ 3, 4,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
+ gtk_widget_show (dialog->details->folder_entry);
+
+ /* user details label */
+ label = gtk_label_new (NULL);
+ str = g_strdup_printf ("<b>%s</b>", _("User Details"));
+ gtk_label_set_markup (GTK_LABEL (label), str);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 6);
+ /* user details alignment */
+ alignment = gtk_alignment_new (0, 0, 0, 0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
+ 0, 0, 12, 0);
+ gtk_box_pack_start (GTK_BOX (content_area), alignment, TRUE, TRUE, 0);
- dialog->details->table = table = gtk_table_new (5, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+ bind_visibility (dialog, alignment, label);
+ dialog->details->user_details = alignment;
+
+ table = gtk_table_new (4, 2, FALSE);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
gtk_widget_show (table);
- gtk_box_pack_start (GTK_BOX (hbox),
- table, TRUE, TRUE, 0);
- dialog->details->uri_entry = caja_location_entry_new ();
- /* hide the clean icon, as it doesn't make sense here */
- g_object_set (dialog->details->uri_entry, "secondary-icon-name", NULL, NULL);
- dialog->details->server_entry = gtk_entry_new ();
- dialog->details->share_entry = gtk_entry_new ();
- dialog->details->port_entry = gtk_entry_new ();
- g_signal_connect (dialog->details->port_entry, "insert_text", G_CALLBACK (port_insert_text),
- NULL);
- dialog->details->folder_entry = gtk_entry_new ();
+ /* first row: domain entry */
+ label = gtk_label_new (_("Domain Name:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label,
+ 0, 1,
+ 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
+
dialog->details->domain_entry = gtk_entry_new ();
- dialog->details->user_entry = gtk_entry_new ();
- dialog->details->bookmark_check = gtk_check_button_new_with_mnemonic (_("Add _bookmark"));
- dialog->details->name_entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->domain_entry), TRUE);
+ gtk_table_attach (GTK_TABLE (table), dialog->details->domain_entry,
+ 1, 2,
+ 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
- g_signal_connect (dialog->details->bookmark_check, "toggled",
- G_CALLBACK (bookmark_checkmark_toggled), dialog);
+ bind_visibility (dialog, dialog->details->domain_entry, label);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->details->bookmark_check), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET(dialog->details->name_entry), FALSE);
+ /* second row: username entry */
+ label = gtk_label_new (_("User Name:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label,
+ 0, 1,
+ 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->uri_entry), TRUE);
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->server_entry), TRUE);
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->share_entry), TRUE);
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->port_entry), TRUE);
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->folder_entry), TRUE);
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->domain_entry), TRUE);
+ dialog->details->user_entry = gtk_entry_new ();
gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->user_entry), TRUE);
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->name_entry), TRUE);
+ gtk_table_attach (GTK_TABLE (table), dialog->details->user_entry,
+ 1, 2,
+ 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
- /* We need an extra ref so we can remove them from the table */
- g_object_ref (dialog->details->uri_entry);
- g_object_ref (dialog->details->server_entry);
- g_object_ref (dialog->details->share_entry);
- g_object_ref (dialog->details->port_entry);
- g_object_ref (dialog->details->folder_entry);
- g_object_ref (dialog->details->domain_entry);
- g_object_ref (dialog->details->user_entry);
- g_object_ref (dialog->details->bookmark_check);
- g_object_ref (dialog->details->name_entry);
+ bind_visibility (dialog, dialog->details->user_entry, label);
- setup_for_type (dialog);
+ /* third row: password entry */
+ label = gtk_label_new (_("Password:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label,
+ 0, 1,
+ 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
+
+ dialog->details->password_entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->password_entry), TRUE);
+ gtk_entry_set_visibility (GTK_ENTRY (dialog->details->password_entry), FALSE);
+ gtk_table_attach (GTK_TABLE (table), dialog->details->password_entry,
+ 1, 2,
+ 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3);
+
+ bind_visibility (dialog, dialog->details->password_entry, label);
+
+ /* fourth row: remember checkbox */
+ checkbox = gtk_check_button_new_with_label (_("Remember this password"));
+ gtk_table_attach (GTK_TABLE (table), checkbox,
+ 1, 2,
+ 3, 4,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 0);
+ dialog->details->remember_checkbox = checkbox;
+
+ bind_visibility (dialog, dialog->details->password_entry, checkbox);
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_HELP,
@@ -1033,21 +1104,56 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog)
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("C_onnect"),
- RESPONSE_CONNECT);
+ connect_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("C_onnect"),
+ RESPONSE_CONNECT);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
RESPONSE_CONNECT);
+ dialog->details->connect_button = connect_button;
+
+ g_signal_connect (dialog->details->server_entry, "changed",
+ G_CALLBACK (sensitive_entry_changed_callback),
+ connect_button);
+ sensitive_entry_changed_callback (GTK_EDITABLE (dialog->details->server_entry),
+ connect_button);
g_signal_connect (dialog, "response",
- G_CALLBACK (response_callback),
+ G_CALLBACK (connect_dialog_response_cb),
dialog);
+ connect_dialog_setup_for_type (dialog);
+}
+static void
+caja_connect_server_dialog_finalize (GObject *object)
+{
+ CajaConnectServerDialog *dialog;
+
+ dialog = CAJA_CONNECT_SERVER_DIALOG (object);
+
+ connect_dialog_abort_mount_operation (dialog);
+
+ if (dialog->details->iconized_entries != NULL) {
+ g_list_free (dialog->details->iconized_entries);
+ dialog->details->iconized_entries = NULL;
+ }
+
+ G_OBJECT_CLASS (caja_connect_server_dialog_parent_class)->finalize (object);
+}
+
+static void
+caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class)
+{
+ GObjectClass *oclass;
+
+ oclass = G_OBJECT_CLASS (class);
+ oclass->finalize = caja_connect_server_dialog_finalize;
+
+ g_type_class_add_private (class, sizeof (CajaConnectServerDialogDetails));
}
GtkWidget *
-caja_connect_server_dialog_new (CajaWindow *window, GFile *location)
+caja_connect_server_dialog_new (CajaWindow *window)
{
CajaConnectServerDialog *conndlg;
GtkWidget *dialog;
@@ -1062,14 +1168,84 @@ caja_connect_server_dialog_new (CajaWindow *window, GFile *location)
conndlg->details->application = window->application;
}
- if (location)
- {
- /* If it's a remote URI, then load as the default */
- if (!g_file_is_native (location))
- {
- display_server_location (conndlg, location);
- }
- }
-
return dialog;
}
+
+gboolean
+caja_connect_server_dialog_fill_details_finish (CajaConnectServerDialog *self,
+ GAsyncResult *result)
+{
+ return g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (result));
+}
+
+void
+caja_connect_server_dialog_fill_details_async (CajaConnectServerDialog *self,
+ GMountOperation *operation,
+ const gchar *default_user,
+ const gchar *default_domain,
+ GAskPasswordFlags flags,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *fill_details_res;
+ const gchar *str;
+ GAskPasswordFlags set_flags;
+
+ fill_details_res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+ caja_connect_server_dialog_fill_details_async);
+
+ self->details->fill_details_res = fill_details_res;
+ set_flags = (flags & G_ASK_PASSWORD_NEED_PASSWORD) |
+ (flags & G_ASK_PASSWORD_NEED_USERNAME) |
+ (flags & G_ASK_PASSWORD_NEED_DOMAIN);
+
+ if (set_flags & G_ASK_PASSWORD_NEED_PASSWORD) {
+ /* provide the password */
+ str = gtk_entry_get_text (GTK_ENTRY (self->details->password_entry));
+
+ if (str != NULL && g_strcmp0 (str, "") != 0 &&
+ !self->details->last_password_set) {
+ g_mount_operation_set_password (G_MOUNT_OPERATION (operation),
+ str);
+ set_flags ^= G_ASK_PASSWORD_NEED_PASSWORD;
+
+ self->details->last_password_set = TRUE;
+ }
+ }
+
+ if (set_flags & G_ASK_PASSWORD_NEED_USERNAME) {
+ /* see if the default username is different from ours */
+ str = gtk_entry_get_text (GTK_ENTRY (self->details->user_entry));
+
+ if (str != NULL && g_strcmp0 (str, "") != 0 &&
+ g_strcmp0 (str, default_user) != 0) {
+ g_mount_operation_set_username (G_MOUNT_OPERATION (operation),
+ str);
+ set_flags ^= G_ASK_PASSWORD_NEED_USERNAME;
+ }
+ }
+
+ if (set_flags & G_ASK_PASSWORD_NEED_DOMAIN) {
+ /* see if the default domain is different from ours */
+ str = gtk_entry_get_text (GTK_ENTRY (self->details->domain_entry));
+
+ if (str != NULL && g_strcmp0 (str, "") &&
+ g_strcmp0 (str, default_domain) != 0) {
+ g_mount_operation_set_domain (G_MOUNT_OPERATION (operation),
+ str);
+ set_flags ^= G_ASK_PASSWORD_NEED_DOMAIN;
+ }
+ }
+
+ if (set_flags != 0) {
+ set_flags |= (flags & G_ASK_PASSWORD_SAVING_SUPPORTED);
+ self->details->fill_operation = g_object_ref (operation);
+ connect_dialog_request_additional_details (self, set_flags, default_user, default_domain);
+ } else {
+ g_simple_async_result_set_op_res_gboolean (fill_details_res, TRUE);
+ g_simple_async_result_complete (fill_details_res);
+ g_object_unref (self->details->fill_details_res);
+
+ self->details->fill_details_res = NULL;
+ }
+}
diff --git a/src/caja-connect-server-dialog.h b/src/caja-connect-server-dialog.h
index 135df55f..1876e8a9 100644
--- a/src/caja-connect-server-dialog.h
+++ b/src/caja-connect-server-dialog.h
@@ -1,9 +1,9 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
/*
* Caja
*
* Copyright (C) 2003 Red Hat, Inc.
+ * Copyright (C) 2010 Cosimo Cecchi <[email protected]>
*
* Caja is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -26,15 +26,22 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
+
#include "caja-window.h"
-#define CAJA_TYPE_CONNECT_SERVER_DIALOG (caja_connect_server_dialog_get_type ())
-#define CAJA_CONNECT_SERVER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG, CajaConnectServerDialog))
-#define CAJA_CONNECT_SERVER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CONNECT_SERVER_DIALOG, CajaConnectServerDialogClass))
-#define CAJA_IS_CONNECT_SERVER_DIALOG(obj) (G_TYPE_INSTANCE_CHECK_TYPE ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG)
+#define CAJA_TYPE_CONNECT_SERVER_DIALOG\
+ (caja_connect_server_dialog_get_type ())
+#define CAJA_CONNECT_SERVER_DIALOG(obj)\
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG,\
+ CajaConnectServerDialog))
+#define CAJA_CONNECT_SERVER_DIALOG_CLASS(klass)\
+ (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CONNECT_SERVER_DIALOG,\
+ CajaConnectServerDialogClass))
+#define CAJA_IS_CONNECT_SERVER_DIALOG(obj)\
+ (G_TYPE_INSTANCE_CHECK_TYPE ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG)
-typedef struct _CajaConnectServerDialog CajaConnectServerDialog;
-typedef struct _CajaConnectServerDialogClass CajaConnectServerDialogClass;
+typedef struct _CajaConnectServerDialog CajaConnectServerDialog;
+typedef struct _CajaConnectServerDialogClass CajaConnectServerDialogClass;
typedef struct _CajaConnectServerDialogDetails CajaConnectServerDialogDetails;
struct _CajaConnectServerDialog
@@ -48,14 +55,27 @@ struct _CajaConnectServerDialogClass
GtkDialogClass parent_class;
};
-GType caja_connect_server_dialog_get_type (void);
-GtkWidget* caja_connect_server_dialog_new (CajaWindow *window,
- GFile *location);
+GType caja_connect_server_dialog_get_type (void);
+
+GtkWidget* caja_connect_server_dialog_new (CajaWindow *window);
-/* Private internal calls */
+void caja_connect_server_dialog_display_location_async (CajaConnectServerDialog *self,
+ CajaApplication *application,
+ GFile *location,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean caja_connect_server_dialog_display_location_finish (CajaConnectServerDialog *self,
+ GAsyncResult *result,
+ GError **error);
-void caja_connect_server_dialog_present_uri (CajaApplication *application,
- GFile *location,
- GtkWidget *widget);
+void caja_connect_server_dialog_fill_details_async (CajaConnectServerDialog *self,
+ GMountOperation *operation,
+ const gchar *default_user,
+ const gchar *default_domain,
+ GAskPasswordFlags flags,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean caja_connect_server_dialog_fill_details_finish (CajaConnectServerDialog *self,
+ GAsyncResult *result);
#endif /* CAJA_CONNECT_SERVER_DIALOG_H */
diff --git a/src/caja-connect-server-operation.c b/src/caja-connect-server-operation.c
new file mode 100644
index 00000000..51b69b84
--- /dev/null
+++ b/src/caja-connect-server-operation.c
@@ -0,0 +1,140 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Caja
+ *
+ * Copyright (C) 2010 Cosimo Cecchi <[email protected]>
+ *
+ * Caja 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.
+ *
+ * Caja 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; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Cosimo Cecchi <[email protected]>
+ */
+
+#include <config.h>
+
+#include "caja-connect-server-operation.h"
+
+#include "caja-connect-server-dialog.h"
+
+G_DEFINE_TYPE (CajaConnectServerOperation,
+ caja_connect_server_operation, GTK_TYPE_MOUNT_OPERATION);
+
+enum {
+ PROP_DIALOG = 1,
+ NUM_PROPERTIES
+};
+
+struct _CajaConnectServerOperationDetails {
+ CajaConnectServerDialog *dialog;
+};
+
+static void
+fill_details_async_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ CajaConnectServerDialog *dialog;
+ CajaConnectServerOperation *self;
+ gboolean res;
+
+ self = user_data;
+ dialog = CAJA_CONNECT_SERVER_DIALOG (source);
+
+ res = caja_connect_server_dialog_fill_details_finish (dialog, result);
+
+ if (!res) {
+ g_mount_operation_reply (G_MOUNT_OPERATION (self), G_MOUNT_OPERATION_ABORTED);
+ } else {
+ g_mount_operation_reply (G_MOUNT_OPERATION (self), G_MOUNT_OPERATION_HANDLED);
+ }
+}
+
+static void
+caja_connect_server_operation_ask_password (GMountOperation *op,
+ const gchar *message,
+ const gchar *default_user,
+ const gchar *default_domain,
+ GAskPasswordFlags flags)
+{
+ CajaConnectServerOperation *self;
+
+ self = CAJA_CONNECT_SERVER_OPERATION (op);
+
+ caja_connect_server_dialog_fill_details_async (self->details->dialog,
+ G_MOUNT_OPERATION (self),
+ default_user,
+ default_domain,
+ flags,
+ fill_details_async_cb,
+ self);
+}
+
+static void
+caja_connect_server_operation_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ CajaConnectServerOperation *self;
+
+ self = CAJA_CONNECT_SERVER_OPERATION (object);
+
+ switch (property_id) {
+ case PROP_DIALOG:
+ self->details->dialog = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+caja_connect_server_operation_class_init (CajaConnectServerOperationClass *klass)
+{
+ GMountOperationClass *mount_op_class;
+ GObjectClass *object_class;
+ GParamSpec *pspec;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->set_property = caja_connect_server_operation_set_property;
+
+ mount_op_class = G_MOUNT_OPERATION_CLASS (klass);
+ mount_op_class->ask_password = caja_connect_server_operation_ask_password;
+
+ pspec = g_param_spec_object ("dialog", "The connect dialog",
+ "The connect to server dialog",
+ CAJA_TYPE_CONNECT_SERVER_DIALOG,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_DIALOG, pspec);
+
+ g_type_class_add_private (klass, sizeof (CajaConnectServerOperationDetails));
+}
+
+static void
+caja_connect_server_operation_init (CajaConnectServerOperation *self)
+{
+ self->details = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ CAJA_TYPE_CONNECT_SERVER_OPERATION,
+ CajaConnectServerOperationDetails);
+}
+
+GMountOperation *
+caja_connect_server_operation_new (CajaConnectServerDialog *dialog)
+{
+ return g_object_new (CAJA_TYPE_CONNECT_SERVER_OPERATION,
+ "dialog", dialog,
+ NULL);
+}
diff --git a/src/caja-connect-server-operation.h b/src/caja-connect-server-operation.h
new file mode 100644
index 00000000..eba0283a
--- /dev/null
+++ b/src/caja-connect-server-operation.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Caja
+ *
+ * Copyright (C) 2010 Cosimo Cecchi <[email protected]>
+ *
+ * Caja 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.
+ *
+ * Caja 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; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Cosimo Cecchi <[email protected]>
+ */
+
+#ifndef __CAJA_CONNECT_SERVER_OPERATION_H__
+#define __CAJA_CONNECT_SERVER_OPERATION_H__
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+#include "caja-connect-server-dialog.h"
+
+#define CAJA_TYPE_CONNECT_SERVER_OPERATION\
+ (caja_connect_server_operation_get_type ())
+#define CAJA_CONNECT_SERVER_OPERATION(obj)\
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
+ CAJA_TYPE_CONNECT_SERVER_OPERATION,\
+ CajaConnectServerOperation))
+#define CAJA_CONNECT_SERVER_OPERATION_CLASS(klass)\
+ (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CONNECT_SERVER_OPERATION,\
+ CajaConnectServerOperationClass))
+#define CAJA_IS_CONNECT_SERVER_OPERATION(obj)\
+ (G_TYPE_INSTANCE_CHECK_TYPE ((obj), CAJA_TYPE_CONNECT_SERVER_OPERATION)
+
+typedef struct _CajaConnectServerOperationDetails
+ CajaConnectServerOperationDetails;
+
+typedef struct {
+ GtkMountOperation parent;
+ CajaConnectServerOperationDetails *details;
+} CajaConnectServerOperation;
+
+typedef struct {
+ GtkMountOperationClass parent_class;
+} CajaConnectServerOperationClass;
+
+GType caja_connect_server_operation_get_type (void);
+
+GMountOperation *
+caja_connect_server_operation_new (CajaConnectServerDialog *dialog);
+
+
+#endif /* __CAJA_CONNECT_SERVER_OPERATION_H__ */
diff --git a/src/caja-desktop-window.c b/src/caja-desktop-window.c
index 08749cc2..aabc0468 100644
--- a/src/caja-desktop-window.c
+++ b/src/caja-desktop-window.c
@@ -30,7 +30,6 @@
#include <X11/Xatom.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <eel/eel-gtk-macros.h>
#include <eel/eel-vfs-extensions.h>
#include <libcaja-private/caja-file-utilities.h>
#include <libcaja-private/caja-icon-names.h>
@@ -39,10 +38,10 @@
struct CajaDesktopWindowDetails
{
- int dummy;
-};
+ gulong size_changed_id;
-static void set_wmspec_desktop_hint (GdkWindow *window);
+ gboolean loaded;
+};
G_DEFINE_TYPE (CajaDesktopWindow, caja_desktop_window,
CAJA_TYPE_SPATIAL_WINDOW);
@@ -53,7 +52,8 @@ caja_desktop_window_init (CajaDesktopWindow *window)
GtkAction *action;
AtkObject *accessible;
- window->details = g_new0 (CajaDesktopWindowDetails, 1);
+ window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, CAJA_TYPE_DESKTOP_WINDOW,
+ CajaDesktopWindowDetails);
gtk_window_move (GTK_WINDOW (window), 0, 0);
@@ -76,8 +76,10 @@ caja_desktop_window_init (CajaDesktopWindow *window)
/* Set the accessible name so that it doesn't inherit the cryptic desktop URI. */
accessible = gtk_widget_get_accessible (GTK_WIDGET (window));
- if (accessible)
+
+ if (accessible) {
atk_object_set_name (accessible, _("Desktop"));
+ }
}
static gint
@@ -94,9 +96,10 @@ caja_desktop_window_update_directory (CajaDesktopWindow *window)
g_assert (CAJA_IS_DESKTOP_WINDOW (window));
- CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = TRUE;
location = g_file_new_for_uri (EEL_DESKTOP_URI);
caja_window_go_to (CAJA_WINDOW (window), location);
+ window->details->loaded = TRUE;
+
g_object_unref (location);
}
@@ -147,18 +150,6 @@ caja_desktop_window_new (CajaApplication *application,
}
static void
-finalize (GObject *object)
-{
- CajaDesktopWindow *window;
-
- window = CAJA_DESKTOP_WINDOW (object);
-
- g_free (window->details);
-
- G_OBJECT_CLASS (caja_desktop_window_parent_class)->finalize (object);
-}
-
-static void
map (GtkWidget *widget)
{
/* Chain up to realize our children */
@@ -166,14 +157,15 @@ map (GtkWidget *widget)
gdk_window_lower (gtk_widget_get_window (widget));
}
-
static void
unrealize (GtkWidget *widget)
{
CajaDesktopWindow *window;
+ CajaDesktopWindowDetails *details;
GdkWindow *root_window;
window = CAJA_DESKTOP_WINDOW (widget);
+ details = window->details;
root_window = gdk_screen_get_root_window (
gtk_window_get_screen (GTK_WINDOW (window)));
@@ -181,9 +173,11 @@ unrealize (GtkWidget *widget)
gdk_property_delete (root_window,
gdk_atom_intern ("CAJA_DESKTOP_WINDOW_ID", TRUE));
- g_signal_handlers_disconnect_by_func (gtk_window_get_screen (GTK_WINDOW (window)),
- G_CALLBACK (caja_desktop_window_screen_size_changed),
- window);
+ if (details->size_changed_id != 0) {
+ g_signal_handler_disconnect (gtk_window_get_screen (GTK_WINDOW (window)),
+ details->size_changed_id);
+ details->size_changed_id = 0;
+ }
GTK_WIDGET_CLASS (caja_desktop_window_parent_class)->unrealize (widget);
}
@@ -225,8 +219,10 @@ static void
realize (GtkWidget *widget)
{
CajaDesktopWindow *window;
+ CajaDesktopWindowDetails *details;
window = CAJA_DESKTOP_WINDOW (widget);
+ details = window->details;
/* Make sure we get keyboard events */
gtk_widget_set_events (widget, gtk_widget_get_events (widget)
@@ -240,8 +236,9 @@ realize (GtkWidget *widget)
set_desktop_window_id (window, gtk_widget_get_window (widget));
- g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed",
- G_CALLBACK (caja_desktop_window_screen_size_changed), window);
+ details->size_changed_id =
+ g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed",
+ G_CALLBACK (caja_desktop_window_screen_size_changed), window);
}
static char *
@@ -258,20 +255,25 @@ real_get_icon (CajaWindow *window,
}
static void
-caja_desktop_window_class_init (CajaDesktopWindowClass *class)
+caja_desktop_window_class_init (CajaDesktopWindowClass *klass)
{
- G_OBJECT_CLASS (class)->finalize = finalize;
- GTK_WIDGET_CLASS (class)->realize = realize;
- GTK_WIDGET_CLASS (class)->unrealize = unrealize;
+ GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+ CajaWindowClass *nclass = CAJA_WINDOW_CLASS (klass);
+ wclass->realize = realize;
+ wclass->unrealize = unrealize;
+ wclass->map = map;
- GTK_WIDGET_CLASS (class)->map = map;
+ nclass->window_type = CAJA_WINDOW_DESKTOP;
+ nclass->get_title = real_get_title;
+ nclass->get_icon = real_get_icon;
- CAJA_WINDOW_CLASS (class)->window_type = CAJA_WINDOW_DESKTOP;
-
- CAJA_WINDOW_CLASS (class)->get_title
- = real_get_title;
- CAJA_WINDOW_CLASS (class)->get_icon
- = real_get_icon;
+ g_type_class_add_private (klass, sizeof (CajaDesktopWindowDetails));
+}
+gboolean
+caja_desktop_window_loaded (CajaDesktopWindow *window)
+{
+ return window->details->loaded;
}
+
diff --git a/src/caja-desktop-window.h b/src/caja-desktop-window.h
index cd9582b4..2bd3579c 100644
--- a/src/caja-desktop-window.h
+++ b/src/caja-desktop-window.h
@@ -62,5 +62,6 @@ GType caja_desktop_window_get_type (void);
CajaDesktopWindow *caja_desktop_window_new (CajaApplication *application,
GdkScreen *screen);
void caja_desktop_window_update_directory (CajaDesktopWindow *window);
+gboolean caja_desktop_window_loaded (CajaDesktopWindow *window);
#endif /* CAJA_DESKTOP_WINDOW_H */
diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c
index 7c188a7d..1de86f9b 100644
--- a/src/caja-emblem-sidebar.c
+++ b/src/caja-emblem-sidebar.c
@@ -32,9 +32,6 @@
#include "caja-emblem-sidebar.h"
#include <stdio.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
#include <eel/eel-wrap-table.h>
#include <eel/eel-labeled-image.h>
#include <eel/eel-graphic-effects.h>
@@ -67,12 +64,10 @@ struct CajaEmblemSidebarDetails
#define STANDARD_EMBLEM_HEIGHT 52
#define EMBLEM_LABEL_SPACING 2
-static void caja_emblem_sidebar_iface_init (CajaSidebarIface *iface);
-static void caja_emblem_sidebar_finalize (GObject *object);
static void caja_emblem_sidebar_populate (CajaEmblemSidebar *emblem_sidebar);
static void caja_emblem_sidebar_refresh (CajaEmblemSidebar *emblem_sidebar);
static void caja_emblem_sidebar_iface_init (CajaSidebarIface *iface);
-static void sidebar_provider_iface_init (CajaSidebarProviderIface *iface);
+static void sidebar_provider_iface_init (CajaSidebarProviderIface *iface);
static GType caja_emblem_sidebar_provider_get_type (void);
static const GtkTargetEntry drag_types[] =
@@ -113,8 +108,6 @@ typedef struct
} CajaEmblemSidebarProviderClass;
-
-
G_DEFINE_TYPE_WITH_CODE (CajaEmblemSidebar, caja_emblem_sidebar, GTK_TYPE_VBOX,
G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR,
caja_emblem_sidebar_iface_init));
@@ -1013,7 +1006,8 @@ caja_emblem_sidebar_populate (CajaEmblemSidebar *emblem_sidebar)
widgets = g_list_prepend (widgets, emblem_widget);
}
- eel_g_list_free_deep (icons);
+ g_list_foreach(icons, (GFunc) g_free, NULL);
+ g_list_free(icons);
/* sort the emblems by display name */
widgets = g_list_sort (widgets, emblem_widget_sort_func);
diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c
index 438ce08a..ef532d72 100644
--- a/src/caja-file-management-properties.c
+++ b/src/caja-file-management-properties.c
@@ -262,6 +262,10 @@ caja_file_management_properties_dialog_response_cb (GtkDialog *parent,
break;
case 4:
section = "goscaja-60";
+ break;
+ case 5:
+ section = "goscaja-61";
+ break;
}
preferences_show_help (GTK_WINDOW (parent), "user-guide", section);
}
@@ -303,7 +307,7 @@ free_column_names_array (GPtrArray *column_names)
}
static void
-create_icon_caption_combo_box_items (GtkComboBox *combo_box,
+create_icon_caption_combo_box_items (GtkComboBoxText *combo_box,
GList *columns)
{
GList *l;
@@ -312,7 +316,7 @@ create_icon_caption_combo_box_items (GtkComboBox *combo_box,
column_names = g_ptr_array_new ();
/* Translators: this is referred to captions under icons. */
- gtk_combo_box_append_text (combo_box, _("None"));
+ gtk_combo_box_text_append_text (combo_box, _("None"));
g_ptr_array_add (column_names, g_strdup ("none"));
for (l = columns; l != NULL; l = l->next)
@@ -335,7 +339,7 @@ create_icon_caption_combo_box_items (GtkComboBox *combo_box,
continue;
}
- gtk_combo_box_append_text (combo_box, label);
+ gtk_combo_box_text_append_text (combo_box, label);
g_ptr_array_add (column_names, name);
g_free (label);
@@ -468,7 +472,7 @@ caja_file_management_properties_dialog_setup_icon_caption_page (GtkBuilder *buil
combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
icon_captions_components[i]));
- create_icon_caption_combo_box_items (GTK_COMBO_BOX (combo_box), columns);
+ create_icon_caption_combo_box_items (GTK_COMBO_BOX_TEXT (combo_box), columns);
gtk_widget_set_sensitive (combo_box, writable);
g_signal_connect (combo_box, "changed",
@@ -484,27 +488,28 @@ caja_file_management_properties_dialog_setup_icon_caption_page (GtkBuilder *buil
static void
create_date_format_menu (GtkBuilder *builder)
{
- GtkWidget *combo_box;
+ GtkComboBoxText *combo_box;
gchar *date_string;
time_t now_raw;
struct tm* now;
- combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
- CAJA_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET));
+ combo_box = GTK_COMBO_BOX_TEXT
+ (gtk_builder_get_object (builder,
+ CAJA_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET));
now_raw = time (NULL);
now = localtime (&now_raw);
date_string = eel_strdup_strftime ("%c", now);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), date_string);
g_free (date_string);
date_string = eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", now);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), date_string);
g_free (date_string);
date_string = eel_strdup_strftime (_("today at %-I:%M:%S %p"), now);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), date_string);
g_free (date_string);
}
diff --git a/src/caja-file-management-properties.ui b/src/caja-file-management-properties.ui
index c810d57e..5c4c3036 100644
--- a/src/caja-file-management-properties.ui
+++ b/src/caja-file-management-properties.ui
@@ -233,32 +233,6 @@
</row>
</data>
</object>
- <object class="GtkListStore" id="model11">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- </data>
- </object>
- <object class="GtkListStore" id="model12">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- </data>
- </object>
- <object class="GtkListStore" id="model13">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- </data>
- </object>
- <object class="GtkListStore" id="model14">
- <columns>
- <column type="gchararray"/>
- </columns>
- </object>
<object class="GtkDialog" id="file_management_dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">File Management Preferences</property>
@@ -274,7 +248,6 @@
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
@@ -420,15 +393,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
<child>
@@ -476,15 +447,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
<child>
@@ -528,15 +497,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
- <property name="fill">True</property>
</packing>
</child>
<child>
@@ -629,15 +596,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
<child>
@@ -681,8 +646,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -782,15 +746,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
<child>
@@ -816,8 +778,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -917,15 +878,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -933,8 +892,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -1012,8 +970,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -1137,31 +1094,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label99">
- <property name="height_request">6</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes"/>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </object>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- <child>
<object class="GtkCheckButton" id="always_use_browser_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -1184,8 +1116,8 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -1301,8 +1233,8 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -1398,8 +1330,8 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -1539,29 +1471,23 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="captions_0_combobox">
+ <object class="GtkComboBoxText" id="captions_0_combobox">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
- <property name="model">model11</property>
- <child>
- <object class="GtkCellRendererText" id="renderer"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
+ <property name="entry-text-column">0</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
<child>
@@ -1594,22 +1520,16 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="captions_1_combobox">
+ <object class="GtkComboBoxText" id="captions_1_combobox">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
- <property name="model">model12</property>
- <child>
- <object class="GtkCellRendererText" id="renderer12"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
+ <property name="entry-text-column">0</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -1649,29 +1569,23 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="captions_2_combobox">
+ <object class="GtkComboBoxText" id="captions_2_combobox">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
- <property name="model">model13</property>
- <child>
- <object class="GtkCellRendererText" id="renderer13"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
+ <property name="entry-text-column">0</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -1679,8 +1593,8 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -1761,17 +1675,11 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="date_format_combobox">
+ <object class="GtkComboBoxText" id="date_format_combobox">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
- <property name="model">model14</property>
- <child>
- <object class="GtkCellRendererText" id="renderer14"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
+ <property name="entry-text-column">0</property>
</object>
<packing>
<property name="padding">0</property>
@@ -1784,15 +1692,15 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -1903,15 +1811,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2035,15 +1941,15 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -2051,8 +1957,8 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
@@ -2152,15 +2058,15 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
<child>
@@ -2208,15 +2114,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2224,8 +2128,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2325,15 +2228,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2341,8 +2242,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2442,15 +2342,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2458,8 +2356,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2799,8 +2696,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2808,15 +2704,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
<child>
@@ -2984,8 +2878,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -2993,15 +2886,13 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
@@ -3101,8 +2992,7 @@
</object>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
</packing>
</child>
</object>
diff --git a/src/caja-history-sidebar.c b/src/caja-history-sidebar.c
index 2375a046..b69dce51 100644
--- a/src/caja-history-sidebar.c
+++ b/src/caja-history-sidebar.c
@@ -27,9 +27,7 @@
#include <config.h>
-#include <eel/eel-debug.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-glib-extensions.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libcaja-private/caja-bookmark.h>
@@ -123,7 +121,8 @@ update_history (CajaHistorySidebar *sidebar)
}
g_free (name);
}
- eel_g_object_list_free (history);
+ g_list_foreach(history, (GFunc) g_object_unref, NULL);
+ g_list_free(history);
selection = GTK_TREE_SELECTION (gtk_tree_view_get_selection (sidebar->tree_view));
diff --git a/src/caja-image-properties-page.c b/src/caja-image-properties-page.c
index 67428fde..1e5b53e2 100644
--- a/src/caja-image-properties-page.c
+++ b/src/caja-image-properties-page.c
@@ -391,6 +391,10 @@ load_finished (CajaImagePropertiesPage *page)
gtk_widget_destroy (page->details->loading_label);
+ if (page->details->loader != NULL) {
+ gdk_pixbuf_loader_close (page->details->loader, NULL);
+ }
+
if (page->details->got_size)
{
#ifdef HAVE_EXIF
@@ -437,7 +441,6 @@ load_finished (CajaImagePropertiesPage *page)
if (page->details->loader != NULL)
{
- gdk_pixbuf_loader_close (page->details->loader, NULL);
g_object_unref (page->details->loader);
page->details->loader = NULL;
}
diff --git a/src/caja-information-panel.c b/src/caja-information-panel.c
index 35df28ca..7aa17908 100644
--- a/src/caja-information-panel.c
+++ b/src/caja-information-panel.c
@@ -31,7 +31,6 @@
#include <eel/eel-background.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
@@ -146,8 +145,6 @@ typedef struct
G_DEFINE_TYPE_WITH_CODE (CajaInformationPanel, caja_information_panel, EEL_TYPE_BACKGROUND_BOX,
G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR,
caja_information_panel_iface_init));
-/* for EEL_CALL_PARENT */
-#define parent_class caja_information_panel_parent_class
G_DEFINE_TYPE_WITH_CODE (CajaInformationPanelProvider, caja_information_panel_provider, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR_PROVIDER,
@@ -221,6 +218,8 @@ caja_information_panel_class_init (CajaInformationPanelClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ g_type_class_add_private (klass, sizeof (CajaInformationPanelDetails));
}
/* utility routine to allocate the box the holds the command buttons */
@@ -245,11 +244,9 @@ make_button_box (CajaInformationPanel *information_panel)
static void
caja_information_panel_init (CajaInformationPanel *information_panel)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (information_panel);
-
- information_panel->details = g_new0 (CajaInformationPanelDetails, 1);
+ information_panel->details = G_TYPE_INSTANCE_GET_PRIVATE (information_panel,
+ CAJA_TYPE_INFORMATION_PANEL,
+ CajaInformationPanelDetails);
/* load the default background */
caja_information_panel_read_defaults (information_panel);
@@ -312,13 +309,12 @@ caja_information_panel_finalize (GObject *object)
g_free (information_panel->details->default_background_image);
g_free (information_panel->details->current_background_color);
g_free (information_panel->details->current_background_image);
- g_free (information_panel->details);
g_signal_handlers_disconnect_by_func (caja_preferences,
caja_information_panel_theme_changed,
information_panel);
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (caja_information_panel_parent_class)->finalize (object);
}
/* callback to handle resetting the background */
@@ -432,12 +428,24 @@ static InformationPanelPart
hit_test (CajaInformationPanel *information_panel,
int x, int y)
{
+ GtkAllocation *allocation;
+ gboolean bg_hit;
+
if (caja_sidebar_title_hit_test_icon (information_panel->details->title, x, y))
{
return ICON_PART;
}
- if (eel_point_in_widget (GTK_WIDGET (information_panel), x, y))
+ allocation = g_new0 (GtkAllocation, 1);
+ gtk_widget_get_allocation (GTK_WIDGET (information_panel), allocation);
+
+ bg_hit = allocation != NULL
+ && x >= allocation->x && y >= allocation->y
+ && x < allocation->x + allocation->width
+ && y < allocation->y + allocation->height;
+ g_free (allocation);
+
+ if (bg_hit)
{
return BACKGROUND_PART;
}
@@ -1072,9 +1080,7 @@ caja_information_panel_update_appearance (CajaInformationPanel *information_pane
eel_background_set_image_uri (background, background_image);
eel_background_set_color (background, background_color);
- caja_sidebar_title_select_text_color
- (information_panel->details->title, background,
- !information_panel_has_background (information_panel));
+ caja_sidebar_title_select_text_color (information_panel->details->title, background);
}
g_free (background_color);
@@ -1222,7 +1228,8 @@ selection_changed_callback (CajaWindowInfo *window,
caja_information_panel_set_uri (panel, uri, name);
- eel_g_object_list_unref (selection);
+ g_list_foreach (selection, (GFunc) g_object_unref, NULL);
+ g_list_free (selection);
g_free (uri);
g_free (name);
}
diff --git a/src/caja-location-bar.c b/src/caja-location-bar.c
index 6fdc34e5..428f26a1 100644
--- a/src/caja-location-bar.c
+++ b/src/caja-location-bar.c
@@ -356,7 +356,11 @@ finalize (GObject *object)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+destroy (GtkWidget *object)
+#else
destroy (GtkObject *object)
+#endif
{
CajaLocationBar *bar;
@@ -372,21 +376,25 @@ destroy (GtkObject *object)
g_free (bar->details->last_location);
bar->details->last_location = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ EEL_CALL_PARENT (GTK_WIDGET_CLASS, destroy, (object));
+#else
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+#endif
}
static void
caja_location_bar_class_init (CajaLocationBarClass *class)
{
- GObjectClass *gobject_class;
- GtkObjectClass *object_class;
CajaNavigationBarClass *navigation_bar_class;
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = finalize;
+ G_OBJECT_CLASS (class)->finalize = finalize;
- object_class = GTK_OBJECT_CLASS (class);
- object_class->destroy = destroy;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (class)->destroy = destroy;
+#else
+ GTK_OBJECT_CLASS (class)->destroy = destroy;
+#endif
navigation_bar_class = CAJA_NAVIGATION_BAR_CLASS (class);
diff --git a/src/caja-location-dialog.c b/src/caja-location-dialog.c
index b80230cd..ec102300 100644
--- a/src/caja-location-dialog.c
+++ b/src/caja-location-dialog.c
@@ -62,16 +62,6 @@ caja_location_dialog_finalize (GObject *object)
}
static void
-caja_location_dialog_destroy (GtkObject *object)
-{
- CajaLocationDialog *dialog;
-
- dialog = CAJA_LOCATION_DIALOG (object);
-
- EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
-}
-
-static void
open_current_location (CajaLocationDialog *dialog)
{
GFile *location;
@@ -136,14 +126,7 @@ entry_activate_callback (GtkEntry *entry,
static void
caja_location_dialog_class_init (CajaLocationDialogClass *class)
{
- GObjectClass *gobject_class;
- GtkObjectClass *object_class;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = caja_location_dialog_finalize;
-
- object_class = GTK_OBJECT_CLASS (class);
- object_class->destroy = caja_location_dialog_destroy;
+ G_OBJECT_CLASS (class)->finalize = caja_location_dialog_finalize;
}
static void
@@ -174,7 +157,6 @@ caja_location_dialog_init (CajaLocationDialog *dialog)
gtk_window_set_title (GTK_WINDOW (dialog), _("Open Location"));
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
diff --git a/src/caja-location-entry.c b/src/caja-location-entry.c
index fac59e44..0a59a347 100644
--- a/src/caja-location-entry.c
+++ b/src/caja-location-entry.c
@@ -133,19 +133,19 @@ entry_would_have_inserted_characters (const GdkEventKey *event)
{
switch (event->keyval)
{
- case GDK_BackSpace:
- case GDK_Clear:
- case GDK_Insert:
- case GDK_Delete:
- case GDK_Home:
- case GDK_End:
- case GDK_KP_Home:
- case GDK_KP_End:
- case GDK_Left:
- case GDK_Right:
- case GDK_KP_Left:
- case GDK_KP_Right:
- case GDK_Return:
+ case GDK_KEY_BackSpace:
+ case GDK_KEY_Clear:
+ case GDK_KEY_Insert:
+ case GDK_KEY_Delete:
+ case GDK_KEY_Home:
+ case GDK_KEY_End:
+ case GDK_KEY_KP_Home:
+ case GDK_KEY_KP_End:
+ case GDK_KEY_Left:
+ case GDK_KEY_Right:
+ case GDK_KEY_KP_Left:
+ case GDK_KEY_KP_Right:
+ case GDK_KEY_Return:
return FALSE;
default:
if (event->keyval >= 0x20 && event->keyval <= 0xFF)
@@ -235,7 +235,7 @@ editable_event_after_callback (GtkEntry *entry,
* likely an auto-completion. We ignore shift / control since
* they can validly be used to extend the selection.
*/
- if ((keyevent->keyval == GDK_Right || keyevent->keyval == GDK_End) &&
+ if ((keyevent->keyval == GDK_KEY_Right || keyevent->keyval == GDK_KEY_End) &&
!(keyevent->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
gtk_editable_get_selection_bounds (editable, NULL, NULL))
{
@@ -285,7 +285,11 @@ finalize (GObject *object)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+destroy (GtkWidget *object)
+#else
destroy (GtkObject *object)
+#endif
{
CajaLocationEntry *entry;
@@ -301,7 +305,11 @@ destroy (GtkObject *object)
g_free (entry->details->current_directory);
entry->details->current_directory = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ EEL_CALL_PARENT (GTK_WIDGET_CLASS, destroy, (object));
+#else
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+#endif
}
static void
@@ -382,22 +390,17 @@ caja_location_entry_activate (GtkEntry *entry)
static void
caja_location_entry_class_init (CajaLocationEntryClass *class)
{
- GtkWidgetClass *widget_class;
- GObjectClass *gobject_class;
- GtkObjectClass *object_class;
- GtkEntryClass *entry_class;
+ GTK_WIDGET_CLASS (class)->focus_in_event = caja_location_entry_focus_in;
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->focus_in_event = caja_location_entry_focus_in;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (class)->destroy = destroy;
+#else
+ GTK_OBJECT_CLASS (class)->destroy = destroy;
+#endif
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = finalize;
+ G_OBJECT_CLASS (class)->finalize = finalize;
- object_class = GTK_OBJECT_CLASS (class);
- object_class->destroy = destroy;
-
- entry_class = GTK_ENTRY_CLASS (class);
- entry_class->activate = caja_location_entry_activate;
+ GTK_ENTRY_CLASS (class)->activate = caja_location_entry_activate;
}
void
diff --git a/src/caja-main.c b/src/caja-main.c
index ef5714b2..3a99163f 100644
--- a/src/caja-main.c
+++ b/src/caja-main.c
@@ -101,7 +101,7 @@ static void eel_gtk_main_quit_all (void)
g_idle_add (quit_if_in_main_loop, NULL);
}
-static void event_loop_unregister (GtkObject *object)
+static void event_loop_unregister (GtkWidget *object)
{
event_loop_registrants = g_slist_remove (event_loop_registrants, object);
@@ -111,13 +111,17 @@ static void event_loop_unregister (GtkObject *object)
}
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+void caja_main_event_loop_register (GtkWidget *object)
+#else
void caja_main_event_loop_register (GtkObject *object)
+#endif
{
g_signal_connect (object, "destroy", G_CALLBACK (event_loop_unregister), NULL);
- event_loop_registrants = g_slist_prepend (event_loop_registrants, object);
+ event_loop_registrants = g_slist_prepend (event_loop_registrants, GTK_WIDGET (object));
}
-gboolean caja_main_is_event_loop_mainstay (GtkObject *object)
+gboolean caja_main_is_event_loop_mainstay (GtkWidget *object)
{
return g_slist_length (event_loop_registrants) == 1
&& event_loop_registrants->data == object;
@@ -148,7 +152,7 @@ void caja_main_event_loop_quit (gboolean explicit)
}
while (event_loop_registrants != NULL)
{
- gtk_object_destroy (event_loop_registrants->data);
+ gtk_widget_destroy (event_loop_registrants->data);
}
}
diff --git a/src/caja-main.h b/src/caja-main.h
index c3ddf82a..abb9e6a7 100644
--- a/src/caja-main.h
+++ b/src/caja-main.h
@@ -29,8 +29,12 @@
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+void caja_main_event_loop_register (GtkWidget *object);
+#else
void caja_main_event_loop_register (GtkObject *object);
-gboolean caja_main_is_event_loop_mainstay (GtkObject *object);
+#endif
+gboolean caja_main_is_event_loop_mainstay (GtkWidget *object);
void caja_main_event_loop_quit (gboolean explicit);
#endif /* CAJA_MAIN_H */
diff --git a/src/caja-navigation-bar.c b/src/caja-navigation-bar.c
index 45434e89..89cd0e20 100644
--- a/src/caja-navigation-bar.c
+++ b/src/caja-navigation-bar.c
@@ -54,14 +54,11 @@ EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (caja_navigation_bar, set_location)
static void
caja_navigation_bar_class_init (CajaNavigationBarClass *klass)
{
- GtkObjectClass *object_class;
GtkBindingSet *binding_set;
- object_class = GTK_OBJECT_CLASS (klass);
-
signals[ACTIVATE] = g_signal_new
("activate",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CajaNavigationBarClass,
activate),
@@ -71,7 +68,7 @@ caja_navigation_bar_class_init (CajaNavigationBarClass *klass)
signals[CANCEL] = g_signal_new
("cancel",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (CajaNavigationBarClass,
cancel),
@@ -81,7 +78,7 @@ caja_navigation_bar_class_init (CajaNavigationBarClass *klass)
signals[LOCATION_CHANGED] = g_signal_new
("location_changed",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CajaNavigationBarClass,
location_changed),
@@ -93,7 +90,7 @@ caja_navigation_bar_class_init (CajaNavigationBarClass *klass)
klass->cancel = NULL;
binding_set = gtk_binding_set_by_class (klass);
- gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, caja_navigation_bar, get_location);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, caja_navigation_bar, set_location);
diff --git a/src/caja-navigation-window-menus.c b/src/caja-navigation-window-menus.c
index 5cc77308..a9214476 100644
--- a/src/caja-navigation-window-menus.c
+++ b/src/caja-navigation-window-menus.c
@@ -47,7 +47,6 @@
#include <eel/eel-mate-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#include <eel/eel-xml-extensions.h>
#include <libxml/parser.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -117,7 +116,7 @@ forget_history_if_yes (GtkDialog *dialog, int response, gpointer callback_data)
{
caja_forget_history ();
}
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
@@ -621,59 +620,32 @@ action_new_tab_callback (GtkAction *action,
gpointer user_data)
{
CajaWindow *window;
- CajaWindowSlot *current_slot;
- CajaWindowSlot *new_slot;
- CajaWindowOpenFlags flags;
- GFile *location;
- int new_slot_position;
- char *scheme;
window = CAJA_WINDOW (user_data);
- current_slot = window->details->active_pane->active_slot;
- location = caja_window_slot_get_location (current_slot);
-
- if (location != NULL)
- {
- flags = 0;
-
- new_slot_position = g_settings_get_enum (caja_preferences, CAJA_PREFERENCES_NEW_TAB_POSITION);
- if (new_slot_position == CAJA_NEW_TAB_POSITION_END)
- {
- flags = CAJA_WINDOW_OPEN_SLOT_APPEND;
- }
-
- scheme = g_file_get_uri_scheme (location);
- if (!strcmp (scheme, "x-caja-search"))
- {
- g_object_unref (location);
- location = g_file_new_for_path (g_get_home_dir ());
- }
- g_free (scheme);
-
- new_slot = caja_window_open_slot (current_slot->pane, flags);
- caja_window_set_active_slot (window, new_slot);
- caja_window_slot_go_to (new_slot, location, FALSE);
- g_object_unref (location);
- }
+ caja_window_new_tab (window);
}
static void
action_folder_window_callback (GtkAction *action,
gpointer user_data)
{
- CajaWindow *current_window;
+ CajaWindow *current_window, *window;
CajaWindowSlot *slot;
GFile *current_location;
current_window = CAJA_WINDOW (user_data);
slot = current_window->details->active_pane->active_slot;
current_location = caja_window_slot_get_location (slot);
- caja_application_present_spatial_window (
- current_window->application,
- current_window,
- NULL,
- current_location,
- gtk_window_get_screen (GTK_WINDOW (current_window)));
+ window = caja_application_get_spatial_window
+ (current_window->application,
+ current_window,
+ NULL,
+ current_location,
+ gtk_window_get_screen (GTK_WINDOW (current_window)),
+ NULL);
+
+ caja_window_go_to (window, current_location);
+
if (current_location != NULL)
{
g_object_unref (current_location);
diff --git a/src/caja-navigation-window-pane.c b/src/caja-navigation-window-pane.c
index b4b6ceaf..da71661b 100644
--- a/src/caja-navigation-window-pane.c
+++ b/src/caja-navigation-window-pane.c
@@ -353,6 +353,16 @@ path_bar_button_drag_begin_callback (GtkWidget *widget,
}
static void
+notebook_popup_menu_new_tab_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ CajaWindowPane *pane;
+
+ pane = CAJA_WINDOW_PANE (user_data);
+ caja_window_new_tab (pane->window);
+}
+
+static void
path_bar_path_set_callback (GtkWidget *widget,
GFile *location,
CajaNavigationWindowPane *pane)
@@ -442,6 +452,16 @@ notebook_popup_menu_show (CajaNavigationWindowPane *pane,
popup = gtk_menu_new();
+ item = gtk_menu_item_new_with_mnemonic (_("_New Tab"));
+ g_signal_connect (item, "activate",
+ G_CALLBACK (notebook_popup_menu_new_tab_cb),
+ pane);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ item);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ gtk_separator_menu_item_new ());
+
item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left"));
g_signal_connect (item, "activate",
G_CALLBACK (notebook_popup_menu_move_left_cb),
diff --git a/src/caja-navigation-window-slot.c b/src/caja-navigation-window-slot.c
index 703cca90..14963733 100644
--- a/src/caja-navigation-window-slot.c
+++ b/src/caja-navigation-window-slot.c
@@ -88,7 +88,8 @@ caja_navigation_window_slot_clear_forward_list (CajaNavigationWindowSlot *slot)
{
g_assert (CAJA_IS_NAVIGATION_WINDOW_SLOT (slot));
- eel_g_object_list_free (slot->forward_list);
+ g_list_foreach(slot->forward_list, (GFunc) g_object_unref, NULL);
+ g_list_free(slot->forward_list);
slot->forward_list = NULL;
}
@@ -97,7 +98,8 @@ caja_navigation_window_slot_clear_back_list (CajaNavigationWindowSlot *slot)
{
g_assert (CAJA_IS_NAVIGATION_WINDOW_SLOT (slot));
- eel_g_object_list_free (slot->back_list);
+ g_list_foreach(slot->back_list, (GFunc) g_object_unref, NULL);
+ g_list_free(slot->back_list);
slot->back_list = NULL;
}
diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c
index db9cf523..e5622af7 100644
--- a/src/caja-navigation-window.c
+++ b/src/caja-navigation-window.c
@@ -55,7 +55,6 @@
#include <libcaja-private/caja-file-utilities.h>
#include <libcaja-private/caja-file-attributes.h>
#include <libcaja-private/caja-global-preferences.h>
-#include <libcaja-private/caja-horizontal-splitter.h>
#include <libcaja-private/caja-icon-info.h>
#include <libcaja-private/caja-metadata.h>
#include <libcaja-private/caja-mime-actions.h>
@@ -141,7 +140,11 @@ caja_navigation_window_init (CajaNavigationWindow *window)
window->details->header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
gtk_size_group_set_ignore_hidden (window->details->header_size_group, FALSE);
- window->details->content_paned = caja_horizontal_splitter_new ();
+#if GTK_CHECK_VERSION(3, 0, 0)
+ window->details->content_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+#else
+ window->details->content_paned = gtk_hpaned_new ();
+#endif
gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table),
window->details->content_paned,
/* X direction */ /* Y direction */
@@ -151,10 +154,15 @@ caja_navigation_window_init (CajaNavigationWindow *window)
gtk_widget_show (window->details->content_paned);
vbox = gtk_vbox_new (FALSE, 0);
- caja_horizontal_splitter_pack2 (CAJA_HORIZONTAL_SPLITTER (window->details->content_paned), vbox);
+ gtk_paned_pack2 (GTK_PANED (window->details->content_paned), vbox,
+ TRUE, FALSE);
gtk_widget_show (vbox);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+#else
hpaned = gtk_hpaned_new ();
+#endif
gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
gtk_widget_show (hpaned);
window->details->split_view_hpane = hpaned;
@@ -593,7 +601,11 @@ caja_navigation_window_button_press_event (GtkWidget *widget,
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+caja_navigation_window_destroy (GtkWidget *object)
+#else
caja_navigation_window_destroy (GtkObject *object)
+#endif
{
CajaNavigationWindow *window;
@@ -609,7 +621,11 @@ caja_navigation_window_destroy (GtkObject *object)
window->details->content_paned = NULL;
window->details->split_view_hpane = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (parent_class)->destroy (object);
+#else
GTK_OBJECT_CLASS (parent_class)->destroy (object);
+#endif
}
static void
@@ -1028,7 +1044,7 @@ caja_navigation_window_sidebar_showing (CajaNavigationWindow *window)
g_return_val_if_fail (CAJA_IS_NAVIGATION_WINDOW (window), FALSE);
return (window->sidebar != NULL)
- && caja_horizontal_splitter_is_hidden (CAJA_HORIZONTAL_SPLITTER (window->details->content_paned));
+ && gtk_widget_get_visible (gtk_paned_get_child1 (GTK_PANED (window->details->content_paned)));
}
/**
@@ -1243,7 +1259,11 @@ caja_navigation_window_class_init (CajaNavigationWindowClass *class)
CAJA_WINDOW_CLASS (class)->bookmarks_placeholder = MENU_PATH_BOOKMARKS_PLACEHOLDER;
G_OBJECT_CLASS (class)->finalize = caja_navigation_window_finalize;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (class)->destroy = caja_navigation_window_destroy;
+#else
GTK_OBJECT_CLASS (class)->destroy = caja_navigation_window_destroy;
+#endif
GTK_WIDGET_CLASS (class)->show = caja_navigation_window_show;
GTK_WIDGET_CLASS (class)->unrealize = caja_navigation_window_unrealize;
GTK_WIDGET_CLASS (class)->window_state_event = caja_navigation_window_state_event;
diff --git a/src/caja-notes-viewer.c b/src/caja-notes-viewer.c
index dc2df7fd..e62a0f14 100644
--- a/src/caja-notes-viewer.c
+++ b/src/caja-notes-viewer.c
@@ -31,7 +31,6 @@
#include <eel/eel-debug.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libcaja-private/caja-file-attributes.h>
@@ -141,7 +140,7 @@ set_saved_text (CajaNotesViewer *notes, char *new_notes)
old_text = notes->details->previous_saved_text;
notes->details->previous_saved_text = new_notes;
- if (eel_strcmp (old_text, new_notes) != 0)
+ if (g_strcmp0 (old_text, new_notes) != 0)
{
g_signal_emit_by_name (CAJA_SIDEBAR (notes),
"tab_icon_changed");
@@ -207,7 +206,7 @@ load_note_text_from_metadata (CajaFile *file,
/* This fn is called for any change signal on the file, so make sure that the
* metadata has actually changed.
*/
- if (eel_strcmp (saved_text, notes->details->previous_saved_text) != 0)
+ if (g_strcmp0 (saved_text, notes->details->previous_saved_text) != 0)
{
set_saved_text (notes, saved_text);
cancel_pending_save (notes);
diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c
index 279f4cd5..57821d60 100644
--- a/src/caja-pathbar.c
+++ b/src/caja-pathbar.c
@@ -20,10 +20,6 @@
#include <config.h>
#include <string.h>
-#include <eel/eel-debug.h>
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
@@ -32,7 +28,6 @@
#include <libcaja-private/caja-global-preferences.h>
#include <libcaja-private/caja-icon-names.h>
#include <libcaja-private/caja-trash-monitor.h>
-#include <libcaja-private/caja-marshal.h>
#include <libcaja-private/caja-dnd.h>
#include <libcaja-private/caja-icon-dnd.h>
#include "caja-pathbar.h"
@@ -40,6 +35,10 @@
#include "caja-window-private.h"
#include "caja-window-slot.h"
+#if !GTK_CHECK_VERSION(3,0,0)
+#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y)
+#endif
+
enum
{
PATH_CLICKED,
@@ -100,8 +99,17 @@ G_DEFINE_TYPE (CajaPathBar,
static void caja_path_bar_finalize (GObject *object);
static void caja_path_bar_dispose (GObject *object);
+#if GTK_CHECK_VERSION(3,0,0)
+static void caja_path_bar_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void caja_path_bar_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+#else
static void caja_path_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+ GtkRequisition *requisition);
+#endif
static void caja_path_bar_unmap (GtkWidget *widget);
static void caja_path_bar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
@@ -362,19 +370,22 @@ static void
caja_path_bar_class_init (CajaPathBarClass *path_bar_class)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
gobject_class = (GObjectClass *) path_bar_class;
- object_class = (GtkObjectClass *) path_bar_class;
widget_class = (GtkWidgetClass *) path_bar_class;
container_class = (GtkContainerClass *) path_bar_class;
gobject_class->finalize = caja_path_bar_finalize;
gobject_class->dispose = caja_path_bar_dispose;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_height = caja_path_bar_get_preferred_height;
+ widget_class->get_preferred_width = caja_path_bar_get_preferred_width;
+#else
widget_class->size_request = caja_path_bar_size_request;
+#endif
widget_class->unmap = caja_path_bar_unmap;
widget_class->size_allocate = caja_path_bar_size_allocate;
widget_class->style_set = caja_path_bar_style_set;
@@ -389,7 +400,7 @@ caja_path_bar_class_init (CajaPathBarClass *path_bar_class)
path_bar_signals [PATH_CLICKED] =
g_signal_new ("path-clicked",
- G_OBJECT_CLASS_TYPE (object_class),
+ G_OBJECT_CLASS_TYPE (path_bar_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (CajaPathBarClass, path_clicked),
NULL, NULL,
@@ -398,13 +409,17 @@ caja_path_bar_class_init (CajaPathBarClass *path_bar_class)
G_TYPE_FILE);
path_bar_signals [PATH_SET] =
g_signal_new ("path-set",
- G_OBJECT_CLASS_TYPE (object_class),
+ G_OBJECT_CLASS_TYPE (path_bar_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (CajaPathBarClass, path_set),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_FILE);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_container_class_handle_border_width (container_class);
+#endif
}
@@ -478,6 +493,77 @@ caja_path_bar_dispose (GObject *object)
* Ideally, our size is determined by another widget, and we are just filling
* available space.
*/
+#if GTK_CHECK_VERSION(3,0,0)
+static void
+caja_path_bar_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ ButtonData *button_data;
+ CajaPathBar *path_bar;
+ GList *list;
+ gint child_height;
+ gint height;
+ gint child_min, child_nat;
+
+ path_bar = CAJA_PATH_BAR (widget);
+
+ *minimum = *natural = 0;
+ height = 0;
+
+ for (list = path_bar->button_list; list; list = list->next) {
+ button_data = BUTTON_DATA (list->data);
+ gtk_widget_get_preferred_width (button_data->button, &child_min, &child_nat);
+ gtk_widget_get_preferred_height (button_data->button, &child_height, NULL);
+ height = MAX (height, child_height);
+
+ if (button_data->type == NORMAL_BUTTON) {
+ /* Use 2*Height as button width because of ellipsized label. */
+ child_min = MAX (child_min, child_height * 2);
+ child_nat = MAX (child_min, child_height * 2);
+ }
+
+ *minimum = MAX (*minimum, child_min);
+ *natural = MAX (*natural, child_nat);
+ }
+
+ /* Add space for slider, if we have more than one path */
+ /* Theoretically, the slider could be bigger than the other button. But we're
+ * not going to worry about that now.
+ */
+ path_bar->slider_width = MIN (height * 2 / 3 + 5, height);
+
+ if (path_bar->button_list && path_bar->button_list->next != NULL) {
+ *minimum += (path_bar->spacing + path_bar->slider_width) * 2;
+ *natural += (path_bar->spacing + path_bar->slider_width) * 2;
+ }
+}
+
+static void
+caja_path_bar_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ ButtonData *button_data;
+ CajaPathBar *path_bar;
+ GList *list;
+ gint child_min, child_nat;
+
+ path_bar = CAJA_PATH_BAR (widget);
+
+ *minimum = *natural = 0;
+
+ for (list = path_bar->button_list; list; list = list->next) {
+ button_data = BUTTON_DATA (list->data);
+ gtk_widget_get_preferred_height (button_data->button, &child_min, &child_nat);
+
+ *minimum = MAX (*minimum, child_min);
+ *natural = MAX (*natural, child_nat);
+ }
+}
+
+#else /* GTK_CHECK_VERSION(3,0,0) */
+
static void
caja_path_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -521,6 +607,7 @@ caja_path_bar_size_request (GtkWidget *widget,
gtk_widget_set_size_request (widget, requisition->width,
requisition->height);
}
+#endif /* GTK_CHECK_VERSION(3,0,0) */
static void
caja_path_bar_update_slider_buttons (CajaPathBar *path_bar)
@@ -571,7 +658,6 @@ caja_path_bar_size_allocate (GtkWidget *widget,
GList *list, *first_button;
gint width;
gint allocation_width;
- gint border_width;
gboolean need_sliders;
gint up_slider_offset;
gint down_slider_offset;
@@ -591,8 +677,12 @@ caja_path_bar_size_allocate (GtkWidget *widget,
return;
}
direction = gtk_widget_get_direction (widget);
- border_width = (gint) gtk_container_get_border_width (GTK_CONTAINER (path_bar));
+#if GTK_CHECK_VERSION(3,0,0)
+ allocation_width = allocation->width;
+#else
+ gint border_width = (gint) gtk_container_get_border_width (GTK_CONTAINER (path_bar));
allocation_width = allocation->width - 2 * border_width;
+#endif
/* First, we check to see if we need the scrollbars. */
if (path_bar->fake_root)
@@ -604,13 +694,14 @@ caja_path_bar_size_allocate (GtkWidget *widget,
width = 0;
}
- gtk_widget_get_child_requisition (BUTTON_DATA (path_bar->button_list->data)->button, &child_requisition);
+ gtk_widget_get_preferred_size (BUTTON_DATA (path_bar->button_list->data)->button,
+ &child_requisition, NULL);
width += child_requisition.width;
for (list = path_bar->button_list->next; list; list = list->next)
{
child = BUTTON_DATA (list->data)->button;
- gtk_widget_get_child_requisition (child, &child_requisition);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
width += child_requisition.width + path_bar->spacing;
if (list == path_bar->fake_root)
@@ -652,13 +743,14 @@ caja_path_bar_size_allocate (GtkWidget *widget,
* button, then count backwards.
*/
/* Count down the path chain towards the end. */
- gtk_widget_get_child_requisition (BUTTON_DATA (first_button->data)->button, &child_requisition);
+ gtk_widget_get_preferred_size (BUTTON_DATA (first_button->data)->button,
+ &child_requisition, NULL);
width = child_requisition.width;
list = first_button->prev;
while (list && !reached_end)
{
child = BUTTON_DATA (list->data)->button;
- gtk_widget_get_child_requisition (child, &child_requisition);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (width + child_requisition.width + path_bar->spacing + slider_space > allocation_width)
{
@@ -684,7 +776,7 @@ caja_path_bar_size_allocate (GtkWidget *widget,
while (first_button->next && ! reached_end)
{
child = BUTTON_DATA (first_button->next->data)->button;
- gtk_widget_get_child_requisition (child, &child_requisition);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (width + child_requisition.width + path_bar->spacing + slider_space > allocation_width)
{
@@ -703,24 +795,45 @@ caja_path_bar_size_allocate (GtkWidget *widget,
}
/* Now, we allocate space to the buttons */
+#if GTK_CHECK_VERSION(3,0,0)
+ child_allocation.y = allocation->y;
+ child_allocation.height = allocation->height;
+#else
child_allocation.y = allocation->y + border_width;
child_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
+#endif
if (direction == GTK_TEXT_DIR_RTL)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ child_allocation.x = allocation->x + allocation->width;
+#else
child_allocation.x = allocation->x + allocation->width - border_width;
+#endif
if (need_sliders || path_bar->fake_root)
{
child_allocation.x -= (path_bar->spacing + path_bar->slider_width);
+#if GTK_CHECK_VERSION(3,0,0)
+ up_slider_offset = allocation->width - path_bar->slider_width;
+#else
up_slider_offset = allocation->width - border_width - path_bar->slider_width;
+#endif
}
}
else
{
+#if GTK_CHECK_VERSION(3,0,0)
+ child_allocation.x = allocation->x;
+#else
child_allocation.x = allocation->x + border_width;
+#endif
if (need_sliders || path_bar->fake_root)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ up_slider_offset = 0;
+#else
up_slider_offset = border_width;
+#endif
child_allocation.x += (path_bar->spacing + path_bar->slider_width);
}
}
@@ -728,7 +841,7 @@ caja_path_bar_size_allocate (GtkWidget *widget,
for (list = first_button; list; list = list->prev)
{
child = BUTTON_DATA (list->data)->button;
- gtk_widget_get_child_requisition (child, &child_requisition);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
gtk_widget_get_allocation (widget, &widget_allocation);
@@ -740,7 +853,11 @@ caja_path_bar_size_allocate (GtkWidget *widget,
/* Check to see if we've don't have any more space to allocate buttons */
if (need_sliders && direction == GTK_TEXT_DIR_RTL)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ if (child_allocation.x - path_bar->spacing - path_bar->slider_width < widget_allocation.x) {
+#else
if (child_allocation.x - path_bar->spacing - path_bar->slider_width < widget_allocation.x + border_width)
+#endif
{
break;
}
@@ -749,7 +866,11 @@ caja_path_bar_size_allocate (GtkWidget *widget,
{
if (need_sliders && direction == GTK_TEXT_DIR_LTR)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ if (child_allocation.x + child_allocation.width + path_bar->spacing + path_bar->slider_width > widget_allocation.x + allocation_width) {
+#else
if (child_allocation.x + child_allocation.width + path_bar->spacing + path_bar->slider_width > widget_allocation.x + border_width + allocation_width)
+#endif
{
break;
}
@@ -763,12 +884,20 @@ caja_path_bar_size_allocate (GtkWidget *widget,
{
child_allocation.x -= path_bar->spacing;
down_slider_offset = child_allocation.x - widget_allocation.x - path_bar->slider_width;
+#if GTK_CHECK_VERSION(3,0,0)
+ down_slider_offset = 0;
+#else
down_slider_offset = border_width;
+#endif
}
else
{
down_slider_offset = child_allocation.x - widget_allocation.x;
+#if GTK_CHECK_VERSION(3,0,0)
+ down_slider_offset = allocation->width - path_bar->slider_width;
+#else
down_slider_offset = allocation->width - border_width - path_bar->slider_width;
+#endif
child_allocation.x += child_allocation.width + path_bar->spacing;
}
}
@@ -962,7 +1091,6 @@ caja_path_bar_scroll_down (CajaPathBar *path_bar)
GList *up_button;
gint space_available;
gint space_needed;
- gint border_width;
GtkTextDirection direction;
GtkAllocation allocation, button_allocation, slider_allocation;
@@ -977,7 +1105,9 @@ caja_path_bar_scroll_down (CajaPathBar *path_bar)
gtk_widget_queue_resize (GTK_WIDGET (path_bar));
- border_width = gtk_container_get_border_width (GTK_CONTAINER (path_bar));
+#if !GTK_CHECK_VERSION(3,0,0)
+ gint border_width = gtk_container_get_border_width (GTK_CONTAINER (path_bar));
+#endif
direction = gtk_widget_get_direction (GTK_WIDGET (path_bar));
/* We find the button at the 'down' end that we have to make */
@@ -1017,7 +1147,10 @@ caja_path_bar_scroll_down (CajaPathBar *path_bar)
}
else
{
- space_available = (allocation.x + allocation.width - border_width) -
+ space_available = (allocation.x + allocation.width) -
+#if !GTK_CHECK_VERSION(3,0,0)
+ border_width -
+#endif
(slider_allocation.x + slider_allocation.width);
}
@@ -1409,6 +1542,34 @@ get_dir_name (ButtonData *button_data)
/* We always want to request the same size for the label, whether
* or not the contents are bold
*/
+#if GTK_CHECK_VERSION(3,0,0)
+static void
+set_label_size_request (GtkWidget *alignment,
+ ButtonData *button_data)
+{
+ const gchar *dir_name = get_dir_name (button_data);
+ PangoLayout *layout;
+ gint width, height, bold_width, bold_height;
+ gchar *markup;
+
+ layout = gtk_widget_create_pango_layout (button_data->label, dir_name);
+ pango_layout_get_pixel_size (layout, &width, &height);
+
+ markup = g_markup_printf_escaped ("<b>%s</b>", dir_name);
+ pango_layout_set_markup (layout, markup, -1);
+ g_free (markup);
+
+ pango_layout_get_pixel_size (layout, &bold_width, &bold_height);
+
+ gtk_widget_set_size_request (alignment,
+ MAX (width, bold_width),
+ MAX (height, bold_height));
+
+ g_object_unref (layout);
+}
+
+#else /* GTK_CHECK_VERSION(3,0,0) */
+
static void
label_size_request_cb (GtkWidget *widget,
GtkRequisition *requisition,
@@ -1432,6 +1593,7 @@ label_size_request_cb (GtkWidget *widget,
g_object_unref (layout);
}
+#endif /* GTK_CHECK_VERSION(3,0,0) */
static void
caja_path_bar_update_button_appearance (ButtonData *button_data)
@@ -1588,7 +1750,8 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data)
g_object_unref (default_location);
g_object_unref (root);
}
- eel_g_object_list_free (mounts);
+ g_list_foreach(mounts, (GFunc) g_object_unref, NULL);
+ g_list_free(mounts);
return result;
}
@@ -1797,7 +1960,7 @@ button_data_file_changed (CajaFile *file,
if (button_data->type != MOUNT_BUTTON)
{
display_name = caja_file_get_display_name (file);
- if (eel_strcmp (display_name, button_data->dir_name) != 0)
+ if (g_strcmp0 (display_name, button_data->dir_name) != 0)
{
g_free (button_data->dir_name);
button_data->dir_name = g_strdup (display_name);
@@ -1866,16 +2029,17 @@ make_directory_button (CajaPathBar *path_bar,
button_data->is_base_dir = base_dir;
}
+#if !GTK_CHECK_VERSION(3,0,0)
/* label_alignment is created because we can't override size-request
* on label itself and still have the contents of the label centered
* properly in the label's requisition
*/
-
if (label_alignment)
{
g_signal_connect (label_alignment, "size-request",
G_CALLBACK (label_size_request_cb), button_data);
}
+#endif
if (button_data->path == NULL)
{
@@ -1898,6 +2062,18 @@ make_directory_button (CajaPathBar *path_bar,
button_data->file_is_hidden = file_is_hidden;
+#if GTK_CHECK_VERSION(3,0,0)
+ /* FIXME: Maybe we dont need this alignment at all and we can
+ * use GtkMisc aligments or even GtkWidget:halign/valign center.
+ *
+ * The following function ensures that the alignment will always
+ * request the same size whether the button's text is bold or not.
+ */
+ if (label_alignment) {
+ set_label_size_request (label_alignment, button_data);
+ }
+#endif
+
gtk_container_add (GTK_CONTAINER (button_data->button), child);
gtk_widget_show_all (button_data->button);
diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c
index 13f06966..7b188152 100644
--- a/src/caja-places-sidebar.c
+++ b/src/caja-places-sidebar.c
@@ -17,7 +17,8 @@
* along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author : Mr Jamie McCracken (jamiemcc at blueyonder dot co dot uk)
+ * Authors : Mr Jamie McCracken (jamiemcc at blueyonder dot co dot uk)
+ * Cosimo Cecchi <[email protected]>
*
*/
@@ -28,6 +29,7 @@
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <eel/eel-stock-dialogs.h>
+#include <eel/eel-gdk-pixbuf-extensions.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -51,14 +53,17 @@
#include "caja-places-sidebar.h"
#include "caja-window.h"
-#define EJECT_BUTTON_XPAD 5
+#define EJECT_BUTTON_XPAD 6
+#define ICON_CELL_XPAD 6
typedef struct
{
GtkScrolledWindow parent;
GtkTreeView *tree_view;
- GtkCellRenderer *icon_cell_renderer;
GtkCellRenderer *eject_text_cell_renderer;
+ GtkCellRenderer *icon_cell_renderer;
+ GtkCellRenderer *icon_padding_cell_renderer;
+ GtkCellRenderer *padding_cell_renderer;
char *uri;
GtkListStore *store;
GtkTreeModel *filter_model;
@@ -66,6 +71,9 @@ typedef struct
CajaBookmarkList *bookmarks;
GVolumeMonitor *volume_monitor;
+ gboolean devices_header_added;
+ gboolean bookmarks_header_added;
+
/* DnD */
GList *drag_list;
gboolean drag_data_received;
@@ -90,6 +98,8 @@ typedef struct
gboolean mounting;
CajaWindowSlotInfo *go_to_after_mount_slot;
CajaWindowOpenFlags go_to_after_mount_flags;
+
+ GtkTreePath *eject_highlight_path;
} CajaPlacesSidebar;
typedef struct
@@ -120,8 +130,10 @@ enum
PLACES_SIDEBAR_COLUMN_EJECT,
PLACES_SIDEBAR_COLUMN_NO_EJECT,
PLACES_SIDEBAR_COLUMN_BOOKMARK,
- PLACES_SIDEBAR_COLUMN_NO_BOOKMARK,
PLACES_SIDEBAR_COLUMN_TOOLTIP,
+ PLACES_SIDEBAR_COLUMN_EJECT_ICON,
+ PLACES_SIDEBAR_COLUMN_SECTION_TYPE,
+ PLACES_SIDEBAR_COLUMN_HEADING_TEXT,
PLACES_SIDEBAR_COLUMN_COUNT
};
@@ -131,9 +143,16 @@ typedef enum
PLACES_BUILT_IN,
PLACES_MOUNTED_VOLUME,
PLACES_BOOKMARK,
- PLACES_SEPARATOR
+ PLACES_HEADING,
} PlaceType;
+typedef enum {
+ SECTION_DEVICES,
+ SECTION_BOOKMARKS,
+ SECTION_COMPUTER,
+ SECTION_NETWORK,
+} SectionType;
+
static void caja_places_sidebar_iface_init (CajaSidebarIface *iface);
static void sidebar_provider_iface_init (CajaSidebarProviderIface *iface);
static GType caja_places_sidebar_provider_get_type (void);
@@ -211,9 +230,106 @@ G_DEFINE_TYPE_WITH_CODE (CajaPlacesSidebarProvider, caja_places_sidebar_provider
G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR_PROVIDER,
sidebar_provider_iface_init));
+static GdkPixbuf *
+get_eject_icon (gboolean highlighted)
+{
+ GdkPixbuf *eject;
+ CajaIconInfo *eject_icon_info;
+ int icon_size;
+
+ icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+
+ eject_icon_info = caja_icon_info_lookup_from_name ("media-eject", icon_size);
+ eject = caja_icon_info_get_pixbuf_at_size (eject_icon_info, icon_size);
+
+ if (highlighted) {
+ GdkPixbuf *high;
+ high = eel_gdk_pixbuf_render (eject, 1, 255, 255, 0, 0);
+ g_object_unref (eject);
+ eject = high;
+ }
+
+ g_object_unref (eject_icon_info);
+
+ return eject;
+}
+
+static gboolean
+is_built_in_bookmark (CajaFile *file)
+{
+ gboolean built_in;
+ gint idx;
+
+ built_in = FALSE;
+
+ for (idx = 0; idx < G_USER_N_DIRECTORIES; idx++) {
+ /* PUBLIC_SHARE and TEMPLATES are not in our built-in list */
+ if (caja_file_is_user_special_directory (file, idx)) {
+ if (idx != G_USER_DIRECTORY_PUBLIC_SHARE && idx != G_USER_DIRECTORY_TEMPLATES) {
+ built_in = TRUE;
+ }
+
+ break;
+ }
+ }
+
+ return built_in;
+}
+
+static GtkTreeIter
+add_heading (CajaPlacesSidebar *sidebar,
+ SectionType section_type,
+ const gchar *title)
+{
+ GtkTreeIter iter, child_iter;
+
+ gtk_list_store_append (sidebar->store, &iter);
+ gtk_list_store_set (sidebar->store, &iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, PLACES_HEADING,
+ PLACES_SIDEBAR_COLUMN_SECTION_TYPE, section_type,
+ PLACES_SIDEBAR_COLUMN_HEADING_TEXT, title,
+ PLACES_SIDEBAR_COLUMN_EJECT, FALSE,
+ PLACES_SIDEBAR_COLUMN_NO_EJECT, TRUE,
+ -1);
+
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sidebar->filter_model));
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (sidebar->filter_model),
+ &child_iter,
+ &iter);
+
+ return child_iter;
+}
+
+static void
+check_heading_for_section (CajaPlacesSidebar *sidebar,
+ SectionType section_type)
+{
+ switch (section_type) {
+ case SECTION_DEVICES:
+ if (!sidebar->devices_header_added) {
+ add_heading (sidebar, SECTION_DEVICES,
+ _("Devices"));
+ sidebar->devices_header_added = TRUE;
+ }
+
+ break;
+ case SECTION_BOOKMARKS:
+ if (!sidebar->bookmarks_header_added) {
+ add_heading (sidebar, SECTION_BOOKMARKS,
+ _("Bookmarks"));
+ sidebar->bookmarks_header_added = TRUE;
+ }
+
+ break;
+ default:
+ break;
+ }
+}
+
static GtkTreeIter
add_place (CajaPlacesSidebar *sidebar,
PlaceType place_type,
+ SectionType section_type,
const char *name,
GIcon *icon,
const char *uri,
@@ -225,16 +341,20 @@ add_place (CajaPlacesSidebar *sidebar,
{
GdkPixbuf *pixbuf;
GtkTreeIter iter, child_iter;
+ GdkPixbuf *eject;
CajaIconInfo *icon_info;
int icon_size;
gboolean show_eject, show_unmount;
gboolean show_eject_button;
+ check_heading_for_section (sidebar, section_type);
+
icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
icon_info = caja_icon_info_lookup (icon, icon_size);
pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size);
g_object_unref (icon_info);
+
check_unmount_and_eject (mount, volume, drive,
&show_unmount, &show_eject);
@@ -252,6 +372,12 @@ add_place (CajaPlacesSidebar *sidebar,
show_eject_button = (show_unmount || show_eject);
}
+ if (show_eject_button) {
+ eject = get_eject_icon (FALSE);
+ } else {
+ eject = NULL;
+ }
+
gtk_list_store_append (sidebar->store, &iter);
gtk_list_store_set (sidebar->store, &iter,
PLACES_SIDEBAR_COLUMN_ICON, pixbuf,
@@ -265,8 +391,9 @@ add_place (CajaPlacesSidebar *sidebar,
PLACES_SIDEBAR_COLUMN_EJECT, show_eject_button,
PLACES_SIDEBAR_COLUMN_NO_EJECT, !show_eject_button,
PLACES_SIDEBAR_COLUMN_BOOKMARK, place_type != PLACES_BOOKMARK,
- PLACES_SIDEBAR_COLUMN_NO_BOOKMARK, place_type == PLACES_BOOKMARK,
PLACES_SIDEBAR_COLUMN_TOOLTIP, tooltip,
+ PLACES_SIDEBAR_COLUMN_EJECT_ICON, eject,
+ PLACES_SIDEBAR_COLUMN_SECTION_TYPE, section_type,
-1);
if (pixbuf != NULL)
@@ -290,7 +417,7 @@ compare_for_selection (CajaPlacesSidebar *sidebar,
{
int res;
- res = eel_strcmp (added_uri, last_uri);
+ res = g_strcmp0 (added_uri, last_uri);
if (res == 0)
{
@@ -302,7 +429,7 @@ compare_for_selection (CajaPlacesSidebar *sidebar,
*path = gtk_tree_model_get_path (sidebar->filter_model,
iter);
}
- else if (eel_strcmp (location, added_uri) == 0)
+ else if (g_strcmp0 (location, added_uri) == 0)
{
if (*path == NULL)
{
@@ -317,7 +444,7 @@ update_places (CajaPlacesSidebar *sidebar)
{
CajaBookmark *bookmark;
GtkTreeSelection *selection;
- GtkTreeIter iter, last_iter;
+ GtkTreeIter last_iter;
GtkTreePath *select_path;
GtkTreeModel *model;
GVolumeMonitor *volume_monitor;
@@ -329,10 +456,13 @@ update_places (CajaPlacesSidebar *sidebar)
GVolume *volume;
int bookmark_count, index;
char *location, *mount_uri, *name, *desktop_path, *last_uri;
+ const gchar *path;
GIcon *icon;
GFile *root;
CajaWindowSlotInfo *slot;
char *tooltip;
+ GList *network_mounts;
+ CajaFile *file;
model = NULL;
last_uri = NULL;
@@ -347,70 +477,17 @@ update_places (CajaPlacesSidebar *sidebar)
}
gtk_list_store_clear (sidebar->store);
+ sidebar->devices_header_added = FALSE;
+ sidebar->bookmarks_header_added = FALSE;
+
slot = caja_window_info_get_active_slot (sidebar->window);
location = caja_window_slot_info_get_current_location (slot);
- /* add built in bookmarks */
- desktop_path = caja_get_desktop_directory ();
-
- if (strcmp (g_get_home_dir(), desktop_path) != 0)
- {
- char *display_name;
-
- mount_uri = caja_get_home_directory_uri ();
- display_name = g_filename_display_basename (g_get_home_dir ());
- icon = g_themed_icon_new (CAJA_ICON_HOME);
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- display_name, icon,
- mount_uri, NULL, NULL, NULL, 0,
- _("Open your personal folder"));
- g_object_unref (icon);
- g_free (display_name);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
- g_free (mount_uri);
- }
-
- mount_uri = g_filename_to_uri (desktop_path, NULL, NULL);
- icon = g_themed_icon_new (CAJA_ICON_DESKTOP);
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- _("Desktop"), icon,
- mount_uri, NULL, NULL, NULL, 0,
- _("Open the contents of your desktop in a folder"));
- g_object_unref (icon);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
- g_free (mount_uri);
- g_free (desktop_path);
-
- mount_uri = "file:///"; /* No need to strdup */
- icon = g_themed_icon_new (CAJA_ICON_FILESYSTEM);
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- _("File System"), icon,
- mount_uri, NULL, NULL, NULL, 0,
- _("Open the contents of the File System"));
- g_object_unref (icon);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
-
- mount_uri = "network:///"; /* No need to strdup */
- icon = g_themed_icon_new (CAJA_ICON_NETWORK);
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- _("Network"), icon,
- mount_uri, NULL, NULL, NULL, 0,
- _("Browse the contents of the network"));
- g_object_unref (icon);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
-
volume_monitor = sidebar->volume_monitor;
/* first go through all connected drives */
drives = g_volume_monitor_get_connected_drives (volume_monitor);
+
for (l = drives; l != NULL; l = l->next)
{
drive = l->data;
@@ -430,7 +507,9 @@ update_places (CajaPlacesSidebar *sidebar)
mount_uri = g_file_get_uri (root);
name = g_mount_get_name (mount);
tooltip = g_file_get_parse_name (root);
+
last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
+ SECTION_DEVICES,
name, icon, mount_uri,
drive, volume, mount, 0, tooltip);
compare_for_selection (sidebar,
@@ -456,7 +535,9 @@ update_places (CajaPlacesSidebar *sidebar)
icon = g_volume_get_icon (volume);
name = g_volume_get_name (volume);
tooltip = g_strdup_printf (_("Mount and open %s"), name);
+
last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
+ SECTION_DEVICES,
name, icon, NULL,
drive, volume, NULL, 0, tooltip);
g_object_unref (icon);
@@ -482,7 +563,9 @@ update_places (CajaPlacesSidebar *sidebar)
icon = g_drive_get_icon (drive);
name = g_drive_get_name (drive);
tooltip = g_strdup_printf (_("Mount and open %s"), name);
+
last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_DEVICES,
name, icon, NULL,
drive, NULL, NULL, 0, tooltip);
g_object_unref (icon);
@@ -516,6 +599,7 @@ update_places (CajaPlacesSidebar *sidebar)
g_object_unref (root);
name = g_mount_get_name (mount);
last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
+ SECTION_DEVICES,
name, icon, mount_uri,
NULL, volume, mount, 0, tooltip);
compare_for_selection (sidebar,
@@ -533,6 +617,7 @@ update_places (CajaPlacesSidebar *sidebar)
icon = g_volume_get_icon (volume);
name = g_volume_get_name (volume);
last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
+ SECTION_DEVICES,
name, icon, NULL,
NULL, volume, NULL, 0, name);
g_object_unref (icon);
@@ -542,8 +627,140 @@ update_places (CajaPlacesSidebar *sidebar)
}
g_list_free (volumes);
+ /* add bookmarks */
+ bookmark_count = caja_bookmark_list_length (sidebar->bookmarks);
+
+ for (index = 0; index < bookmark_count; ++index) {
+ bookmark = caja_bookmark_list_item_at (sidebar->bookmarks, index);
+
+ if (caja_bookmark_uri_known_not_to_exist (bookmark)) {
+ continue;
+ }
+
+ root = caja_bookmark_get_location (bookmark);
+ file = caja_file_get (root);
+
+ if (is_built_in_bookmark (file)) {
+ g_object_unref (root);
+ caja_file_unref (file);
+ continue;
+ }
+
+ name = caja_bookmark_get_name (bookmark);
+ icon = caja_bookmark_get_icon (bookmark);
+ mount_uri = caja_bookmark_get_uri (bookmark);
+ tooltip = g_file_get_parse_name (root);
+
+ last_iter = add_place (sidebar, PLACES_BOOKMARK,
+ SECTION_BOOKMARKS,
+ name, icon, mount_uri,
+ NULL, NULL, NULL, index,
+ tooltip);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (name);
+ g_object_unref (root);
+ g_object_unref (icon);
+ g_free (mount_uri);
+ g_free (tooltip);
+ }
+
+ last_iter = add_heading (sidebar, SECTION_COMPUTER,
+ _("Computer"));
+
+ /* add built in bookmarks */
+ desktop_path = caja_get_desktop_directory ();
+
+ /* home folder */
+ if (strcmp (g_get_home_dir(), desktop_path) != 0) {
+ char *display_name;
+
+ mount_uri = caja_get_home_directory_uri ();
+ display_name = g_filename_display_basename (g_get_home_dir ());
+ icon = g_themed_icon_new (CAJA_ICON_HOME);
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ display_name, icon,
+ mount_uri, NULL, NULL, NULL, 0,
+ _("Open your personal folder"));
+ g_object_unref (icon);
+ g_free (display_name);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (mount_uri);
+ }
+
+ /* desktop */
+ mount_uri = g_filename_to_uri (desktop_path, NULL, NULL);
+ icon = g_themed_icon_new (CAJA_ICON_DESKTOP);
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ _("Desktop"), icon,
+ mount_uri, NULL, NULL, NULL, 0,
+ _("Open the contents of your desktop in a folder"));
+ g_object_unref (icon);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (mount_uri);
+ g_free (desktop_path);
+
+ /* file system root */
+ mount_uri = "file:///"; /* No need to strdup */
+ icon = g_themed_icon_new (CAJA_ICON_FILESYSTEM);
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ _("File System"), icon,
+ mount_uri, NULL, NULL, NULL, 0,
+ _("Open the contents of the File System"));
+ g_object_unref (icon);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+
+
+ /* XDG directories */
+ for (index = 0; index < G_USER_N_DIRECTORIES; index++) {
+
+ if (index == G_USER_DIRECTORY_DESKTOP ||
+ index == G_USER_DIRECTORY_TEMPLATES ||
+ index == G_USER_DIRECTORY_PUBLIC_SHARE) {
+ continue;
+ }
+
+ path = g_get_user_special_dir (index);
+
+ if (!path) {
+ continue;
+ }
+
+ root = g_file_new_for_path (path);
+ name = g_file_get_basename (root);
+ icon = caja_user_special_directory_get_gicon (index);
+ mount_uri = g_file_get_uri (root);
+ tooltip = g_file_get_parse_name (root);
+
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ name, icon, mount_uri,
+ NULL, NULL, NULL, 0,
+ tooltip);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (name);
+ g_object_unref (root);
+ g_object_unref (icon);
+ g_free (mount_uri);
+ g_free (tooltip);
+ }
+
/* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */
+ network_mounts = NULL;
mounts = g_volume_monitor_get_mounts (volume_monitor);
+
for (l = mounts; l != NULL; l = l->next)
{
mount = l->data;
@@ -559,12 +776,19 @@ update_places (CajaPlacesSidebar *sidebar)
g_object_unref (mount);
continue;
}
- icon = g_mount_get_icon (mount);
root = g_mount_get_default_location (mount);
+
+ if (!g_file_is_native (root)) {
+ network_mounts = g_list_prepend (network_mounts, g_object_ref (mount));
+ continue;
+ }
+
+ icon = g_mount_get_icon (mount);
mount_uri = g_file_get_uri (root);
name = g_mount_get_name (mount);
tooltip = g_file_get_parse_name (root);
last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
+ SECTION_COMPUTER,
name, icon, mount_uri,
NULL, NULL, mount, 0, tooltip);
compare_for_selection (sidebar,
@@ -582,6 +806,7 @@ update_places (CajaPlacesSidebar *sidebar)
mount_uri = "trash:///"; /* No need to strdup */
icon = caja_trash_monitor_get_icon ();
last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
_("Trash"), icon, mount_uri,
NULL, NULL, NULL, 0,
_("Open the trash"));
@@ -590,75 +815,62 @@ update_places (CajaPlacesSidebar *sidebar)
&last_iter, &select_path);
g_object_unref (icon);
- /* add separator */
-
- gtk_list_store_append (sidebar->store, &iter);
- gtk_list_store_set (sidebar->store, &iter,
- PLACES_SIDEBAR_COLUMN_ROW_TYPE, PLACES_SEPARATOR,
- -1);
-
- /* add bookmarks */
-
- bookmark_count = caja_bookmark_list_length (sidebar->bookmarks);
- for (index = 0; index < bookmark_count; ++index)
- {
- bookmark = caja_bookmark_list_item_at (sidebar->bookmarks, index);
+ /* network */
+ last_iter = add_heading (sidebar, SECTION_NETWORK,
+ _("Network"));
- if (caja_bookmark_uri_known_not_to_exist (bookmark))
- {
- continue;
- }
-
- name = caja_bookmark_get_name (bookmark);
- icon = caja_bookmark_get_icon (bookmark);
- mount_uri = caja_bookmark_get_uri (bookmark);
- root = caja_bookmark_get_location (bookmark);
+ network_mounts = g_list_reverse (network_mounts);
+ for (l = network_mounts; l != NULL; l = l->next) {
+ mount = l->data;
+ root = g_mount_get_default_location (mount);
+ icon = g_mount_get_icon (mount);
+ mount_uri = g_file_get_uri (root);
+ name = g_mount_get_name (mount);
tooltip = g_file_get_parse_name (root);
- last_iter = add_place (sidebar, PLACES_BOOKMARK,
+ last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
+ SECTION_NETWORK,
name, icon, mount_uri,
- NULL, NULL, NULL, index,
- tooltip);
+ NULL, NULL, mount, 0, tooltip);
compare_for_selection (sidebar,
location, mount_uri, last_uri,
&last_iter, &select_path);
- g_free (name);
g_object_unref (root);
+ g_object_unref (mount);
g_object_unref (icon);
+ g_free (name);
g_free (mount_uri);
g_free (tooltip);
}
+
+ g_list_foreach (network_mounts, (GFunc) g_object_unref, NULL);
+ g_list_free(network_mounts);
+
+ /* network:// */
+ mount_uri = "network:///"; /* No need to strdup */
+ icon = g_themed_icon_new (CAJA_ICON_NETWORK);
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_NETWORK,
+ _("Browse Network"), icon,
+ mount_uri, NULL, NULL, NULL, 0,
+ _("Browse the contents of the network"));
+ g_object_unref (icon);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+
g_free (location);
- if (select_path != NULL)
- {
+ if (select_path != NULL) {
gtk_tree_selection_select_path (selection, select_path);
}
- if (select_path != NULL)
- {
+ if (select_path != NULL) {
gtk_tree_path_free (select_path);
}
g_free (last_uri);
}
-static gboolean
-caja_shortcuts_row_separator_func (GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer data)
-{
- PlaceType type;
-
- gtk_tree_model_get (model, iter, PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, -1);
-
- if (type == PLACES_SEPARATOR)
- {
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
mount_added_callback (GVolumeMonitor *volume_monitor,
GMount *mount,
@@ -732,11 +944,11 @@ drive_changed_callback (GVolumeMonitor *volume_monitor,
}
static gboolean
-clicked_eject_button (CajaPlacesSidebar *sidebar,
- GtkTreePath **path)
+over_eject_button (CajaPlacesSidebar *sidebar,
+ gint x,
+ gint y,
+ GtkTreePath **path)
{
- GdkEvent *event = gtk_get_current_event ();
- GdkEventButton *button_event = (GdkEventButton *) event;
GtkTreeViewColumn *column;
GtkTextDirection direction;
int width, total_width;
@@ -748,19 +960,16 @@ clicked_eject_button (CajaPlacesSidebar *sidebar,
*path = NULL;
model = gtk_tree_view_get_model (sidebar->tree_view);
- if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) &&
- gtk_tree_view_get_path_at_pos (sidebar->tree_view,
- button_event->x, button_event->y,
- path, &column, NULL, NULL))
- {
+ if (gtk_tree_view_get_path_at_pos (sidebar->tree_view,
+ x, y,
+ path, &column, NULL, NULL)) {
gtk_tree_model_get_iter (model, &iter, *path);
gtk_tree_model_get (model, &iter,
PLACES_SIDEBAR_COLUMN_EJECT, &show_eject,
-1);
- if (!show_eject)
- {
+ if (!show_eject) {
goto out;
}
@@ -769,12 +978,21 @@ clicked_eject_button (CajaPlacesSidebar *sidebar,
gtk_widget_style_get (GTK_WIDGET (sidebar->tree_view),
"horizontal-separator", &width,
NULL);
- total_width += width / 2;
+ total_width += width;
direction = gtk_widget_get_direction (GTK_WIDGET (sidebar->tree_view));
- if (direction != GTK_TEXT_DIR_RTL)
- {
+ if (direction != GTK_TEXT_DIR_RTL) {
gtk_tree_view_column_cell_get_position (column,
+ sidebar->padding_cell_renderer,
+ NULL, &width);
+ total_width += width;
+
+ gtk_tree_view_column_cell_get_position (column,
+ sidebar->icon_padding_cell_renderer,
+ NULL, &width);
+ total_width += width;
+
+ gtk_tree_view_column_cell_get_position (column,
sidebar->icon_cell_renderer,
NULL, &width);
total_width += width;
@@ -789,17 +1007,31 @@ clicked_eject_button (CajaPlacesSidebar *sidebar,
eject_button_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
- if (button_event->x - total_width >= 0 &&
- button_event->x - total_width <= eject_button_size)
- {
+ if (x - total_width >= 0 &&
+ x - total_width <= eject_button_size) {
return TRUE;
}
}
out:
- if (*path != NULL)
- {
+ if (*path != NULL) {
gtk_tree_path_free (*path);
+ *path = NULL;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+clicked_eject_button (CajaPlacesSidebar *sidebar,
+ GtkTreePath **path)
+{
+ GdkEvent *event = gtk_get_current_event ();
+ GdkEventButton *button_event = (GdkEventButton *) event;
+
+ if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) &&
+ over_eject_button (sidebar, button_event->x, button_event->y, path)) {
+ return TRUE;
}
return FALSE;
@@ -855,103 +1087,75 @@ loading_uri_callback (CajaWindowInfo *window,
}
}
-
-static unsigned int
-get_bookmark_index (GtkTreeView *tree_view)
+/* Computes the appropriate row and position for dropping */
+static gboolean
+compute_drop_position (GtkTreeView *tree_view,
+ int x,
+ int y,
+ GtkTreePath **path,
+ GtkTreeViewDropPosition *pos,
+ CajaPlacesSidebar *sidebar)
{
GtkTreeModel *model;
- GtkTreePath *p;
GtkTreeIter iter;
PlaceType place_type;
- int bookmark_index;
+ SectionType section_type;
+
+ if (!gtk_tree_view_get_dest_row_at_pos (tree_view,
+ x,
+ y,
+ path,
+ pos)) {
+ return FALSE;
+ }
model = gtk_tree_view_get_model (tree_view);
- bookmark_index = -1;
+ gtk_tree_model_get_iter (model, &iter, *path);
+ gtk_tree_model_get (model, &iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type,
+ PLACES_SIDEBAR_COLUMN_SECTION_TYPE, &section_type,
+ -1);
- /* find separator */
- p = gtk_tree_path_new_first ();
- while (p != NULL)
- {
- gtk_tree_model_get_iter (model, &iter, p);
- gtk_tree_model_get (model, &iter,
- PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type,
- -1);
+ if (place_type == PLACES_HEADING && section_type != SECTION_BOOKMARKS) {
+ /* never drop on headings, but special case the bookmarks heading,
+ * so we can drop bookmarks in between it and the first item.
+ */
- if (place_type == PLACES_SEPARATOR)
- {
- bookmark_index = *gtk_tree_path_get_indices (p) + 1;
- break;
- }
+ gtk_tree_path_free (*path);
+ *path = NULL;
- gtk_tree_path_next (p);
+ return FALSE;
}
- gtk_tree_path_free (p);
-
- g_assert (bookmark_index >= 0);
-
- return bookmark_index;
-}
-/* Computes the appropriate row and position for dropping */
-static void
-compute_drop_position (GtkTreeView *tree_view,
- int x,
- int y,
- GtkTreePath **path,
- GtkTreeViewDropPosition *pos,
- CajaPlacesSidebar *sidebar)
-{
- int bookmarks_index;
- int num_rows;
- int row;
+ if (section_type != SECTION_BOOKMARKS &&
+ sidebar->drag_data_received &&
+ sidebar->drag_data_info == GTK_TREE_MODEL_ROW) {
+ /* don't allow dropping bookmarks into non-bookmark areas */
- bookmarks_index = get_bookmark_index (tree_view);
-
- num_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (sidebar->filter_model), NULL);
+ gtk_tree_path_free (*path);
+ *path = NULL;
- if (!gtk_tree_view_get_dest_row_at_pos (tree_view,
- x,
- y,
- path,
- pos))
- {
- row = num_rows - 1;
- *path = gtk_tree_path_new_from_indices (row, -1);
- *pos = GTK_TREE_VIEW_DROP_AFTER;
- return;
+ return FALSE;
}
- row = *gtk_tree_path_get_indices (*path);
- gtk_tree_path_free (*path);
-
- if (row == bookmarks_index - 1)
- {
- /* Only allow to drop after separator */
+ if (section_type == SECTION_BOOKMARKS) {
*pos = GTK_TREE_VIEW_DROP_AFTER;
- }
- else if (row < bookmarks_index)
- {
- /* Hardcoded shortcuts can only be dragged into */
+ } else {
+ /* non-bookmark shortcuts can only be dragged into */
*pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
}
- else if (row >= num_rows)
- {
- row = num_rows - 1;
- *pos = GTK_TREE_VIEW_DROP_AFTER;
- }
- else if (*pos != GTK_TREE_VIEW_DROP_BEFORE &&
- sidebar->drag_data_received &&
- sidebar->drag_data_info == GTK_TREE_MODEL_ROW)
- {
+
+ if (*pos != GTK_TREE_VIEW_DROP_BEFORE &&
+ sidebar->drag_data_received &&
+ sidebar->drag_data_info == GTK_TREE_MODEL_ROW) {
/* bookmark rows are never dragged into other bookmark rows */
*pos = GTK_TREE_VIEW_DROP_AFTER;
}
- *path = gtk_tree_path_new_from_indices (row, -1);
+ return TRUE;
}
-
static gboolean
get_drag_data (GtkTreeView *tree_view,
GdkDragContext *context,
@@ -989,7 +1193,8 @@ free_drag_data (CajaPlacesSidebar *sidebar)
static gboolean
can_accept_file_as_bookmark (CajaFile *file)
{
- return caja_file_is_directory (file);
+ return (caja_file_is_directory (file) &&
+ !is_built_in_bookmark (file));
}
static gboolean
@@ -1028,8 +1233,9 @@ drag_motion_callback (GtkTreeView *tree_view,
GtkTreePath *path;
GtkTreeViewDropPosition pos;
int action;
- GtkTreeIter iter, child_iter;
+ GtkTreeIter iter;
char *uri;
+ gboolean res;
if (!sidebar->drag_data_received)
{
@@ -1039,7 +1245,12 @@ drag_motion_callback (GtkTreeView *tree_view,
}
}
- compute_drop_position (tree_view, x, y, &path, &pos, sidebar);
+ path = NULL;
+ res = compute_drop_position (tree_view, x, y, &path, &pos, sidebar);
+
+ if (!res) {
+ goto out;
+ }
if (pos == GTK_TREE_VIEW_DROP_BEFORE ||
pos == GTK_TREE_VIEW_DROP_AFTER )
@@ -1068,11 +1279,8 @@ drag_motion_callback (GtkTreeView *tree_view,
{
gtk_tree_model_get_iter (sidebar->filter_model,
&iter, path);
- gtk_tree_model_filter_convert_iter_to_child_iter (
- GTK_TREE_MODEL_FILTER (sidebar->filter_model),
- &child_iter, &iter);
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store),
- &child_iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model),
+ &iter,
PLACES_SIDEBAR_COLUMN_URI, &uri,
-1);
caja_drag_default_drop_action_for_icons (context, uri,
@@ -1082,8 +1290,15 @@ drag_motion_callback (GtkTreeView *tree_view,
}
}
- gtk_tree_view_set_drag_dest_row (tree_view, path, pos);
- gtk_tree_path_free (path);
+ if (action != 0) {
+ gtk_tree_view_set_drag_dest_row (tree_view, path, pos);
+ }
+
+ if (path != NULL) {
+ gtk_tree_path_free (path);
+ }
+
+ out:
g_signal_stop_emission_by_name (tree_view, "drag-motion");
if (action != 0)
@@ -1209,17 +1424,10 @@ get_selected_iter (CajaPlacesSidebar *sidebar,
GtkTreeIter *iter)
{
GtkTreeSelection *selection;
- GtkTreeIter parent_iter;
selection = gtk_tree_view_get_selection (sidebar->tree_view);
- if (!gtk_tree_selection_get_selected (selection, NULL, &parent_iter))
- {
- return FALSE;
- }
- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (sidebar->filter_model),
- iter,
- &parent_iter);
- return TRUE;
+
+ return gtk_tree_selection_get_selected (selection, NULL, iter);
}
/* Reorders the selected bookmark to the specified position */
@@ -1236,7 +1444,7 @@ reorder_bookmarks (CajaPlacesSidebar *sidebar,
if (!get_selected_iter (sidebar, &iter))
g_assert_not_reached ();
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
PLACES_SIDEBAR_COLUMN_INDEX, &old_position,
-1);
@@ -1270,7 +1478,8 @@ drag_data_received_callback (GtkWidget *widget,
GtkTreeModel *model;
char *drop_uri;
GList *selection_list, *uris;
- PlaceType type;
+ PlaceType place_type;
+ SectionType section_type;
gboolean success;
tree_view = GTK_TREE_VIEW (widget);
@@ -1313,18 +1522,17 @@ drag_data_received_callback (GtkWidget *widget,
}
gtk_tree_model_get (model, &iter,
- PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
+ PLACES_SIDEBAR_COLUMN_SECTION_TYPE, &section_type,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type,
PLACES_SIDEBAR_COLUMN_INDEX, &position,
-1);
- if (type != PLACES_SEPARATOR && type != PLACES_BOOKMARK)
- {
+ if (section_type != SECTION_BOOKMARKS) {
goto out;
}
- if (type == PLACES_BOOKMARK &&
- tree_pos == GTK_TREE_VIEW_DROP_AFTER)
- {
+ if (tree_pos == GTK_TREE_VIEW_DROP_AFTER && place_type != PLACES_HEADING) {
+ /* heading already has position 0 */
position++;
}
@@ -1531,7 +1739,7 @@ bookmarks_check_popup_sensitivity (CajaPlacesSidebar *sidebar)
if (get_selected_iter (sidebar, &iter))
{
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
PLACES_SIDEBAR_COLUMN_DRIVE, &drive,
PLACES_SIDEBAR_COLUMN_VOLUME, &volume,
@@ -1556,16 +1764,16 @@ bookmarks_check_popup_sensitivity (CajaPlacesSidebar *sidebar)
show_empty_trash = (uri != NULL) &&
(!strcmp (uri, "trash:///"));
- eel_gtk_widget_set_shown (sidebar->popup_menu_separator_item,
+ gtk_widget_set_visible (sidebar->popup_menu_separator_item,
show_mount || show_unmount || show_eject || show_format || show_empty_trash);
- eel_gtk_widget_set_shown (sidebar->popup_menu_mount_item, show_mount);
- eel_gtk_widget_set_shown (sidebar->popup_menu_unmount_item, show_unmount);
- eel_gtk_widget_set_shown (sidebar->popup_menu_eject_item, show_eject);
- eel_gtk_widget_set_shown (sidebar->popup_menu_rescan_item, show_rescan);
- eel_gtk_widget_set_shown (sidebar->popup_menu_format_item, show_format);
- eel_gtk_widget_set_shown (sidebar->popup_menu_start_item, show_start);
- eel_gtk_widget_set_shown (sidebar->popup_menu_stop_item, show_stop);
- eel_gtk_widget_set_shown (sidebar->popup_menu_empty_trash_item, show_empty_trash);
+ gtk_widget_set_visible (sidebar->popup_menu_mount_item, show_mount);
+ gtk_widget_set_visible (sidebar->popup_menu_unmount_item, show_unmount);
+ gtk_widget_set_visible (sidebar->popup_menu_eject_item, show_eject);
+ gtk_widget_set_visible (sidebar->popup_menu_rescan_item, show_rescan);
+ gtk_widget_set_visible (sidebar->popup_menu_format_item, show_format);
+ gtk_widget_set_visible (sidebar->popup_menu_start_item, show_start);
+ gtk_widget_set_visible (sidebar->popup_menu_stop_item, show_stop);
+ gtk_widget_set_visible (sidebar->popup_menu_empty_trash_item, show_empty_trash);
/* Adjust start/stop items to reflect the type of the drive */
gtk_menu_item_set_label (GTK_MENU_ITEM (sidebar->popup_menu_start_item), _("_Start"));
@@ -1826,10 +2034,10 @@ rename_selected_bookmark (CajaPlacesSidebar *sidebar)
if (get_selected_iter (sidebar, &iter))
{
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->store), &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->filter_model), &iter);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (sidebar->tree_view), 0);
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
- cell = g_list_nth_data (renderers, 3);
+ cell = g_list_nth_data (renderers, 6);
g_list_free (renderers);
g_object_set (cell, "editable", TRUE, NULL);
gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (sidebar->tree_view),
@@ -1858,7 +2066,7 @@ remove_selected_bookmarks (CajaPlacesSidebar *sidebar)
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
-1);
@@ -1867,7 +2075,7 @@ remove_selected_bookmarks (CajaPlacesSidebar *sidebar)
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_INDEX, &index,
-1);
@@ -1893,7 +2101,7 @@ mount_shortcut_cb (GtkMenuItem *item,
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_VOLUME, &volume,
-1);
@@ -1938,7 +2146,7 @@ do_unmount_selection (CajaPlacesSidebar *sidebar)
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_MOUNT, &mount,
-1);
@@ -2093,7 +2301,7 @@ eject_shortcut_cb (GtkMenuItem *item,
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_MOUNT, &mount,
PLACES_SIDEBAR_COLUMN_VOLUME, &volume,
PLACES_SIDEBAR_COLUMN_DRIVE, &drive,
@@ -2163,14 +2371,12 @@ eject_or_unmount_selection (CajaPlacesSidebar *sidebar)
GtkTreePath *path;
gboolean ret;
- if (!get_selected_iter (sidebar, &iter))
- {
+ if (!get_selected_iter (sidebar, &iter)) {
return FALSE;
}
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->store), &iter);
- if (path == NULL)
- {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->filter_model), &iter);
+ if (path == NULL) {
return FALSE;
}
@@ -2219,7 +2425,7 @@ rescan_shortcut_cb (GtkMenuItem *item,
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_DRIVE, &drive,
-1);
@@ -2275,7 +2481,7 @@ start_shortcut_cb (GtkMenuItem *item,
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_DRIVE, &drive,
-1);
@@ -2335,7 +2541,7 @@ stop_shortcut_cb (GtkMenuItem *item,
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_DRIVE, &drive,
-1);
@@ -2372,10 +2578,10 @@ bookmarks_key_press_event_cb (GtkWidget *widget,
modifiers = gtk_accelerator_get_default_mod_mask ();
- if (event->keyval == GDK_Return ||
- event->keyval == GDK_KP_Enter ||
- event->keyval == GDK_ISO_Enter ||
- event->keyval == GDK_space)
+ if (event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter ||
+ event->keyval == GDK_KEY_space)
{
if ((event->state & modifiers) == GDK_SHIFT_MASK)
flags = CAJA_WINDOW_OPEN_FLAG_NEW_TAB;
@@ -2391,21 +2597,21 @@ bookmarks_key_press_event_cb (GtkWidget *widget,
return TRUE;
}
- if (event->keyval == GDK_Down &&
+ if (event->keyval == GDK_KEY_Down &&
(event->state & modifiers) == GDK_MOD1_MASK)
{
return eject_or_unmount_selection (sidebar);
}
- if ((event->keyval == GDK_Delete
- || event->keyval == GDK_KP_Delete)
+ if ((event->keyval == GDK_KEY_Delete
+ || event->keyval == GDK_KEY_KP_Delete)
&& (event->state & modifiers) == 0)
{
remove_selected_bookmarks (sidebar);
return TRUE;
}
- if ((event->keyval == GDK_F2)
+ if ((event->keyval == GDK_KEY_F2)
&& (event->state & modifiers) == 0)
{
rename_selected_bookmark (sidebar);
@@ -2572,6 +2778,8 @@ bookmarks_button_release_event_cb (GtkWidget *widget,
GtkTreeView *tree_view;
gboolean ret;
+ path = NULL;
+
if (event->type != GDK_BUTTON_RELEASE)
{
return TRUE;
@@ -2606,6 +2814,104 @@ bookmarks_button_release_event_cb (GtkWidget *widget,
return FALSE;
}
+static void
+update_eject_buttons (CajaPlacesSidebar *sidebar,
+ GtkTreePath *path)
+{
+ GtkTreeIter iter;
+ gboolean icon_visible, path_same;
+
+ icon_visible = TRUE;
+
+ if (path == NULL && sidebar->eject_highlight_path == NULL) {
+ /* Both are null - highlight up to date */
+ return;
+ }
+
+ path_same = (path != NULL) &&
+ (sidebar->eject_highlight_path != NULL) &&
+ (gtk_tree_path_compare (sidebar->eject_highlight_path, path) == 0);
+
+ if (path_same) {
+ /* Same path - highlight up to date */
+ return;
+ }
+
+ if (path) {
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->filter_model),
+ &iter,
+ path);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model),
+ &iter,
+ PLACES_SIDEBAR_COLUMN_EJECT, &icon_visible,
+ -1);
+ }
+
+ if (!icon_visible || path == NULL || !path_same) {
+ /* remove highlighting and reset the saved path, as we are leaving
+ * an eject button area.
+ */
+ if (sidebar->eject_highlight_path) {
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store),
+ &iter,
+ sidebar->eject_highlight_path);
+
+ gtk_list_store_set (sidebar->store,
+ &iter,
+ PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (FALSE),
+ -1);
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sidebar->filter_model));
+
+ gtk_tree_path_free (sidebar->eject_highlight_path);
+ sidebar->eject_highlight_path = NULL;
+ }
+
+ if (!icon_visible) {
+ return;
+ }
+ }
+
+ if (path != NULL) {
+ /* add highlighting to the selected path, as the icon is visible and
+ * we're hovering it.
+ */
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store),
+ &iter,
+ path);
+ gtk_list_store_set (sidebar->store,
+ &iter,
+ PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE),
+ -1);
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sidebar->filter_model));
+
+ sidebar->eject_highlight_path = gtk_tree_path_copy (path);
+ }
+}
+
+static gboolean
+bookmarks_motion_event_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ CajaPlacesSidebar *sidebar)
+{
+ GtkTreePath *path;
+ GtkTreeModel *model;
+
+ model = GTK_TREE_MODEL (sidebar->filter_model);
+ path = NULL;
+
+ if (over_eject_button (sidebar, event->x, event->y, &path)) {
+ update_eject_buttons (sidebar, path);
+ gtk_tree_path_free (path);
+
+ return TRUE;
+ }
+
+ update_eject_buttons (sidebar, NULL);
+
+ return FALSE;
+}
+
/* Callback used when a button is pressed on the shortcuts list.
* We trap button 3 to bring up a popup menu, and button 2 to
* open in a new tab.
@@ -2669,8 +2975,8 @@ bookmarks_edited (GtkCellRenderer *cell,
g_object_set (cell, "editable", FALSE, NULL);
path = gtk_tree_path_new_from_string (path_string);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), &iter, path);
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->filter_model), &iter, path);
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter,
PLACES_SIDEBAR_COLUMN_INDEX, &index,
-1);
gtk_tree_path_free (path);
@@ -2704,6 +3010,107 @@ trash_state_changed_cb (CajaTrashMonitor *trash_monitor,
bookmarks_check_popup_sensitivity (sidebar);
}
+static gboolean
+tree_selection_func (GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ gpointer user_data)
+{
+ GtkTreeIter iter;
+ PlaceType row_type;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &row_type,
+ -1);
+
+ if (row_type == PLACES_HEADING) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+icon_cell_renderer_func (GtkTreeViewColumn *column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ CajaPlacesSidebar *sidebar;
+ PlaceType type;
+
+ sidebar = user_data;
+
+ gtk_tree_model_get (model, iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
+ -1);
+
+ if (type == PLACES_HEADING) {
+ g_object_set (cell,
+ "visible", FALSE,
+ NULL);
+ } else {
+ g_object_set (cell,
+ "visible", TRUE,
+ NULL);
+ }
+}
+
+static void
+padding_cell_renderer_func (GtkTreeViewColumn *column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ PlaceType type;
+
+ gtk_tree_model_get (model, iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
+ -1);
+
+ if (type == PLACES_HEADING) {
+ g_object_set (cell,
+ "visible", FALSE,
+ "xpad", 0,
+ "ypad", 0,
+ NULL);
+ } else {
+ g_object_set (cell,
+ "visible", TRUE,
+ "xpad", 3,
+ "ypad", 3,
+ NULL);
+ }
+}
+
+static void
+heading_cell_renderer_func (GtkTreeViewColumn *column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ PlaceType type;
+
+ gtk_tree_model_get (model, iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
+ -1);
+
+ if (type == PLACES_HEADING) {
+ g_object_set (cell,
+ "visible", TRUE,
+ NULL);
+ } else {
+ g_object_set (cell,
+ "visible", FALSE,
+ NULL);
+ }
+}
+
static void
caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
{
@@ -2727,14 +3134,50 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
col = GTK_TREE_VIEW_COLUMN (gtk_tree_view_column_new ());
+ /* initial padding */
+ cell = gtk_cell_renderer_text_new ();
+ sidebar->padding_cell_renderer = cell;
+ gtk_tree_view_column_pack_start (col, cell, FALSE);
+ g_object_set (cell,
+ "xpad", 6,
+ NULL);
+
+ /* headings */
+ cell = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (col, cell, FALSE);
+ gtk_tree_view_column_set_attributes (col, cell,
+ "text", PLACES_SIDEBAR_COLUMN_HEADING_TEXT,
+ NULL);
+ g_object_set (cell,
+ "weight", PANGO_WEIGHT_BOLD,
+ "weight-set", TRUE,
+ "ypad", 6,
+ "xpad", 0,
+ NULL);
+ gtk_tree_view_column_set_cell_data_func (col, cell,
+ heading_cell_renderer_func,
+ sidebar, NULL);
+
+ /* icon padding */
+ cell = gtk_cell_renderer_text_new ();
+ sidebar->icon_padding_cell_renderer = cell;
+ gtk_tree_view_column_pack_start (col, cell, FALSE);
+ gtk_tree_view_column_set_cell_data_func (col, cell,
+ padding_cell_renderer_func,
+ sidebar, NULL);
+
+ /* icon renderer */
cell = gtk_cell_renderer_pixbuf_new ();
sidebar->icon_cell_renderer = cell;
gtk_tree_view_column_pack_start (col, cell, FALSE);
gtk_tree_view_column_set_attributes (col, cell,
"pixbuf", PLACES_SIDEBAR_COLUMN_ICON,
NULL);
+ gtk_tree_view_column_set_cell_data_func (col, cell,
+ icon_cell_renderer_func,
+ sidebar, NULL);
-
+ /* eject text renderer */
cell = gtk_cell_renderer_text_new ();
sidebar->eject_text_cell_renderer = cell;
gtk_tree_view_column_pack_start (col, cell, TRUE);
@@ -2747,19 +3190,20 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
"ellipsize-set", TRUE,
NULL);
-
+ /* eject icon renderer */
cell = gtk_cell_renderer_pixbuf_new ();
g_object_set (cell,
"mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
- "icon-name", "media-eject",
"stock-size", GTK_ICON_SIZE_MENU,
"xpad", EJECT_BUTTON_XPAD,
NULL);
gtk_tree_view_column_pack_start (col, cell, FALSE);
gtk_tree_view_column_set_attributes (col, cell,
"visible", PLACES_SIDEBAR_COLUMN_EJECT,
+ "pixbuf", PLACES_SIDEBAR_COLUMN_EJECT_ICON,
NULL);
+ /* normal text renderer */
cell = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (col, cell, TRUE);
g_object_set (G_OBJECT (cell), "editable", FALSE, NULL);
@@ -2778,11 +3222,6 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
g_signal_connect (cell, "editing-canceled",
G_CALLBACK (bookmarks_editing_canceled), sidebar);
- gtk_tree_view_set_row_separator_func (tree_view,
- caja_shortcuts_row_separator_func,
- NULL,
- NULL);
-
/* this is required to align the eject buttons to the right */
gtk_tree_view_column_set_max_width (GTK_TREE_VIEW_COLUMN (col), CAJA_ICON_SIZE_SMALLER);
gtk_tree_view_append_column (tree_view, col);
@@ -2799,9 +3238,10 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_STRING
- );
+ G_TYPE_STRING,
+ GDK_TYPE_PIXBUF,
+ G_TYPE_INT,
+ G_TYPE_STRING);
gtk_tree_view_set_tooltip_column (tree_view, PLACES_SIDEBAR_COLUMN_TOOLTIP);
@@ -2820,6 +3260,11 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
selection = gtk_tree_view_get_selection (tree_view);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ gtk_tree_selection_set_select_function (selection,
+ tree_selection_func,
+ sidebar,
+ NULL);
+
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tree_view),
GDK_BUTTON1_MASK,
caja_shortcuts_source_targets,
@@ -2841,12 +3286,15 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
G_CALLBACK (drag_data_received_callback), sidebar);
g_signal_connect (tree_view, "drag-drop",
G_CALLBACK (drag_drop_callback), sidebar);
+
g_signal_connect (selection, "changed",
G_CALLBACK (bookmarks_selection_changed_cb), sidebar);
g_signal_connect (tree_view, "popup-menu",
G_CALLBACK (bookmarks_popup_menu_cb), sidebar);
g_signal_connect (tree_view, "button-press-event",
G_CALLBACK (bookmarks_button_press_event_cb), sidebar);
+ g_signal_connect (tree_view, "motion-notify-event",
+ G_CALLBACK (bookmarks_motion_event_cb), sidebar);
g_signal_connect (tree_view, "button-release-event",
G_CALLBACK (bookmarks_button_release_event_cb), sidebar);
@@ -2878,20 +3326,22 @@ caja_places_sidebar_dispose (GObject *object)
free_drag_data (sidebar);
- if (sidebar->store != NULL)
- {
+ if (sidebar->eject_highlight_path != NULL) {
+ gtk_tree_path_free (sidebar->eject_highlight_path);
+ sidebar->eject_highlight_path = NULL;
+ }
+
+ if (sidebar->store != NULL) {
g_object_unref (sidebar->store);
sidebar->store = NULL;
}
- if (sidebar->volume_monitor != NULL)
- {
+ if (sidebar->volume_monitor != NULL) {
g_object_unref (sidebar->volume_monitor);
sidebar->volume_monitor = NULL;
}
- if (sidebar->bookmarks != NULL)
- {
+ if (sidebar->bookmarks != NULL) {
g_object_unref (sidebar->bookmarks);
sidebar->bookmarks = NULL;
}
@@ -3061,31 +3511,21 @@ static gboolean
caja_shortcuts_model_filter_row_draggable (GtkTreeDragSource *drag_source,
GtkTreePath *path)
{
- CajaShortcutsModelFilter *model;
- int pos;
- int bookmarks_pos;
- int num_bookmarks;
-
- model = CAJA_SHORTCUTS_MODEL_FILTER (drag_source);
-
- pos = *gtk_tree_path_get_indices (path);
- bookmarks_pos = get_bookmark_index (model->sidebar->tree_view);
- num_bookmarks = caja_bookmark_list_length (model->sidebar->bookmarks);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ PlaceType place_type;
+ SectionType section_type;
- return (pos >= bookmarks_pos && pos < bookmarks_pos + num_bookmarks);
-}
-
-/* GtkTreeDragSource::drag_data_get implementation for the shortcuts filter model */
-static gboolean
-caja_shortcuts_model_filter_drag_data_get (GtkTreeDragSource *drag_source,
- GtkTreePath *path,
- GtkSelectionData *selection_data)
-{
- CajaShortcutsModelFilter *model;
+ model = GTK_TREE_MODEL (drag_source);
- model = CAJA_SHORTCUTS_MODEL_FILTER (drag_source);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type,
+ PLACES_SIDEBAR_COLUMN_SECTION_TYPE, &section_type,
+ -1);
- /* FIXME */
+ if (place_type != PLACES_HEADING && section_type == SECTION_BOOKMARKS)
+ return TRUE;
return FALSE;
}
@@ -3095,7 +3535,6 @@ static void
caja_shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface)
{
iface->row_draggable = caja_shortcuts_model_filter_row_draggable;
- iface->drag_data_get = caja_shortcuts_model_filter_drag_data_get;
}
static GtkTreeModel *
diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c
index c74177d3..e3ee8dd7 100644
--- a/src/caja-property-browser.c
+++ b/src/caja-property-browser.c
@@ -34,14 +34,10 @@
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-mate-extensions.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
#include <eel/eel-image-table.h>
#include <eel/eel-labeled-image.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <eel/eel-xml-extensions.h>
#include <libxml/parser.h>
@@ -122,9 +118,6 @@ struct CajaPropertyBrowserDetails
gboolean has_local;
};
-static void caja_property_browser_class_init (GtkObjectClass *object_klass);
-static void caja_property_browser_init (GtkObject *object);
-static void caja_property_browser_destroy (GtkObject *object);
static void caja_property_browser_update_contents (CajaPropertyBrowser *property_browser);
static void caja_property_browser_set_category (CajaPropertyBrowser *property_browser,
const char *new_category);
@@ -200,40 +193,86 @@ static GtkTargetEntry drag_types[] =
};
-EEL_CLASS_BOILERPLATE (CajaPropertyBrowser,
- caja_property_browser,
- GTK_TYPE_WINDOW)
+G_DEFINE_TYPE (CajaPropertyBrowser, caja_property_browser, GTK_TYPE_WINDOW)
-/* initializing the class object by installing the operations we override */
+
+/* Destroy the three dialogs for adding patterns/colors/emblems if any of them
+ exist. */
static void
-caja_property_browser_class_init (GtkObjectClass *object_klass)
+caja_property_browser_destroy_dialogs (CajaPropertyBrowser *property_browser)
{
- CajaPropertyBrowserClass *klass;
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (object_klass);
+ if (property_browser->details->patterns_dialog)
+ {
+ gtk_widget_destroy (property_browser->details->patterns_dialog);
+ property_browser->details->patterns_dialog = NULL;
+ }
+ if (property_browser->details->colors_dialog)
+ {
+ gtk_widget_destroy (property_browser->details->colors_dialog);
+ property_browser->details->colors_dialog = NULL;
+ }
+ if (property_browser->details->emblems_dialog)
+ {
+ gtk_widget_destroy (property_browser->details->emblems_dialog);
+ property_browser->details->emblems_dialog = NULL;
+ }
+}
- klass = CAJA_PROPERTY_BROWSER_CLASS (object_klass);
+static void
+caja_property_browser_dispose (GObject *object)
+{
+ CajaPropertyBrowser *property_browser;
- object_klass->destroy = caja_property_browser_destroy;
+ property_browser = CAJA_PROPERTY_BROWSER (object);
+
+ caja_property_browser_destroy_dialogs (property_browser);
+
+ g_free (property_browser->details->path);
+ g_free (property_browser->details->category);
+ g_free (property_browser->details->dragged_file);
+ g_free (property_browser->details->drag_type);
+
+ g_list_foreach (property_browser->details->keywords, (GFunc) g_free, NULL);
+ g_list_free(property_browser->details->keywords);
+
+ if (property_browser->details->property_chit)
+ {
+ g_object_unref (property_browser->details->property_chit);
+ }
+
+ G_OBJECT_CLASS (caja_property_browser_parent_class)->dispose (object);
+}
+
+/* initializing the class object by installing the operations we override */
+static void
+caja_property_browser_class_init (CajaPropertyBrowserClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ G_OBJECT_CLASS (klass)->dispose = caja_property_browser_dispose;
widget_class->drag_begin = caja_property_browser_drag_begin;
widget_class->drag_data_get = caja_property_browser_drag_data_get;
widget_class->drag_end = caja_property_browser_drag_end;
+
+ g_type_class_add_private (klass, sizeof (CajaPropertyBrowserDetails));
}
/* initialize the instance's fields, create the necessary subviews, etc. */
static void
-caja_property_browser_init (GtkObject *object)
+caja_property_browser_init (CajaPropertyBrowser *property_browser)
{
- CajaPropertyBrowser *property_browser;
GtkWidget *widget, *temp_box, *temp_hbox, *temp_frame, *vbox;
GtkWidget *temp_button;
GtkWidget *viewport;
+ PangoAttrList *attrs;
char *temp_str;
- property_browser = CAJA_PROPERTY_BROWSER (object);
- widget = GTK_WIDGET (object);
+ widget = GTK_WIDGET (property_browser);
- property_browser->details = g_new0 (CajaPropertyBrowserDetails, 1);
+ property_browser->details = G_TYPE_INSTANCE_GET_PRIVATE (property_browser,
+ CAJA_TYPE_PROPERTY_BROWSER,
+ CajaPropertyBrowserDetails);
property_browser->details->category = g_strdup ("patterns");
property_browser->details->category_type = CAJA_PROPERTY_PATTERN;
@@ -255,7 +294,6 @@ caja_property_browser_init (GtkObject *object)
gtk_window_set_title (GTK_WINDOW (widget), _("Backgrounds and Emblems"));
gtk_window_set_wmclass (GTK_WINDOW (widget), "property_browser", "Caja");
gtk_window_set_type_hint (GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_DIALOG);
- eel_gtk_window_set_up_close_accelerator (GTK_WINDOW (widget));
/* create the main vbox. */
vbox = gtk_vbox_new (FALSE, 12);
@@ -316,9 +354,12 @@ caja_property_browser_init (GtkObject *object)
gtk_container_add(GTK_CONTAINER(temp_frame), temp_hbox);
/* add the title label */
+ attrs = pango_attr_list_new ();
+ pango_attr_list_insert (attrs, pango_attr_scale_new (PANGO_SCALE_X_LARGE));
+ pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
property_browser->details->title_label = gtk_label_new ("");
- eel_gtk_label_set_scale (GTK_LABEL (property_browser->details->title_label), PANGO_SCALE_X_LARGE);
- eel_gtk_label_make_bold (GTK_LABEL (property_browser->details->title_label));
+ gtk_label_set_attributes (GTK_LABEL (property_browser->details->title_label), attrs);
+ pango_attr_list_unref (attrs);
gtk_widget_show(property_browser->details->title_label);
gtk_box_pack_start (GTK_BOX(temp_hbox), property_browser->details->title_label, FALSE, FALSE, 0);
@@ -402,55 +443,6 @@ caja_property_browser_init (GtkObject *object)
caja_property_browser_set_path(property_browser, BROWSER_CATEGORIES_FILE_NAME);
}
-/* Destroy the three dialogs for adding patterns/colors/emblems if any of them
- exist. */
-static void
-caja_property_browser_destroy_dialogs (CajaPropertyBrowser *property_browser)
-{
- if (property_browser->details->patterns_dialog)
- {
- gtk_widget_destroy (property_browser->details->patterns_dialog);
- property_browser->details->patterns_dialog = NULL;
- }
- if (property_browser->details->colors_dialog)
- {
- gtk_widget_destroy (property_browser->details->colors_dialog);
- property_browser->details->colors_dialog = NULL;
- }
- if (property_browser->details->emblems_dialog)
- {
- gtk_widget_destroy (property_browser->details->emblems_dialog);
- property_browser->details->emblems_dialog = NULL;
- }
-}
-
-static void
-caja_property_browser_destroy (GtkObject *object)
-{
- CajaPropertyBrowser *property_browser;
-
-
- property_browser = CAJA_PROPERTY_BROWSER (object);
-
- caja_property_browser_destroy_dialogs (property_browser);
-
- g_free (property_browser->details->path);
- g_free (property_browser->details->category);
- g_free (property_browser->details->dragged_file);
- g_free (property_browser->details->drag_type);
-
- eel_g_list_free_deep (property_browser->details->keywords);
-
- if (property_browser->details->property_chit)
- {
- g_object_unref (property_browser->details->property_chit);
- }
-
- g_free (property_browser->details);
-
- EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
-}
-
/* create a new instance */
CajaPropertyBrowser *
caja_property_browser_new (GdkScreen *screen)
@@ -552,7 +544,7 @@ caja_property_browser_drag_begin (GtkWidget *widget,
/* it's not a color, so, for now, it must be an image */
/* fiddle with the category to handle the "reset" case properly */
char * save_category = property_browser->details->category;
- if (eel_strcmp (property_browser->details->category, "colors") == 0)
+ if (g_strcmp0 (property_browser->details->category, "colors") == 0)
{
property_browser->details->category = "patterns";
}
@@ -622,7 +614,7 @@ caja_property_browser_drag_data_get (GtkWidget *widget,
guint16 colorArray[4];
/* handle the "reset" case as an image */
- if (eel_strcmp (property_browser->details->dragged_file, RESET_IMAGE_NAME) != 0)
+ if (g_strcmp0 (property_browser->details->dragged_file, RESET_IMAGE_NAME) != 0)
{
gdk_color_parse (property_browser->details->dragged_file, &color);
@@ -780,7 +772,7 @@ make_drag_image (CajaPropertyBrowser *property_browser, const char* file_name)
return NULL;
}
- is_reset = eel_strcmp (file_name, RESET_IMAGE_NAME) == 0;
+ is_reset = g_strcmp0 (file_name, RESET_IMAGE_NAME) == 0;
if (strcmp (property_browser->details->category, "patterns") == 0 &&
property_browser->details->property_chit != NULL)
@@ -1237,7 +1229,7 @@ add_pattern_to_browser (GtkDialog *dialog, gint response_id, gpointer *data)
/* don't allow the user to change the reset image */
basename = g_file_get_basename (selected);
- if (basename && eel_strcmp (basename, RESET_IMAGE_NAME) == 0)
+ if (basename && g_strcmp0 (basename, RESET_IMAGE_NAME) == 0)
{
eel_show_error_dialog (_("Sorry, but you cannot replace the reset image."),
_("Reset is a special image that cannot be deleted."),
@@ -1722,7 +1714,7 @@ element_clicked_callback (GtkWidget *image_table,
drag_types[0].target = property_browser->details->drag_type;
/* treat the reset property in the colors section specially */
- if (eel_strcmp (element_name, RESET_IMAGE_NAME) == 0)
+ if (g_strcmp0 (element_name, RESET_IMAGE_NAME) == 0)
{
drag_types[0].target = "x-special/mate-reset-background";
}
@@ -1804,7 +1796,8 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser)
if (property_browser->details->category_type == CAJA_PROPERTY_EMBLEM)
{
- eel_g_list_free_deep (property_browser->details->keywords);
+ g_list_foreach(property_browser->details->keywords, (GFunc) g_free, NULL);
+ g_list_free(property_browser->details->keywords);
property_browser->details->keywords = NULL;
icons = caja_emblem_list_available ();
@@ -1858,7 +1851,8 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser)
g_object_unref (object_pixbuf);
}
}
- eel_g_list_free_deep (icons);
+ g_list_foreach(icons, (GFunc) g_free, NULL);
+ g_list_free(icons);
}
else
{
@@ -1885,7 +1879,7 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser)
/* Keep track of ERASE objects to place them prominently later */
if (property_browser->details->category_type == CAJA_PROPERTY_PATTERN
- && !eel_strcmp (object_name, RESET_IMAGE_NAME))
+ && !g_strcmp0 (object_name, RESET_IMAGE_NAME))
{
g_assert (reset_object == NULL);
reset_object = property_image;
@@ -2405,7 +2399,7 @@ caja_property_browser_set_category (CajaPropertyBrowser *property_browser,
const char *new_category)
{
/* there's nothing to do if the category is the same as the current one */
- if (eel_strcmp (property_browser->details->category, new_category) == 0)
+ if (g_strcmp0 (property_browser->details->category, new_category) == 0)
{
return;
}
@@ -2414,15 +2408,15 @@ caja_property_browser_set_category (CajaPropertyBrowser *property_browser,
property_browser->details->category = g_strdup (new_category);
/* set up the property type enum */
- if (eel_strcmp (new_category, "patterns") == 0)
+ if (g_strcmp0 (new_category, "patterns") == 0)
{
property_browser->details->category_type = CAJA_PROPERTY_PATTERN;
}
- else if (eel_strcmp (new_category, "colors") == 0)
+ else if (g_strcmp0 (new_category, "colors") == 0)
{
property_browser->details->category_type = CAJA_PROPERTY_COLOR;
}
- else if (eel_strcmp (new_category, "emblems") == 0)
+ else if (g_strcmp0 (new_category, "emblems") == 0)
{
property_browser->details->category_type = CAJA_PROPERTY_EMBLEM;
}
@@ -2444,7 +2438,7 @@ caja_property_browser_set_path (CajaPropertyBrowser *property_browser,
const char *new_path)
{
/* there's nothing to do if the uri is the same as the current one */
- if (eel_strcmp (property_browser->details->path, new_path) == 0)
+ if (g_strcmp0 (property_browser->details->path, new_path) == 0)
{
return;
}
diff --git a/src/caja-query-editor.c b/src/caja-query-editor.c
index dab9e329..b0d04008 100644
--- a/src/caja-query-editor.c
+++ b/src/caja-query-editor.c
@@ -23,10 +23,10 @@
#include <config.h>
#include "caja-query-editor.h"
+#include "caja-src-marshal.h"
#include "caja-window-slot.h"
#include <string.h>
-#include <libcaja-private/caja-marshal.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <eel/eel-gtk-macros.h>
@@ -197,7 +197,7 @@ caja_query_editor_class_init (CajaQueryEditorClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CajaQueryEditorClass, changed),
NULL, NULL,
- caja_marshal_VOID__OBJECT_BOOLEAN,
+ caja_src_marshal_VOID__OBJECT_BOOLEAN,
G_TYPE_NONE, 2, CAJA_TYPE_QUERY, G_TYPE_BOOLEAN);
signals[CANCEL] =
@@ -210,7 +210,7 @@ caja_query_editor_class_init (CajaQueryEditorClass *class)
G_TYPE_NONE, 0);
binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
}
static void
@@ -587,7 +587,7 @@ type_combo_changed (GtkComboBox *combo_box, CajaQueryEditorRow *row)
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
dialog = gtk_dialog_new_with_buttons (_("Select type"),
GTK_WINDOW (toplevel),
- GTK_DIALOG_NO_SEPARATOR,
+ 0,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 600);
@@ -864,8 +864,8 @@ type_add_rows_from_query (CajaQueryEditor *editor,
&iter);
}
- eel_g_list_free_deep (mime_types);
-
+ g_list_foreach(mime_types, (GFunc) g_free, NULL);
+ g_list_free(mime_types);
}
/* End of row types */
@@ -967,11 +967,11 @@ caja_query_editor_add_row (CajaQueryEditor *editor,
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (editor->details->visible_vbox), hbox, FALSE, FALSE, 0);
- combo = gtk_combo_box_new_text ();
+ combo = gtk_combo_box_text_new ();
row->combo = combo;
for (i = 0; i < CAJA_QUERY_EDITOR_ROW_LAST; i++)
{
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), gettext (row_type[i].name));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), gettext (row_type[i].name));
}
gtk_widget_show (combo);
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
diff --git a/src/caja-search-bar.c b/src/caja-search-bar.c
index 86bd1f0a..4ff4ef4b 100644
--- a/src/caja-search-bar.c
+++ b/src/caja-search-bar.c
@@ -102,7 +102,7 @@ caja_search_bar_class_init (CajaSearchBarClass *class)
G_TYPE_NONE, 0);
binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
}
static gboolean
@@ -198,7 +198,7 @@ caja_search_bar_borrow_entry (CajaSearchBar *bar)
bar->details->entry_borrowed = TRUE;
binding_set = gtk_binding_set_by_class (G_OBJECT_GET_CLASS (bar));
- gtk_binding_entry_remove (binding_set, GDK_Escape, 0);
+ gtk_binding_entry_remove (binding_set, GDK_KEY_Escape, 0);
return bar->details->entry;
}
@@ -210,7 +210,7 @@ caja_search_bar_return_entry (CajaSearchBar *bar)
bar->details->entry_borrowed = FALSE;
binding_set = gtk_binding_set_by_class (G_OBJECT_GET_CLASS (bar));
- gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
}
GtkWidget *
diff --git a/src/caja-side-pane.c b/src/caja-side-pane.c
index 0566e81d..d3922b9f 100644
--- a/src/caja-side-pane.c
+++ b/src/caja-side-pane.c
@@ -30,6 +30,10 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#if !GTK_CHECK_VERSION(3,0,0)
+#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y)
+#endif
+
typedef struct
{
char *title;
@@ -146,7 +150,7 @@ caja_side_pane_size_allocate (GtkWidget *widget,
frame = pane->details->title_frame;
hbox = pane->details->title_hbox;
- gtk_widget_get_child_requisition (hbox, &child_requisition);
+ gtk_widget_get_preferred_size (hbox, &child_requisition, NULL);
width = child_requisition.width;
gtk_widget_get_allocation (frame, &frame_allocation);
@@ -249,7 +253,7 @@ select_button_press_callback (GtkWidget *widget,
gtk_widget_get_allocation (widget, &allocation);
width = allocation.width;
gtk_widget_set_size_request (side_pane->details->menu, -1, -1);
- gtk_widget_size_request (side_pane->details->menu, &requisition);
+ gtk_widget_get_preferred_size (side_pane->details->menu, &requisition, NULL);
gtk_widget_set_size_request (side_pane->details->menu,
MAX (width, requisition.width), -1);
@@ -274,10 +278,10 @@ select_button_key_press_callback (GtkWidget *widget,
side_pane = CAJA_SIDE_PANE (user_data);
- if (event->keyval == GDK_space ||
- event->keyval == GDK_KP_Space ||
- event->keyval == GDK_Return ||
- event->keyval == GDK_KP_Enter)
+ if (event->keyval == GDK_KEY_space ||
+ event->keyval == GDK_KEY_KP_Space ||
+ event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
gtk_menu_popup (GTK_MENU (side_pane->details->menu),
diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c
index 15a761be..c7bda988 100644
--- a/src/caja-sidebar-title.c
+++ b/src/caja-sidebar-title.c
@@ -35,10 +35,8 @@
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-pango-extensions.h>
-#include <eel/eel-string.h>
#include <gtk/gtk.h>
+#include <pango/pango.h>
#include <glib/gi18n.h>
#include <libcaja-private/caja-file-attributes.h>
#include <libcaja-private/caja-global-preferences.h>
@@ -51,60 +49,57 @@
#define MAX_TITLE_SIZE 256
#define MINIMUM_INFO_WIDTH 32
#define SIDEBAR_INFO_MARGIN 4
-#define SHADOW_OFFSET 1
#define MORE_INFO_FONT_SIZE 12
#define MIN_TITLE_FONT_SIZE 12
#define TITLE_PADDING 4
-static void caja_sidebar_title_class_init (CajaSidebarTitleClass *klass);
-static void caja_sidebar_title_destroy (GtkObject *object);
-static void caja_sidebar_title_init (CajaSidebarTitle *pixmap);
-static void caja_sidebar_title_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void update_icon (CajaSidebarTitle *sidebar_title);
-static GtkWidget * sidebar_title_create_title_label (void);
-static GtkWidget * sidebar_title_create_more_info_label (void);
-static void update_all (CajaSidebarTitle *sidebar_title);
-static void update_more_info (CajaSidebarTitle *sidebar_title);
-static void update_title_font (CajaSidebarTitle *sidebar_title);
-static void style_set (GtkWidget *widget,
- GtkStyle *previous_style);
-static guint get_best_icon_size (CajaSidebarTitle *sidebar_title);
+#define DEFAULT_LIGHT_INFO_COLOR 0xFFFFFF
+#define DEFAULT_DARK_INFO_COLOR 0x2A2A2A
+
+static void caja_sidebar_title_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static void update_icon (CajaSidebarTitle *sidebar_title);
+static GtkWidget * sidebar_title_create_title_label (void);
+static GtkWidget * sidebar_title_create_more_info_label (void);
+static void update_all (CajaSidebarTitle *sidebar_title);
+static void update_more_info (CajaSidebarTitle *sidebar_title);
+static void update_title_font (CajaSidebarTitle *sidebar_title);
+static void style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
+static guint get_best_icon_size (CajaSidebarTitle *sidebar_title);
+
+enum
+{
+ LABEL_COLOR,
+ LABEL_COLOR_HIGHLIGHT,
+ LABEL_COLOR_ACTIVE,
+ LABEL_COLOR_PRELIGHT,
+ LABEL_INFO_COLOR,
+ LABEL_INFO_COLOR_HIGHLIGHT,
+ LABEL_INFO_COLOR_ACTIVE,
+ LAST_LABEL_COLOR
+};
struct CajaSidebarTitleDetails
{
CajaFile *file;
- guint file_changed_connection;
- gboolean monitoring_count;
+ guint file_changed_connection;
+ gboolean monitoring_count;
- char *title_text;
+ char *title_text;
GtkWidget *icon;
GtkWidget *title_label;
GtkWidget *more_info_label;
GtkWidget *emblem_box;
- guint best_icon_size;
-
+ GdkColor label_colors [LAST_LABEL_COLOR];
+ guint best_icon_size;
gboolean determined_icon;
};
-EEL_CLASS_BOILERPLATE (CajaSidebarTitle, caja_sidebar_title, gtk_vbox_get_type ())
-
-static void
-caja_sidebar_title_class_init (CajaSidebarTitleClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass*) class;
- widget_class = (GtkWidgetClass*) class;
-
- object_class->destroy = caja_sidebar_title_destroy;
- widget_class->size_allocate = caja_sidebar_title_size_allocate;
- widget_class->style_set = style_set;
+G_DEFINE_TYPE (CajaSidebarTitle, caja_sidebar_title, GTK_TYPE_VBOX)
-}
static void
style_set (GtkWidget *widget,
@@ -137,7 +132,9 @@ style_set (GtkWidget *widget,
static void
caja_sidebar_title_init (CajaSidebarTitle *sidebar_title)
{
- sidebar_title->details = g_new0 (CajaSidebarTitleDetails, 1);
+ sidebar_title->details = G_TYPE_INSTANCE_GET_PRIVATE (sidebar_title,
+ CAJA_TYPE_SIDEBAR_TITLE,
+ CajaSidebarTitleDetails);
/* Create the icon */
sidebar_title->details->icon = gtk_image_new ();
@@ -191,7 +188,7 @@ release_file (CajaSidebarTitle *sidebar_title)
}
static void
-caja_sidebar_title_destroy (GtkObject *object)
+caja_sidebar_title_finalize (GObject *object)
{
CajaSidebarTitle *sidebar_title;
@@ -202,14 +199,23 @@ caja_sidebar_title_destroy (GtkObject *object)
release_file (sidebar_title);
g_free (sidebar_title->details->title_text);
- g_free (sidebar_title->details);
- sidebar_title->details = NULL;
}
g_signal_handlers_disconnect_by_func (caja_preferences,
update_more_info, sidebar_title);
- EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+ G_OBJECT_CLASS (caja_sidebar_title_parent_class)->finalize (object);
+}
+
+static void
+caja_sidebar_title_class_init (CajaSidebarTitleClass *klass)
+{
+ g_type_class_add_private (klass, sizeof (CajaSidebarTitleDetails));
+
+ G_OBJECT_CLASS (klass)->finalize = caja_sidebar_title_finalize;
+
+ GTK_WIDGET_CLASS (klass)->size_allocate = caja_sidebar_title_size_allocate;
+ GTK_WIDGET_CLASS (klass)->style_set = style_set;
}
/* return a new index title object */
@@ -219,58 +225,82 @@ caja_sidebar_title_new (void)
return gtk_widget_new (caja_sidebar_title_get_type (), NULL);
}
+static void
+setup_gc_with_fg (CajaSidebarTitle *sidebar_title, int idx, guint32 color)
+{
+ sidebar_title->details->label_colors [idx] = eel_gdk_rgb_to_color (color);
+}
+
void
caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
- EelBackground *background,
- gboolean is_default)
+ EelBackground *background)
{
- char *sidebar_title_color;
- char *sidebar_info_title_color;
- char *sidebar_title_shadow_color;
+ GdkColor *light_info_color, *dark_info_color;
+ guint light_info_value, dark_info_value;
+ GtkStyle *style;
- g_return_if_fail (background != NULL);
+ g_assert (CAJA_IS_SIDEBAR_TITLE (sidebar_title));
+ g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (sidebar_title)));
- /* if the background is set to the default, the theme can explicitly
- * define the title colors. Check if the background has been customized
- * and if the theme specified any colors
- */
- sidebar_title_color = NULL;
- sidebar_info_title_color = NULL;
- sidebar_title_shadow_color = NULL;
+ /* read the info colors from the current theme; use a reasonable default if undefined */
+ gtk_widget_style_get (GTK_WIDGET (sidebar_title),
+ "light_info_color", &light_info_color,
+ "dark_info_color", &dark_info_color,
+ NULL);
+ style = gtk_widget_get_style (GTK_WIDGET (sidebar_title));
- /* FIXME bugzilla.gnome.org 42496: for now, both the title and info
- * colors are the same - and hard coded */
- if (eel_background_is_dark (background))
+ if (light_info_color)
{
- sidebar_title_color = g_strdup ("#FFFFFF");
- sidebar_info_title_color = g_strdup ("#FFFFFF");
- sidebar_title_shadow_color = g_strdup ("#000000");
+ light_info_value = eel_gdk_color_to_rgb (light_info_color);
+ gdk_color_free (light_info_color);
}
else
{
- sidebar_title_color = g_strdup ("#000000");
- sidebar_info_title_color = g_strdup ("#000000");
- sidebar_title_shadow_color = g_strdup ("#FFFFFF");
+ light_info_value = DEFAULT_LIGHT_INFO_COLOR;
}
- eel_gtk_widget_set_foreground_color (sidebar_title->details->title_label,
- sidebar_title_color);
- eel_gtk_widget_set_foreground_color (sidebar_title->details->more_info_label,
- sidebar_info_title_color);
-
- eel_gtk_label_set_drop_shadow_color (GTK_LABEL (sidebar_title->details->title_label),
- eel_parse_rgb_with_white_default (sidebar_title_shadow_color));
- eel_gtk_label_set_drop_shadow_color (GTK_LABEL (sidebar_title->details->more_info_label),
- eel_parse_rgb_with_white_default (sidebar_title_shadow_color));
+ if (dark_info_color)
+ {
+ dark_info_value = eel_gdk_color_to_rgb (dark_info_color);
+ gdk_color_free (dark_info_color);
+ }
+ else
+ {
+ dark_info_value = DEFAULT_DARK_INFO_COLOR;
+ }
- eel_gtk_label_set_drop_shadow_offset (GTK_LABEL (sidebar_title->details->title_label),
- SHADOW_OFFSET);
- eel_gtk_label_set_drop_shadow_offset (GTK_LABEL (sidebar_title->details->more_info_label),
- SHADOW_OFFSET);
- g_free (sidebar_title_color);
- g_free (sidebar_info_title_color);
- g_free (sidebar_title_shadow_color);
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR_HIGHLIGHT,
+ eel_gdk_color_to_rgb (&style->text[GTK_STATE_SELECTED]));
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR_ACTIVE,
+ eel_gdk_color_to_rgb (&style->text[GTK_STATE_ACTIVE]));
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR_PRELIGHT,
+ eel_gdk_color_to_rgb (&style->text[GTK_STATE_PRELIGHT]));
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_HIGHLIGHT,
+ eel_gdk_color_is_dark (&style->base[GTK_STATE_SELECTED]) ? light_info_value : dark_info_value);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_ACTIVE,
+ eel_gdk_color_is_dark (&style->base[GTK_STATE_ACTIVE]) ? light_info_value : dark_info_value);
+
+ /* If EelBackground is not set in the widget, we can safely
+ * use the foreground color from the theme, because it will
+ * always be displayed against the gtk background */
+ if (!eel_background_is_set(background))
+ {
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR,
+ eel_gdk_color_to_rgb (&style->text[GTK_STATE_NORMAL]));
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR,
+ eel_gdk_color_is_dark (&style->base[GTK_STATE_NORMAL]) ? light_info_value : dark_info_value);
+ }
+ else if (eel_background_is_dark (background))
+ {
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR, 0xEFEFEF);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, light_info_value);
+ }
+ else /* converse */
+ {
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR, 0x000000);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, dark_info_value);
+ }
}
static char*
@@ -361,15 +391,16 @@ update_icon (CajaSidebarTitle *sidebar_title)
static void
update_title_font (CajaSidebarTitle *sidebar_title)
{
- int available_width;
- PangoFontDescription *title_font;
- int largest_fitting_font_size;
- int max_style_font_size;
+ int available_width, width;
+ int max_fit_font_size, max_style_font_size;
GtkStyle *style;
GtkAllocation allocation;
+ PangoFontDescription *title_font, *tmp_font;
+ PangoLayout *layout;
/* Make sure theres work to do */
- if (eel_strlen (sidebar_title->details->title_text) < 1)
+ if (sidebar_title->details->title_text == NULL
+ || strlen (sidebar_title->details->title_text) < 1)
{
return;
}
@@ -392,19 +423,29 @@ update_title_font (CajaSidebarTitle *sidebar_title)
max_style_font_size = MIN_TITLE_FONT_SIZE + 1;
}
- largest_fitting_font_size = eel_pango_font_description_get_largest_fitting_font_size (
- title_font,
- gtk_widget_get_pango_context (sidebar_title->details->title_label),
- sidebar_title->details->title_text,
- available_width,
- MIN_TITLE_FONT_SIZE,
- max_style_font_size);
- pango_font_description_set_size (title_font, largest_fitting_font_size * PANGO_SCALE);
+ /* Calculate largest-fitting font size */
+ layout = pango_layout_new (gtk_widget_get_pango_context (sidebar_title->details->title_label));
+ pango_layout_set_text (layout, sidebar_title->details->title_text, -1);
+ pango_layout_set_font_description (layout, title_font);
+ tmp_font = pango_font_description_new ();
- pango_font_description_set_weight (title_font, PANGO_WEIGHT_BOLD);
+ max_fit_font_size = max_style_font_size;
+ for (; max_fit_font_size >= MIN_TITLE_FONT_SIZE; max_fit_font_size--)
+ {
+ pango_font_description_set_size (tmp_font, max_fit_font_size * PANGO_SCALE);
+ pango_layout_set_font_description (layout, tmp_font);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+
+ if (width <= available_width)
+ break;
+ }
- gtk_widget_modify_font (sidebar_title->details->title_label,
- title_font);
+ pango_font_description_free (tmp_font);
+ g_object_unref (layout);
+
+ pango_font_description_set_size (title_font, max_fit_font_size * PANGO_SCALE);
+ pango_font_description_set_weight (title_font, PANGO_WEIGHT_BOLD);
+ gtk_widget_modify_font (sidebar_title->details->title_label, title_font);
pango_font_description_free (title_font);
}
@@ -417,7 +458,7 @@ update_title (CajaSidebarTitle *sidebar_title)
label = GTK_LABEL (sidebar_title->details->title_label);
text = sidebar_title->details->title_text;
- if (eel_strcmp (text, gtk_label_get_text (label)) == 0)
+ if (g_strcmp0 (text, gtk_label_get_text (label)) == 0)
{
return;
}
@@ -678,7 +719,7 @@ caja_sidebar_title_size_allocate (GtkWidget *widget,
gtk_widget_get_allocation (widget, &old_allocation);
old_width = old_allocation.width;
- EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
+ GTK_WIDGET_CLASS (caja_sidebar_title_parent_class)->size_allocate (widget, allocation);
gtk_widget_get_allocation (widget, &new_allocation);
@@ -700,9 +741,21 @@ caja_sidebar_title_size_allocate (GtkWidget *widget,
gboolean
caja_sidebar_title_hit_test_icon (CajaSidebarTitle *sidebar_title, int x, int y)
{
+ GtkAllocation *allocation;
+ gboolean icon_hit;
+
g_return_val_if_fail (CAJA_IS_SIDEBAR_TITLE (sidebar_title), FALSE);
- return eel_point_in_widget (sidebar_title->details->icon, x, y);
+ allocation = g_new0 (GtkAllocation, 1);
+ gtk_widget_get_allocation (GTK_WIDGET (sidebar_title->details->icon), allocation);
+ g_return_val_if_fail (allocation != NULL, FALSE);
+
+ icon_hit = x >= allocation->x && y >= allocation->y
+ && x < allocation->x + allocation->width
+ && y < allocation->y + allocation->height;
+ g_free (allocation);
+
+ return icon_hit;
}
static GtkWidget *
@@ -724,9 +777,16 @@ static GtkWidget *
sidebar_title_create_more_info_label (void)
{
GtkWidget *more_info_label;
+ PangoAttrList *attrs;
+
+ attrs = pango_attr_list_new ();
+ pango_attr_list_insert (attrs, pango_attr_scale_new (PANGO_SCALE_SMALL));
more_info_label = gtk_label_new ("");
- eel_gtk_label_set_scale (GTK_LABEL (more_info_label), PANGO_SCALE_SMALL);
+
+ gtk_label_set_attributes (GTK_LABEL (more_info_label), attrs);
+ pango_attr_list_unref (attrs);
+
gtk_label_set_justify (GTK_LABEL (more_info_label), GTK_JUSTIFY_CENTER);
gtk_label_set_selectable (GTK_LABEL (more_info_label), TRUE);
gtk_label_set_ellipsize (GTK_LABEL (more_info_label), PANGO_ELLIPSIZE_END);
diff --git a/src/caja-sidebar-title.h b/src/caja-sidebar-title.h
index a677fdfc..757d5c3b 100644
--- a/src/caja-sidebar-title.h
+++ b/src/caja-sidebar-title.h
@@ -70,7 +70,6 @@ gboolean caja_sidebar_title_hit_test_icon (CajaSidebarTitle *sidebar_title
int x,
int y);
void caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
- EelBackground *background,
- gboolean is_default);
+ EelBackground *background);
#endif /* CAJA_SIDEBAR_TITLE_H */
diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c
index c5a1bac4..94e43956 100644
--- a/src/caja-spatial-window.c
+++ b/src/caja-spatial-window.c
@@ -42,7 +42,6 @@
#include "caja-search-bar.h"
#include "caja-window-manage-views.h"
#include "caja-zoom-control.h"
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
@@ -56,7 +55,6 @@
#include <libcaja-private/caja-ui-utilities.h>
#include <libcaja-private/caja-file-attributes.h>
#include <libcaja-private/caja-global-preferences.h>
-#include <libcaja-private/caja-horizontal-splitter.h>
#include <libcaja-private/caja-metadata.h>
#include <libcaja-private/caja-mime-actions.h>
#include <libcaja-private/caja-program-choosing.h>
@@ -64,6 +62,10 @@
#include <libcaja-private/caja-search-engine.h>
#include <libcaja-private/caja-signaller.h>
+#if !GTK_CHECK_VERSION(3,0,0)
+#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y)
+#endif
+
#define MAX_TITLE_LENGTH 180
#define MAX_SHORTNAME_PATH 16
@@ -95,7 +97,8 @@ static const GtkTargetEntry location_button_drag_types[] =
G_DEFINE_TYPE(CajaSpatialWindow, caja_spatial_window, CAJA_TYPE_WINDOW)
#define parent_class caja_spatial_window_parent_class
-static void caja_spatial_window_save_geometry (CajaWindowSlot *slot);
+static void caja_spatial_window_save_geometry (CajaSpatialWindow *window,
+ CajaFile *viewed_file);
static gboolean
save_window_geometry_timeout (gpointer callback_data)
@@ -108,7 +111,7 @@ save_window_geometry_timeout (gpointer callback_data)
if (slot != NULL)
{
- caja_spatial_window_save_geometry (slot);
+ caja_spatial_window_save_geometry (window, slot->viewed_file);
}
window->details->save_geometry_timeout_id = 0;
@@ -121,7 +124,6 @@ caja_spatial_window_configure_event (GtkWidget *widget,
GdkEventConfigure *event)
{
CajaSpatialWindow *window;
- char *geometry_string;
window = CAJA_SPATIAL_WINDOW (widget);
@@ -134,34 +136,9 @@ caja_spatial_window_configure_event (GtkWidget *widget,
{
g_source_remove (window->details->save_geometry_timeout_id);
}
- if (gtk_widget_get_visible (GTK_WIDGET (window)) && !CAJA_IS_DESKTOP_WINDOW (window))
- {
- geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
- /* If the last geometry is NULL the window must have just
- * been shown. No need to save geometry to disk since it
- * must be the same.
- */
- if (window->details->last_geometry == NULL)
- {
- window->details->last_geometry = geometry_string;
- return FALSE;
- }
-
- /* Don't save geometry if it's the same as before. */
- if (!strcmp (window->details->last_geometry,
- geometry_string))
- {
- g_free (geometry_string);
- return FALSE;
- }
-
- g_free (window->details->last_geometry);
- window->details->last_geometry = geometry_string;
-
- window->details->save_geometry_timeout_id =
- g_timeout_add_seconds (1, save_window_geometry_timeout, window);
- }
+ window->details->save_geometry_timeout_id =
+ g_timeout_add_seconds (1, save_window_geometry_timeout, window);
return FALSE;
}
@@ -184,7 +161,7 @@ caja_spatial_window_unrealize (GtkWidget *widget)
if (slot != NULL)
{
- caja_spatial_window_save_geometry (slot);
+ caja_spatial_window_save_geometry (window, slot->viewed_file);
}
}
}
@@ -242,43 +219,23 @@ caja_spatial_window_state_event (GtkWidget *widget,
}
static void
-caja_spatial_window_destroy (GtkObject *object)
-{
- CajaSpatialWindow *window;
-
- window = CAJA_SPATIAL_WINDOW (object);
-
- window->details->content_box = NULL;
-
- GTK_OBJECT_CLASS (caja_spatial_window_parent_class)->destroy (object);
-}
-
-static void
caja_spatial_window_finalize (GObject *object)
{
CajaSpatialWindow *window;
window = CAJA_SPATIAL_WINDOW (object);
- if (window->details->last_geometry != NULL)
- {
- g_free (window->details->last_geometry);
- }
+ g_free (window->details->last_geometry);
G_OBJECT_CLASS (caja_spatial_window_parent_class)->finalize (object);
}
static void
-caja_spatial_window_save_geometry (CajaWindowSlot *slot)
+caja_spatial_window_save_geometry (CajaSpatialWindow *window,
+ CajaFile *viewed_file)
{
- CajaWindow *window;
- CajaFile *viewed_file;
char *geometry_string;
- window = CAJA_WINDOW (slot->pane->window);
-
- viewed_file = slot->viewed_file;
-
if (viewed_file == NULL)
{
/* We never showed a file */
@@ -286,27 +243,34 @@ caja_spatial_window_save_geometry (CajaWindowSlot *slot)
}
if (gtk_widget_get_window (GTK_WIDGET (window)) &&
- !(gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET(window))) & GDK_WINDOW_STATE_MAXIMIZED))
- {
+ gtk_widget_get_visible (GTK_WIDGET (window)) &&
+ !CAJA_IS_DESKTOP_WINDOW (window) &&
+ !(gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET(window))) & GDK_WINDOW_STATE_MAXIMIZED)) {
+
geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
+ if (!g_strcmp0 (window->details->last_geometry, geometry_string)) {
+ /* Don't save geometry if it's the same as before. */
+ g_free (geometry_string);
+ return;
+ }
+
+ g_free (window->details->last_geometry);
+ window->details->last_geometry = geometry_string;
+
caja_file_set_metadata (viewed_file,
CAJA_METADATA_KEY_WINDOW_GEOMETRY,
NULL,
geometry_string);
-
- g_free (geometry_string);
}
}
static void
-caja_spatial_window_save_scroll_position (CajaWindowSlot *slot)
+caja_spatial_window_save_scroll_position (CajaSpatialWindow *window,
+ CajaWindowSlot *slot)
{
- CajaWindow *window;
char *scroll_string;
- window = CAJA_WINDOW (slot->pane->window);
-
if (slot->content_view == NULL ||
slot->viewed_file == NULL)
{
@@ -322,31 +286,25 @@ caja_spatial_window_save_scroll_position (CajaWindowSlot *slot)
}
static void
-caja_spatial_window_save_show_hidden_files_mode (CajaWindowSlot *slot)
+caja_spatial_window_save_show_hidden_files_mode (CajaSpatialWindow *window,
+ CajaFile *viewed_file)
{
- CajaWindow *window;
char *show_hidden_file_setting;
CajaWindowShowHiddenFilesMode mode;
- if (slot->viewed_file == NULL)
- {
+ if (viewed_file == NULL) {
return;
}
- window = CAJA_WINDOW (slot->pane->window);
-
mode = CAJA_WINDOW (window)->details->show_hidden_files_mode;
- if (mode != CAJA_WINDOW_SHOW_HIDDEN_FILES_DEFAULT)
- {
- if (mode == CAJA_WINDOW_SHOW_HIDDEN_FILES_ENABLE)
- {
+
+ if (mode != CAJA_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) {
+ if (mode == CAJA_WINDOW_SHOW_HIDDEN_FILES_ENABLE) {
show_hidden_file_setting = "1";
- }
- else
- {
+ } else {
show_hidden_file_setting = "0";
}
- caja_file_set_metadata (slot->viewed_file,
+ caja_file_set_metadata (viewed_file,
CAJA_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES,
NULL,
show_hidden_file_setting);
@@ -510,48 +468,53 @@ real_open_slot (CajaWindowPane *pane,
}
static void
-save_spatial_data (CajaWindowSlot *slot)
+save_spatial_data (CajaSpatialWindow *window,
+ CajaWindowSlot *slot)
{
- caja_spatial_window_save_geometry (slot);
- caja_spatial_window_save_scroll_position (slot);
- caja_spatial_window_save_show_hidden_files_mode (slot);
+ caja_spatial_window_save_geometry (window, slot->viewed_file);
+ caja_spatial_window_save_scroll_position (window, slot);
+ caja_spatial_window_save_show_hidden_files_mode (window, slot->viewed_file);
}
static void
real_close_slot (CajaWindowPane *pane,
CajaWindowSlot *slot)
{
+ CajaSpatialWindow *window;
+
+ window = CAJA_SPATIAL_WINDOW (pane->window);
+
/* Save spatial data for close if we didn't already */
- if (!CAJA_SPATIAL_WINDOW (pane->window)->details->saved_data_on_close)
- {
- save_spatial_data (slot);
+ if (!window->details->saved_data_on_close) {
+ save_spatial_data (window, slot);
}
- EEL_CALL_PARENT (CAJA_WINDOW_CLASS,
- close_slot, (pane, slot));
+ CAJA_WINDOW_CLASS (caja_spatial_window_parent_class)->close_slot (pane, slot);
}
static void
real_window_close (CajaWindow *window)
{
CajaWindowSlot *slot;
+ CajaSpatialWindow *self;
+
+ self = CAJA_SPATIAL_WINDOW (window);
/* We're closing the window, save the geometry. */
/* Note that we do this in window close, not slot close, because slot
* close is too late, by then the widgets have been unrealized.
* This is for the close by WM case, if you're closing via Ctrl-W that
* means we close the slots first and this is not an issue */
- if (window->details->active_pane != NULL &&
- window->details->active_pane->active_slot != NULL)
- {
- slot = window->details->active_pane->active_slot;
+ slot = caja_window_get_active_slot (window);
- save_spatial_data (slot);
- CAJA_SPATIAL_WINDOW (window)->details->saved_data_on_close = TRUE;
+ if (slot != NULL) {
+ save_spatial_data (self, slot);
+ self->details->saved_data_on_close = TRUE;
}
- EEL_CALL_PARENT (CAJA_WINDOW_CLASS,
- close, (window));
+ if (CAJA_WINDOW_CLASS (caja_spatial_window_parent_class)->close != NULL) {
+ CAJA_WINDOW_CLASS (caja_spatial_window_parent_class)->close (window);
+ }
}
static void
@@ -559,18 +522,13 @@ location_menu_item_activated_callback (GtkWidget *menu_item,
CajaWindow *window)
{
CajaWindowSlot *slot;
- char *location;
GFile *current;
GFile *dest;
GdkEvent *event;
- slot = window->details->active_pane->active_slot;
-
- location = caja_window_slot_get_location_uri (slot);
- current = g_file_new_for_uri (location);
- g_free (location);
-
- dest = g_object_get_data (G_OBJECT (menu_item), "uri");
+ slot = caja_window_get_active_slot (window);
+ current = caja_window_slot_get_location (slot);
+ dest = g_object_get_data (G_OBJECT (menu_item), "location");
event = gtk_get_current_event();
@@ -583,27 +541,25 @@ location_menu_item_activated_callback (GtkWidget *menu_item,
close_behind = FALSE;
selection = NULL;
- child = g_object_get_data (G_OBJECT(menu_item), "child_uri");
- if (child != NULL)
- {
+ child = g_object_get_data (G_OBJECT(menu_item), "child_location");
+ if (child != NULL) {
selection = g_list_prepend (NULL, g_object_ref (child));
}
if (event != NULL && ((GdkEventAny *) event)->type == GDK_BUTTON_RELEASE &&
(((GdkEventButton *) event)->button == 2 ||
- (((GdkEventButton *) event)->state & GDK_SHIFT_MASK) != 0))
- {
+ (((GdkEventButton *) event)->state & GDK_SHIFT_MASK) != 0)) {
close_behind = TRUE;
}
caja_window_slot_open_location_with_selection
(slot, dest, selection, close_behind);
- eel_g_object_list_free (selection);
+ g_list_foreach(selection, (GFunc) g_object_unref, NULL);
+ g_list_free(selection);
}
- if (event != NULL)
- {
+ if (event != NULL) {
gdk_event_free (event);
}
@@ -679,8 +635,8 @@ menu_popup_pos (GtkMenu *menu,
widget = user_data;
- gtk_widget_size_request (GTK_WIDGET (menu), &menu_requisition);
- gtk_widget_size_request (widget, &button_requisition);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &button_requisition, NULL);
gtk_widget_get_allocation (widget, &allocation);
gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
@@ -697,9 +653,11 @@ location_button_pressed_callback (GtkWidget *widget,
GdkEventButton *event,
CajaWindow *window)
{
+ CajaWindowSlot *slot;
CajaView *view;
- view = window->details->active_pane->active_slot->content_view;
+ slot = caja_window_get_active_slot (window);
+ view = slot->content_view;
if (event->button == 3 && view != NULL)
{
@@ -715,37 +673,31 @@ location_button_clicked_callback (GtkWidget *widget,
{
CajaWindowSlot *slot;
GtkWidget *popup, *menu_item, *first_item = NULL;
- char *location;
- GFile *uri;
- GFile *child_uri;
+ GFile *location;
+ GFile *child_location;
GMainLoop *loop;
- slot = CAJA_WINDOW (window)->details->active_pane->active_slot;
+ slot = caja_window_get_active_slot (CAJA_WINDOW (window));
popup = gtk_menu_new ();
first_item = NULL;
- location = caja_window_slot_get_location_uri (slot);
+ location = caja_window_slot_get_location (slot);
g_return_if_fail (location != NULL);
- uri = g_file_new_for_uri (location);
- g_free (location);
-
- child_uri = NULL;
- while (uri != NULL)
- {
+ child_location = NULL;
+ while (location != NULL) {
CajaFile *file;
char *name;
- file = caja_file_get (uri);
+ file = caja_file_get (location);
name = caja_file_get_display_name (file);
menu_item = gtk_image_menu_item_new_with_label (name);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menu_item), TRUE);
g_free (name);
- if (first_item == NULL)
- {
+ if (first_item == NULL) {
first_item = menu_item;
}
@@ -761,35 +713,31 @@ location_button_clicked_callback (GtkWidget *widget,
window);
g_object_set_data_full (G_OBJECT (menu_item),
- "uri",
- g_object_ref (uri),
+ "location",
+ g_object_ref (location),
(GDestroyNotify)g_object_unref);
- if (child_uri)
- {
+ if (child_location) {
g_object_set_data_full (G_OBJECT (menu_item),
- "child_uri",
- g_object_ref (child_uri),
+ "child_location",
+ g_object_ref (child_location),
(GDestroyNotify)g_object_unref);
}
gtk_menu_shell_prepend (GTK_MENU_SHELL (popup), menu_item);
- if (child_uri)
- {
- g_object_unref (child_uri);
+ if (child_location) {
+ g_object_unref (child_location);
}
- child_uri = uri;
- uri = g_file_get_parent (uri);
+ child_location = location;
+ location = g_file_get_parent (location);
}
- if (child_uri)
- {
- g_object_unref (child_uri);
+ if (child_location) {
+ g_object_unref (child_location);
}
- if (uri)
- {
- g_object_unref (uri);
+ if (location) {
+ g_object_unref (location);
}
gtk_menu_set_screen (GTK_MENU (popup), gtk_widget_get_screen (widget));
@@ -813,12 +761,12 @@ location_button_clicked_callback (GtkWidget *widget,
static int
get_dnd_icon_size (CajaSpatialWindow *window)
{
- CajaWindow *parent;
+ CajaWindowSlot *active_slot;
CajaView *view;
CajaZoomLevel zoom_level;
- parent = CAJA_WINDOW(window);
- view = parent->details->active_pane->active_slot->content_view;
+ active_slot = caja_window_get_active_slot (CAJA_WINDOW (window));
+ view = active_slot->content_view;
if (view == NULL)
{
@@ -829,7 +777,6 @@ get_dnd_icon_size (CajaSpatialWindow *window)
zoom_level = caja_view_get_zoom_level (view);
return caja_get_icon_size_for_zoom_level (zoom_level);
}
-
}
static void
@@ -1068,8 +1015,6 @@ caja_spatial_window_init (CajaSpatialWindow *window)
pane = caja_window_pane_new (win);
win->details->panes = g_list_prepend (win->details->panes, pane);
- window->affect_spatial_window_on_next_location_change = TRUE;
-
vbox = gtk_vbox_new (FALSE, 0);
gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table),
vbox,
@@ -1164,45 +1109,39 @@ caja_spatial_window_init (CajaSpatialWindow *window)
}
static void
-caja_spatial_window_class_init (CajaSpatialWindowClass *class)
+caja_spatial_window_class_init (CajaSpatialWindowClass *klass)
{
GtkBindingSet *binding_set;
-
- CAJA_WINDOW_CLASS (class)->window_type = CAJA_WINDOW_SPATIAL;
- CAJA_WINDOW_CLASS (class)->bookmarks_placeholder = MENU_PATH_SPATIAL_BOOKMARKS_PLACEHOLDER;
-
- G_OBJECT_CLASS (class)->finalize = caja_spatial_window_finalize;
- GTK_OBJECT_CLASS (class)->destroy = caja_spatial_window_destroy;
- GTK_WIDGET_CLASS (class)->show = caja_spatial_window_show;
- GTK_WIDGET_CLASS (class)->configure_event = caja_spatial_window_configure_event;
- GTK_WIDGET_CLASS (class)->unrealize = caja_spatial_window_unrealize;
- GTK_WIDGET_CLASS (class)->window_state_event = caja_spatial_window_state_event;
-
- CAJA_WINDOW_CLASS (class)->prompt_for_location =
- real_prompt_for_location;
- CAJA_WINDOW_CLASS (class)->get_icon =
- real_get_icon;
- CAJA_WINDOW_CLASS (class)->sync_title =
- real_sync_title;
- CAJA_WINDOW_CLASS(class)->get_min_size = real_get_min_size;
- CAJA_WINDOW_CLASS(class)->get_default_size = real_get_default_size;
-
- CAJA_WINDOW_CLASS(class)->sync_allow_stop =
- real_sync_allow_stop;
- CAJA_WINDOW_CLASS(class)->set_allow_up =
- real_set_allow_up;
-
- CAJA_WINDOW_CLASS (class)->open_slot = real_open_slot;
- CAJA_WINDOW_CLASS (class)->close = real_window_close;
- CAJA_WINDOW_CLASS (class)->close_slot = real_close_slot;
-
- binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK,
+ CajaWindowClass *nclass = CAJA_WINDOW_CLASS (klass);
+ GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+
+ nclass->window_type = CAJA_WINDOW_SPATIAL;
+ nclass->bookmarks_placeholder = MENU_PATH_SPATIAL_BOOKMARKS_PLACEHOLDER;
+ nclass->prompt_for_location = real_prompt_for_location;
+ nclass->get_icon = real_get_icon;
+ nclass->sync_title = real_sync_title;
+ nclass->get_min_size = real_get_min_size;
+ nclass->get_default_size = real_get_default_size;
+ nclass->sync_allow_stop = real_sync_allow_stop;
+ nclass->set_allow_up = real_set_allow_up;
+ nclass->open_slot = real_open_slot;
+ nclass->close = real_window_close;
+ nclass->close_slot = real_close_slot;
+
+ wclass->show = caja_spatial_window_show;
+ wclass->configure_event = caja_spatial_window_configure_event;
+ wclass->unrealize = caja_spatial_window_unrealize;
+ wclass->window_state_event = caja_spatial_window_state_event;
+
+ G_OBJECT_CLASS (klass)->finalize = caja_spatial_window_finalize;
+
+ binding_set = gtk_binding_set_by_class (klass);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK,
"go_up", 1,
G_TYPE_BOOLEAN, TRUE);
- gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_SHIFT_MASK | GDK_MOD1_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_SHIFT_MASK | GDK_MOD1_MASK,
"go_up", 1,
G_TYPE_BOOLEAN, TRUE);
- g_type_class_add_private (G_OBJECT_CLASS (class), sizeof(CajaSpatialWindowDetails));
+ g_type_class_add_private (klass, sizeof(CajaSpatialWindowDetails));
}
diff --git a/src/caja-spatial-window.h b/src/caja-spatial-window.h
index f877aaf1..a012e88e 100644
--- a/src/caja-spatial-window.h
+++ b/src/caja-spatial-window.h
@@ -53,8 +53,6 @@ struct _CajaSpatialWindow
{
CajaWindow parent_object;
- gboolean affect_spatial_window_on_next_location_change;
-
CajaSpatialWindowDetails *details;
};
diff --git a/src/caja-trash-bar.c b/src/caja-trash-bar.c
index 77e60f88..beb993bd 100644
--- a/src/caja-trash-bar.c
+++ b/src/caja-trash-bar.c
@@ -70,7 +70,8 @@ restore_button_clicked_cb (GtkWidget *button,
caja_restore_files_from_trash (files, GTK_WINDOW (gtk_widget_get_toplevel (button)));
caja_file_list_free (files);
- eel_g_object_list_free (locations);
+ g_list_foreach(locations, (GFunc) g_object_unref, NULL);
+ g_list_free(locations);
}
static void
diff --git a/src/caja-view-as-action.c b/src/caja-view-as-action.c
index 645d8057..87785855 100644
--- a/src/caja-view-as-action.c
+++ b/src/caja-view-as-action.c
@@ -134,7 +134,7 @@ view_as_changed_callback (CajaWindow *window,
node = node->next, ++index)
{
info = caja_view_factory_lookup (node->data);
- gtk_combo_box_append_text (combo_box, _(info->view_combo_label));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _(info->view_combo_label));
if (caja_window_slot_content_view_matches_iid (slot, (char *)node->data))
{
@@ -149,8 +149,8 @@ view_as_changed_callback (CajaWindow *window,
id = caja_window_slot_get_content_view_id (slot);
info = caja_view_factory_lookup (id);
- gtk_combo_box_append_text (combo_box,
- _(info->view_combo_label));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box),
+ _(info->view_combo_label));
selected_index = index;
}
@@ -179,7 +179,7 @@ connect_proxy (GtkAction *action,
gtk_container_set_border_width (GTK_CONTAINER (item), 4);
gtk_container_add (GTK_CONTAINER (item), view_as_menu_vbox);
- view_as_combo_box = gtk_combo_box_new_text ();
+ view_as_combo_box = gtk_combo_box_text_new ();
gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (view_as_combo_box), FALSE);
gtk_box_pack_end (GTK_BOX (view_as_menu_vbox), view_as_combo_box, TRUE, FALSE, 0);
diff --git a/src/caja-window-bookmarks.c b/src/caja-window-bookmarks.c
index e2b6ec73..f96b823f 100644
--- a/src/caja-window-bookmarks.c
+++ b/src/caja-window-bookmarks.c
@@ -62,7 +62,7 @@ remove_bookmarks_for_uri_if_yes (GtkDialog *dialog, int response, gpointer callb
caja_bookmark_list_delete_items_with_uri (window->details->bookmark_list, uri);
}
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c
index 35091bed..5156cb18 100644
--- a/src/caja-window-manage-views.c
+++ b/src/caja-window-manage-views.c
@@ -84,9 +84,11 @@
static void begin_location_change (CajaWindowSlot *slot,
GFile *location,
GList *new_selection,
- CajaLocationChangeType type,
+ CajaLocationChangeType type,
guint distance,
- const char *scroll_pos);
+ const char *scroll_pos,
+ CajaWindowGoToCallback callback,
+ gpointer user_data);
static void free_location_change (CajaWindowSlot *slot);
static void end_location_change (CajaWindowSlot *slot);
static void cancel_location_change (CajaWindowSlot *slot);
@@ -511,23 +513,28 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot,
GFile *location,
CajaWindowOpenMode mode,
CajaWindowOpenFlags flags,
- GList *new_selection)
+ GList *new_selection,
+ CajaWindowGoToCallback callback,
+ gpointer user_data)
{
CajaWindow *window;
CajaWindow *target_window;
CajaWindowPane *pane;
CajaWindowSlot *target_slot;
CajaWindowOpenFlags slot_flags;
- gboolean do_load_location = TRUE;
+ gboolean existing = FALSE;
GFile *old_location;
char *old_uri, *new_uri;
int new_slot_position;
GList *l;
+ gboolean target_spatial, target_navigation, target_same;
+ gboolean is_desktop;
window = slot->pane->window;
target_window = NULL;
target_slot = NULL;
+ target_spatial = target_navigation = target_same = FALSE;
old_uri = caja_window_slot_get_location_uri (slot);
if (old_uri == NULL)
@@ -546,87 +553,86 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot,
g_assert (!((flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0 &&
(flags & CAJA_WINDOW_OPEN_FLAG_NEW_TAB) != 0));
+ is_desktop = CAJA_IS_DESKTOP_WINDOW (window);
+ target_same = is_desktop &&
+ !caja_desktop_window_loaded (CAJA_DESKTOP_WINDOW (window));
old_location = caja_window_slot_get_location (slot);
+
switch (mode)
{
case CAJA_WINDOW_OPEN_ACCORDING_TO_MODE :
- if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER))
- {
- target_window = window;
- if (CAJA_IS_SPATIAL_WINDOW (window))
- {
- if (!CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change)
- {
- target_window = caja_application_create_navigation_window
- (window->application,
- NULL,
- gtk_window_get_screen (GTK_WINDOW (window)));
- }
- else
- {
- CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = FALSE;
- }
- }
- else if ((flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0)
- {
- target_window = caja_application_create_navigation_window
- (window->application,
- NULL,
- gtk_window_get_screen (GTK_WINDOW (window)));
+ if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ /* always use browser: if we're on the desktop the target is a new navigation window,
+ * otherwise it's the same window.
+ */
+ if (is_desktop) {
+ target_navigation = TRUE;
+ } else {
+ target_same = TRUE;
}
}
else if (CAJA_IS_SPATIAL_WINDOW (window))
{
- if (!CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change)
- {
- target_window = caja_application_present_spatial_window_with_selection (
- window->application,
- window,
- NULL,
- location,
- new_selection,
- gtk_window_get_screen (GTK_WINDOW (window)));
- do_load_location = FALSE;
- }
- else
- {
- CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = FALSE;
- target_window = window;
- }
- }
- else if (flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW)
- {
- target_window = caja_application_create_navigation_window
- (window->application,
- NULL,
- gtk_window_get_screen (GTK_WINDOW (window)));
- }
- else
- {
- target_window = window;
+ /* don't always use browser: if source is spatial, target is spatial */
+ target_spatial = TRUE;
+ } else if (flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) {
+ /* if it's specified to open a new window, and we're not using spatial,
+ * the target is a navigation.
+ */
+ target_navigation = TRUE;
}
break;
case CAJA_WINDOW_OPEN_IN_SPATIAL :
- target_window = caja_application_present_spatial_window (
- window->application,
- window,
- NULL,
- location,
- gtk_window_get_screen (GTK_WINDOW (window)));
+ target_spatial = TRUE;
break;
case CAJA_WINDOW_OPEN_IN_NAVIGATION :
- target_window = caja_application_create_navigation_window
- (window->application,
- NULL,
- gtk_window_get_screen (GTK_WINDOW (window)));
+ target_navigation = TRUE;
break;
default :
- g_warning ("Unknown open location mode");
+ g_critical ("Unknown open location mode");
g_object_unref (old_location);
return;
}
+ /* now get/create the window according to the mode */
+ if (target_same) {
+ target_window = window;
+ } else if (target_navigation) {
+ target_window = caja_application_create_navigation_window
+ (window->application,
+ NULL,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ } else {
+ target_window = caja_application_get_spatial_window
+ (window->application,
+ window,
+ NULL,
+ location,
+ gtk_window_get_screen (GTK_WINDOW (window)),
+ &existing);
+ }
+
+ /* if the spatial window is already showing, present it and set the
+ * new selection, if present.
+ */
+ if (existing) {
+ target_slot = target_window->details->active_pane->active_slot;
+
+ gtk_window_present (GTK_WINDOW (target_window));
+
+ if (new_selection != NULL && slot->content_view != NULL) {
+ caja_view_set_selection (target_slot->content_view, new_selection);
+ }
+
+ /* call the callback successfully */
+ if (callback != NULL) {
+ callback (window, NULL, user_data);
+ }
+
+ return;
+ }
+
g_assert (target_window != NULL);
if ((flags & CAJA_WINDOW_OPEN_FLAG_NEW_TAB) != 0 &&
@@ -676,14 +682,14 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot,
}
}
- if ((!do_load_location) ||
- (target_window == window && target_slot == slot &&
- old_location && g_file_equal (old_location, location)))
- {
- if (old_location)
- {
- g_object_unref (old_location);
+ if ((target_window == window && target_slot == slot &&
+ old_location && g_file_equal (old_location, location))) {
+
+ if (callback != NULL) {
+ callback (window, NULL, user_data);
}
+
+ g_object_unref (old_location);
return;
}
@@ -693,7 +699,7 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot,
}
begin_location_change (target_slot, location, new_selection,
- CAJA_LOCATION_CHANGE_STANDARD, 0, NULL);
+ CAJA_LOCATION_CHANGE_STANDARD, 0, NULL, callback, user_data);
/* Additionally, load this in all slots that have no location, this means
we load both panes in e.g. a newly opened dual pane window. */
@@ -701,10 +707,9 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot,
{
pane = l->data;
slot = pane->active_slot;
- if (slot->location == NULL && slot->pending_location == NULL)
- {
+ if (slot->location == NULL && slot->pending_location == NULL) {
begin_location_change (slot, location, new_selection,
- CAJA_LOCATION_CHANGE_STANDARD, 0, NULL);
+ CAJA_LOCATION_CHANGE_STANDARD, 0, NULL, NULL, NULL);
}
}
}
@@ -724,7 +729,7 @@ caja_window_slot_open_location (CajaWindowSlot *slot,
caja_window_slot_open_location_full (slot, location,
CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
- flags, NULL);
+ flags, NULL, NULL, NULL);
}
void
@@ -742,7 +747,7 @@ caja_window_slot_open_location_with_selection (CajaWindowSlot *slot,
}
caja_window_slot_open_location_full (slot, location,
CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
- flags, selection);
+ flags, selection, NULL, NULL);
}
@@ -766,7 +771,7 @@ caja_window_slot_go_home (CajaWindowSlot *slot, gboolean new_tab)
home = g_file_new_for_path (g_get_home_dir ());
caja_window_slot_open_location_full (slot, home,
CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
- flags, NULL);
+ flags, NULL, NULL, NULL);
g_object_unref (home);
}
@@ -855,9 +860,23 @@ caja_window_slot_content_view_matches_iid (CajaWindowSlot *slot,
{
return FALSE;
}
- return eel_strcmp (caja_view_get_view_id (slot->content_view), iid) == 0;
+ return g_strcmp0 (caja_view_get_view_id (slot->content_view), iid) == 0;
}
+static gboolean
+report_callback (CajaWindowSlot *slot,
+ GError *error)
+{
+ if (slot->open_callback != NULL) {
+ slot->open_callback (slot->pane->window, error, slot->open_callback_user_data);
+ slot->open_callback = NULL;
+ slot->open_callback_user_data = NULL;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
/*
* begin_location_change
@@ -870,6 +889,8 @@ caja_window_slot_content_view_matches_iid (CajaWindowSlot *slot,
* @distance: If type is back or forward, the index into the back or forward chain. If
* type is standard or reload, this is ignored, and must be 0.
* @scroll_pos: The file to scroll to when the location is loaded.
+ * @callback: function to be called when the location is changed.
+ * @user_data: data for @callback.
*
* This is the core function for changing the location of a window. Every change to the
* location begins here.
@@ -880,7 +901,9 @@ begin_location_change (CajaWindowSlot *slot,
GList *new_selection,
CajaLocationChangeType type,
guint distance,
- const char *scroll_pos)
+ const char *scroll_pos,
+ CajaWindowGoToCallback callback,
+ gpointer user_data)
{
CajaWindow *window;
CajaDirectory *directory;
@@ -914,6 +937,9 @@ begin_location_change (CajaWindowSlot *slot,
slot->pending_scroll_to = g_strdup (scroll_pos);
+ slot->open_callback = callback;
+ slot->open_callback_user_data = user_data;
+
directory = caja_directory_get (location);
/* The code to force a reload is here because if we do it
@@ -1245,11 +1271,15 @@ got_file_info_for_view_selection_callback (CajaFile *file,
}
create_content_view (slot, view_id);
g_free (view_id);
+
+ report_callback (slot, NULL);
}
else
{
- display_view_selection_failure (window, file,
- location, error);
+ if (!report_callback (slot, error)) {
+ display_view_selection_failure (window, file,
+ location, error);
+ }
if (!gtk_widget_get_visible (GTK_WIDGET (window)))
{
@@ -1261,11 +1291,6 @@ got_file_info_for_view_selection_callback (CajaFile *file,
{
g_assert (caja_application_get_n_windows () == 1);
- /* Make sure we re-use this window */
- if (CAJA_IS_SPATIAL_WINDOW (window))
- {
- CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = TRUE;
- }
/* the user could have typed in a home directory that doesn't exist,
in which case going home would cause an infinite loop, so we
better test for that */
@@ -1288,13 +1313,13 @@ got_file_info_for_view_selection_callback (CajaFile *file,
}
else
{
- gtk_object_destroy (GTK_OBJECT (window));
+ gtk_widget_destroy (GTK_WIDGET (window));
}
}
else
{
/* Since this is a window, destroying it will also unref it. */
- gtk_object_destroy (GTK_OBJECT (window));
+ gtk_widget_destroy (GTK_WIDGET (window));
}
}
else
@@ -1365,7 +1390,7 @@ create_content_view (CajaWindowSlot *slot,
}
if (slot->content_view != NULL &&
- eel_strcmp (caja_view_get_view_id (slot->content_view),
+ g_strcmp0 (caja_view_get_view_id (slot->content_view),
view_id) == 0)
{
/* reuse existing content view */
@@ -1396,7 +1421,8 @@ create_content_view (CajaWindowSlot *slot,
FALSE,
TRUE);
- eel_g_object_list_free (slot->pending_selection);
+ g_list_foreach(slot->pending_selection, (GFunc) g_object_unref, NULL);
+ g_list_free(slot->pending_selection);
slot->pending_selection = NULL;
}
else if (slot->location != NULL)
@@ -1407,7 +1433,8 @@ create_content_view (CajaWindowSlot *slot,
selection,
FALSE,
TRUE);
- eel_g_object_list_free (selection);
+ g_list_foreach(selection, (GFunc) g_object_unref, NULL);
+ g_list_free(selection);
}
else
{
@@ -1465,7 +1492,8 @@ load_new_location (CajaWindowSlot *slot,
caja_view_set_selection (view, selection_copy);
}
- eel_g_object_list_free (selection_copy);
+ g_list_foreach(selection_copy, (GFunc) g_object_unref, NULL);
+ g_list_free(selection_copy);
}
/* A view started to load the location its viewing, either due to
@@ -1922,7 +1950,8 @@ free_location_change (CajaWindowSlot *slot)
}
slot->pending_location = NULL;
- eel_g_object_list_free (slot->pending_selection);
+ g_list_foreach(slot->pending_selection, (GFunc) g_object_unref, NULL);
+ g_list_free(slot->pending_selection);
slot->pending_selection = NULL;
/* Don't free pending_scroll_to, since thats needed until
@@ -1976,7 +2005,8 @@ cancel_location_change (CajaWindowSlot *slot)
selection,
TRUE,
FALSE);
- eel_g_object_list_free (selection);
+ g_list_foreach(selection, (GFunc) g_object_unref, NULL);
+ g_list_free(selection);
}
end_location_change (slot);
@@ -2034,7 +2064,7 @@ caja_window_report_view_failed (CajaWindow *window,
{
/* We loose the pending selection change here, but who cares... */
begin_location_change (slot, fallback_load_location, NULL,
- CAJA_LOCATION_CHANGE_FALLBACK, 0, NULL);
+ CAJA_LOCATION_CHANGE_FALLBACK, 0, NULL, NULL, NULL);
g_object_unref (fallback_load_location);
}
@@ -2273,7 +2303,7 @@ caja_navigation_window_back_or_forward (CajaNavigationWindow *window,
caja_window_slot_open_location_full (slot, location,
CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
CAJA_WINDOW_OPEN_FLAG_NEW_TAB,
- NULL);
+ NULL, NULL, NULL);
}
else
{
@@ -2285,7 +2315,8 @@ caja_navigation_window_back_or_forward (CajaNavigationWindow *window,
location, NULL,
back ? CAJA_LOCATION_CHANGE_BACK : CAJA_LOCATION_CHANGE_FORWARD,
distance,
- scroll_pos);
+ scroll_pos,
+ NULL, NULL);
g_free (scroll_pos);
}
@@ -2321,10 +2352,12 @@ caja_window_slot_reload (CajaWindowSlot *slot)
}
begin_location_change
(slot, location, selection,
- CAJA_LOCATION_CHANGE_RELOAD, 0, current_pos);
+ CAJA_LOCATION_CHANGE_RELOAD, 0, current_pos,
+ NULL, NULL);
g_free (current_pos);
g_object_unref (location);
- eel_g_object_list_free (selection);
+ g_list_foreach(selection, (GFunc) g_object_unref, NULL);
+ g_list_free(selection);
}
void
diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c
index 291b6e66..b0522b03 100644
--- a/src/caja-window-menus.c
+++ b/src/caja-window-menus.c
@@ -243,17 +243,9 @@ action_connect_to_server_callback (GtkAction *action,
gpointer user_data)
{
CajaWindow *window = CAJA_WINDOW (user_data);
- CajaWindowSlot *slot;
GtkWidget *dialog;
- GFile *location;
- slot = caja_window_get_active_slot (window);
- location = caja_window_slot_get_location (slot);
- dialog = caja_connect_server_dialog_new (window, location);
- if (location)
- {
- g_object_unref (location);
- }
+ dialog = caja_connect_server_dialog_new (window);
gtk_widget_show (dialog);
}
diff --git a/src/caja-window-private.h b/src/caja-window-private.h
index 83a6da0f..73a9c29c 100644
--- a/src/caja-window-private.h
+++ b/src/caja-window-private.h
@@ -33,6 +33,7 @@
#include "caja-window-pane.h"
#include "caja-spatial-window.h"
#include "caja-navigation-window.h"
+#include "caja-bookmark-list.h"
#include <libcaja-private/caja-directory.h>
@@ -178,9 +179,6 @@ void caja_menus_append_bookmark_to_menu (CajaWindow
guint merge_id,
GCallback refresh_callback,
CajaBookmarkFailedCallback failed_callback);
-#ifdef NEW_UI_COMPLETE
-void caja_window_go_up (CajaWindow *window);
-#endif
void caja_window_update_find_menu_item (CajaWindow *window);
void caja_window_zoom_in (CajaWindow *window);
void caja_window_zoom_out (CajaWindow *window);
diff --git a/src/caja-window-slot.c b/src/caja-window-slot.c
index e82bcb00..5d87a60f 100644
--- a/src/caja-window-slot.c
+++ b/src/caja-window-slot.c
@@ -662,7 +662,8 @@ caja_window_slot_dispose (GObject *object)
g_object_ref (slot->location);
}
- eel_g_list_free_deep (slot->pending_selection);
+ g_list_foreach(slot->pending_selection, (GFunc) g_free, NULL);
+ g_list_free(slot->pending_selection);
slot->pending_selection = NULL;
if (slot->current_location_bookmark != NULL)
diff --git a/src/caja-window-slot.h b/src/caja-window-slot.h
index f25bdf41..ea858166 100644
--- a/src/caja-window-slot.h
+++ b/src/caja-window-slot.h
@@ -109,6 +109,8 @@ struct CajaWindowSlot
GCancellable *mount_cancellable;
GError *mount_error;
gboolean tried_mount;
+ CajaWindowGoToCallback open_callback;
+ gpointer open_callback_user_data;
GCancellable *find_mount_cancellable;
@@ -139,7 +141,9 @@ void caja_window_slot_open_location_full (CajaWindowSlot *slot,
GFile *location,
CajaWindowOpenMode mode,
CajaWindowOpenFlags flags,
- GList *new_selection);
+ GList *new_selection,
+ CajaWindowGoToCallback callback,
+ gpointer user_data);
void caja_window_slot_stop_loading (CajaWindowSlot *slot);
void caja_window_slot_set_content_view (CajaWindowSlot *slot,
@@ -156,7 +160,12 @@ void caja_window_slot_disconnect_content_view (CajaWindowSlo
#define caja_window_slot_go_to(slot,location, new_tab) \
caja_window_slot_open_location_full(slot, location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, \
(new_tab ? CAJA_WINDOW_OPEN_FLAG_NEW_TAB : 0), \
- NULL)
+ NULL, NULL, NULL)
+
+#define caja_window_slot_go_to_full(slot, location, new_tab, callback, user_data) \
+ caja_window_slot_open_location_full(slot, location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, \
+ (new_tab ? CAJA_WINDOW_OPEN_FLAG_NEW_TAB : 0), \
+ NULL, callback, user_data)
#define caja_window_slot_go_to_with_selection(slot,location,new_selection) \
caja_window_slot_open_location_with_selection(slot, location, new_selection, FALSE)
diff --git a/src/caja-window-toolbars.c b/src/caja-window-toolbars.c
index d777ab41..1d6a22fb 100644
--- a/src/caja-window-toolbars.c
+++ b/src/caja-window-toolbars.c
@@ -59,19 +59,16 @@ caja_navigation_window_set_spinner_active (CajaNavigationWindow *window,
gboolean allow)
{
if (( window->details->spinner_active && allow) ||
- (!window->details->spinner_active && !allow))
- {
+ (!window->details->spinner_active && !allow)) {
return;
}
window->details->spinner_active = allow;
- if (allow)
- {
+ if (allow) {
+ gtk_widget_show (window->details->spinner);
gtk_spinner_start (GTK_SPINNER (window->details->spinner));
- }
- else
- {
- gtk_spinner_stop (GTK_SPINNER (window->details->spinner));
+ } else {
+ gtk_widget_hide (window->details->spinner);
}
}
diff --git a/src/caja-window.c b/src/caja-window.c
index 29830511..35b78432 100644
--- a/src/caja-window.c
+++ b/src/caja-window.c
@@ -40,8 +40,8 @@
#include "caja-zoom-control.h"
#include "caja-search-bar.h"
#include "caja-navigation-window-pane.h"
+#include "caja-src-marshal.h"
#include <eel/eel-debug.h>
-#include <eel/eel-marshal.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -55,9 +55,7 @@
#include <libcaja-private/caja-file-utilities.h>
#include <libcaja-private/caja-file-attributes.h>
#include <libcaja-private/caja-global-preferences.h>
-#include <libcaja-private/caja-horizontal-splitter.h>
#include <libcaja-private/caja-metadata.h>
-#include <libcaja-private/caja-marshal.h>
#include <libcaja-private/caja-mime-actions.h>
#include <libcaja-private/caja-program-choosing.h>
#include <libcaja-private/caja-view-factory.h>
@@ -189,10 +187,14 @@ caja_window_init (CajaWindow *window)
g_signal_connect_object (caja_signaller_get_current (), "popup_menu_changed",
G_CALLBACK (caja_window_load_extension_menus), window, G_CONNECT_SWAPPED);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_quit_add_destroy (1, GTK_WIDGET (window));
+#else
gtk_quit_add_destroy (1, GTK_OBJECT (window));
+#endif
/* Keep the main event loop alive as long as the window exists */
- caja_main_event_loop_register (GTK_OBJECT (window));
+ caja_main_event_loop_register (GTK_WIDGET (window));
}
/* Unconditionally synchronize the GtkUIManager of WINDOW. */
@@ -237,6 +239,17 @@ caja_window_go_to (CajaWindow *window, GFile *location)
}
void
+caja_window_go_to_full (CajaWindow *window,
+ GFile *location,
+ CajaWindowGoToCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (CAJA_IS_WINDOW (window));
+
+ caja_window_slot_go_to_full (window->details->active_pane->active_slot, location, FALSE, callback, user_data);
+}
+
+void
caja_window_go_to_with_selection (CajaWindow *window, GFile *location, GList *new_selection)
{
g_return_if_fail (CAJA_IS_WINDOW (window));
@@ -252,6 +265,41 @@ caja_window_go_up_signal (CajaWindow *window, gboolean close_behind)
}
void
+caja_window_new_tab (CajaWindow *window)
+{
+ CajaWindowSlot *current_slot;
+ CajaWindowSlot *new_slot;
+ CajaWindowOpenFlags flags;
+ GFile *location;
+ int new_slot_position;
+ char *scheme;
+
+ current_slot = window->details->active_pane->active_slot;
+ location = caja_window_slot_get_location (current_slot);
+
+ if (location != NULL) {
+ flags = 0;
+
+ new_slot_position = g_settings_get_enum (caja_preferences, CAJA_PREFERENCES_NEW_TAB_POSITION);
+ if (new_slot_position == CAJA_NEW_TAB_POSITION_END) {
+ flags = CAJA_WINDOW_OPEN_SLOT_APPEND;
+ }
+
+ scheme = g_file_get_uri_scheme (location);
+ if (!strcmp (scheme, "x-caja-search")) {
+ g_object_unref (location);
+ location = g_file_new_for_path (g_get_home_dir ());
+ }
+ g_free (scheme);
+
+ new_slot = caja_window_open_slot (current_slot->pane, flags);
+ caja_window_set_active_slot (window, new_slot);
+ caja_window_slot_go_to (new_slot, location, FALSE);
+ g_object_unref (location);
+ }
+}
+
+void
caja_window_go_up (CajaWindow *window, gboolean close_behind, gboolean new_tab)
{
CajaWindowSlot *slot;
@@ -290,11 +338,13 @@ caja_window_go_up (CajaWindow *window, gboolean close_behind, gboolean new_tab)
caja_window_slot_open_location_full (slot, parent,
CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
flags,
- selection);
+ selection,
+ NULL, NULL);
g_object_unref (parent);
- eel_g_object_list_free (selection);
+ g_list_foreach(selection, (GFunc) g_object_unref, NULL);
+ g_list_free(selection);
}
static void
@@ -478,30 +528,18 @@ static void
caja_window_set_initial_window_geometry (CajaWindow *window)
{
GdkScreen *screen;
- guint max_width_for_screen, max_height_for_screen, min_width, min_height;
+ guint max_width_for_screen, max_height_for_screen;
+#if !GTK_CHECK_VERSION(3,0,0)
+ guint min_width, min_height;
+#endif
guint default_width, default_height;
screen = gtk_window_get_screen (GTK_WINDOW (window));
- /* Don't let GTK determine the minimum size
- * automatically. It will insist that the window be
- * really wide based on some misguided notion about
- * the content view area. Also, it might start the
- * window wider (or taller) than the screen, which
- * is evil. So we choose semi-arbitrary initial and
- * minimum widths instead of letting GTK decide.
- */
- /* FIXME - the above comment suggests that the size request
- * of the content view area is wrong, probably because of
- * another stupid set_usize someplace. If someone gets the
- * content view area's size request right then we can
- * probably remove this broken set_size_request() here.
- */
-
max_width_for_screen = get_max_forced_width (screen);
max_height_for_screen = get_max_forced_height (screen);
+#if !GTK_CHECK_VERSION(3,0,0)
EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window,
get_min_size, (window, &min_width, &min_height));
@@ -510,6 +548,7 @@ caja_window_set_initial_window_geometry (CajaWindow *window)
max_width_for_screen),
MIN (min_height,
max_height_for_screen));
+#endif
EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window,
get_default_size, (window, &default_width, &default_height));
@@ -567,16 +606,18 @@ caja_window_get_property (GObject *object,
static void
free_stored_viewers (CajaWindow *window)
{
- eel_g_list_free_deep_custom (window->details->short_list_viewers,
- (GFunc) g_free,
- NULL);
+ g_list_foreach(window->details->short_list_viewers, (GFunc) g_free, NULL);
+ g_list_free(window->details->short_list_viewers);
window->details->short_list_viewers = NULL;
g_free (window->details->extra_viewer);
window->details->extra_viewer = NULL;
}
-static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+caja_window_destroy (GtkWidget *object)
+#else
caja_window_destroy (GtkObject *object)
+#endif
{
CajaWindow *window;
GList *panes_copy;
@@ -592,7 +633,11 @@ caja_window_destroy (GtkObject *object)
g_assert (window->details->panes == NULL);
g_assert (window->details->active_pane == NULL);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (caja_window_parent_class)->destroy (object);
+#else
GTK_OBJECT_CLASS (caja_window_parent_class)->destroy (object);
+#endif
}
static void
@@ -947,6 +992,51 @@ caja_window_slot_close (CajaWindowSlot *slot)
caja_window_pane_slot_close (slot->pane, slot);
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void
+caja_window_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GdkScreen *screen;
+ gint max_w, min_w, min_h, default_w, default_h;
+ CajaWindow *window = CAJA_WINDOW (widget);
+
+ screen = gtk_window_get_screen (GTK_WINDOW (widget));
+
+ max_w = get_max_forced_width (screen);
+ EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window,
+ get_min_size, (window, &min_w, &min_h));
+ EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window,
+ get_default_size, (window, &default_w, &default_h));
+
+ *minimal_width = MIN (min_w, max_w);
+ *natural_width = MIN (default_w, max_w);
+}
+
+static void
+caja_window_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GdkScreen *screen;
+ gint max_h, min_w, min_h, default_w, default_h;
+ CajaWindow *window = CAJA_WINDOW (widget);
+
+ screen = gtk_window_get_screen (GTK_WINDOW (widget));
+
+ max_h = get_max_forced_height (screen);
+ EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window,
+ get_min_size, (window, &min_w, &min_h));
+ EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window,
+ get_default_size, (window, &default_w, &default_h));
+
+ *minimal_height = MIN (min_h, max_h);
+ *natural_height = MIN (default_h, max_h);
+}
+
+#else /* GTK_CHECK_VERSION(3,0,0) */
+
static void
caja_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -988,6 +1078,7 @@ caja_window_size_request (GtkWidget *widget,
requisition->height = max_height;
}
}
+#endif /* GTK_CHECK_VERSION(3,0,0) */
static void
caja_window_realize (GtkWidget *widget)
@@ -1099,7 +1190,7 @@ add_view_as_menu_item (CajaWindow *window,
g_snprintf (accel_path, sizeof (accel_path), "<Caja-Window>/%s", action_name);
accel_keyval = gdk_keyval_from_name (accel);
- g_assert (accel_keyval != GDK_VoidSymbol);
+ g_assert (accel_keyval != GDK_KEY_VoidSymbol);
gtk_accel_map_add_entry (accel_path, accel_keyval, GDK_CONTROL_MASK);
gtk_action_set_accel_path (GTK_ACTION (action), accel_path);
@@ -1669,7 +1760,8 @@ caja_send_history_list_changed (void)
static void
free_history_list (void)
{
- eel_g_object_list_free (history_list);
+ g_list_foreach(history_list, (GFunc) g_object_unref, NULL);
+ g_list_free(history_list);
history_list = NULL;
}
@@ -2053,14 +2145,25 @@ caja_window_class_init (CajaWindowClass *class)
{
GtkBindingSet *binding_set;
- G_OBJECT_CLASS (class)->finalize = caja_window_finalize;
G_OBJECT_CLASS (class)->constructor = caja_window_constructor;
G_OBJECT_CLASS (class)->constructed = caja_window_constructed;
G_OBJECT_CLASS (class)->get_property = caja_window_get_property;
G_OBJECT_CLASS (class)->set_property = caja_window_set_property;
+ G_OBJECT_CLASS (class)->finalize = caja_window_finalize;
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
GTK_OBJECT_CLASS (class)->destroy = caja_window_destroy;
+#else
+ GTK_WIDGET_CLASS (class)->destroy = caja_window_destroy;
+#endif
+
GTK_WIDGET_CLASS (class)->show = caja_window_show;
+#if GTK_CHECK_VERSION(3,0,0)
+ GTK_WIDGET_CLASS (class)->get_preferred_width = caja_window_get_preferred_width;
+ GTK_WIDGET_CLASS (class)->get_preferred_height = caja_window_get_preferred_height;
+#else
GTK_WIDGET_CLASS (class)->size_request = caja_window_size_request;
+#endif
GTK_WIDGET_CLASS (class)->realize = caja_window_realize;
GTK_WIDGET_CLASS (class)->key_press_event = caja_window_key_press_event;
class->get_title = real_get_title;
@@ -2082,7 +2185,7 @@ caja_window_class_init (CajaWindowClass *class)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (CajaWindowClass, go_up),
g_signal_accumulator_true_handled, NULL,
- eel_marshal_BOOLEAN__BOOLEAN,
+ caja_src_marshal_BOOLEAN__BOOLEAN,
G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN);
signals[RELOAD] =
g_signal_new ("reload",
@@ -2106,7 +2209,7 @@ caja_window_class_init (CajaWindowClass *class)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- caja_marshal_VOID__INT_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN,
+ caja_src_marshal_VOID__INT_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN,
G_TYPE_NONE, 5,
G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
@@ -2120,12 +2223,12 @@ caja_window_class_init (CajaWindowClass *class)
G_TYPE_NONE, 0);
binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0,
"go_up", 1,
G_TYPE_BOOLEAN, FALSE);
- gtk_binding_entry_add_signal (binding_set, GDK_F5, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_F5, 0,
"reload", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_slash, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, 0,
"prompt-for-location", 1,
G_TYPE_STRING, "/");
@@ -2144,19 +2247,3 @@ caja_window_class_init (CajaWindowClass *class)
g_type_class_add_private (G_OBJECT_CLASS (class), sizeof (CajaWindowDetails));
}
-
-/**
- * caja_window_has_menubar_and_statusbar:
- * @window: A #CajaWindow
- *
- * Queries whether the window should have a menubar and statusbar, based on the
- * window_type from its class structure.
- *
- * Return value: TRUE if the window should have a menubar and statusbar; FALSE
- * otherwise.
- **/
-gboolean
-caja_window_has_menubar_and_statusbar (CajaWindow *window)
-{
- return (caja_window_get_window_type (window) != CAJA_WINDOW_DESKTOP);
-}
diff --git a/src/caja-window.h b/src/caja-window.h
index 46b0fd44..b5ea219c 100644
--- a/src/caja-window.h
+++ b/src/caja-window.h
@@ -122,7 +122,6 @@ struct CajaWindow
CajaWindowDetails *details;
- /** CORBA-related elements **/
CajaApplication *application;
};
@@ -137,16 +136,20 @@ void caja_window_disconnect_content_view (CajaWindow *window,
void caja_window_go_to (CajaWindow *window,
GFile *location);
+void caja_window_go_to_full (CajaWindow *window,
+ GFile *location,
+ CajaWindowGoToCallback callback,
+ gpointer user_data);
void caja_window_go_to_with_selection (CajaWindow *window,
GFile *location,
GList *new_selection);
void caja_window_go_home (CajaWindow *window);
+void caja_window_new_tab (CajaWindow *window);
void caja_window_go_up (CajaWindow *window,
gboolean close_behind,
gboolean new_tab);
void caja_window_prompt_for_location (CajaWindow *window,
const char *initial);
-void caja_window_launch_cd_burner (CajaWindow *window);
void caja_window_display_error (CajaWindow *window,
const char *error_msg);
void caja_window_reload (CajaWindow *window);
@@ -157,9 +160,6 @@ void caja_window_allow_up (CajaWindow *window,
gboolean allow);
void caja_window_allow_stop (CajaWindow *window,
gboolean allow);
-void caja_window_allow_burn_cd (CajaWindow *window,
- gboolean allow);
GtkUIManager * caja_window_get_ui_manager (CajaWindow *window);
-gboolean caja_window_has_menubar_and_statusbar (CajaWindow *window);
#endif
diff --git a/src/caja-zoom-control.c b/src/caja-zoom-control.c
index 8ba974c4..1b251da2 100644
--- a/src/caja-zoom-control.c
+++ b/src/caja-zoom-control.c
@@ -40,11 +40,14 @@
#include <gdk/gdkkeysyms.h>
#include <libcaja-private/caja-file-utilities.h>
#include <libcaja-private/caja-global-preferences.h>
-#include <libcaja-private/caja-marshal.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#if !GTK_CHECK_VERSION(3,0,0)
+#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y)
+#endif
+
enum
{
ZOOM_IN,
@@ -154,8 +157,8 @@ menu_position_under_widget (GtkMenu *menu,
container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
g_assert (container != NULL);
- gtk_widget_size_request (widget, &req);
- gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
+ gtk_widget_get_preferred_size (widget, &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
@@ -723,32 +726,32 @@ caja_zoom_control_class_init (CajaZoomControlClass *class)
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set,
- GDK_KP_Subtract, 0,
+ GDK_KEY_KP_Subtract, 0,
"change_value",
1, GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_STEP_DOWN);
gtk_binding_entry_add_signal (binding_set,
- GDK_minus, 0,
+ GDK_KEY_minus, 0,
"change_value",
1, GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_STEP_DOWN);
gtk_binding_entry_add_signal (binding_set,
- GDK_KP_Equal, 0,
+ GDK_KEY_KP_Equal, 0,
"zoom_to_default",
0);
gtk_binding_entry_add_signal (binding_set,
- GDK_KP_Equal, 0,
+ GDK_KEY_KP_Equal, 0,
"zoom_to_default",
0);
gtk_binding_entry_add_signal (binding_set,
- GDK_KP_Add, 0,
+ GDK_KEY_KP_Add, 0,
"change_value",
1, GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_STEP_UP);
gtk_binding_entry_add_signal (binding_set,
- GDK_plus, 0,
+ GDK_KEY_plus, 0,
"change_value",
1, GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_STEP_UP);
diff --git a/src/file-manager/Makefile.am b/src/file-manager/Makefile.am
index e73afbed..a08d01ad 100644
--- a/src/file-manager/Makefile.am
+++ b/src/file-manager/Makefile.am
@@ -12,6 +12,11 @@ INCLUDES = \
$(DISABLE_DEPRECATED_CFLAGS) \
$(NULL)
+BUILT_SOURCES = \
+ fm-marshal.c \
+ fm-marshal.h \
+ $(NULL)
+
libcaja_file_manager_la_SOURCES = \
fm-actions.h \
fm-desktop-icon-view.c \
@@ -40,6 +45,28 @@ libcaja_file_manager_la_SOURCES = \
caja-audio-mime-types.h \
$(NULL)
+nodist_libcaja_file_manager_la_SOURCES=\
+ $(BUILT_SOURCES) \
+ $(NULL)
+
+fm-marshal.list: $(libcaja_file_manager_la_SOURCES) Makefile.am
+ $(AM_V_GEN)( cd $(srcdir) && \
+ sed -n -e 's/.*fm_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \
+ $(libcaja_file_manager_la_SOURCES) ) \
+ | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > [email protected]
+ @if cmp -s [email protected] $@; then \
+ else \
+ fi
+
+%-marshal.c: %-marshal.list Makefile
+ $(AM_V_GEN)echo "#include \"fm-marshal.h\"" > $@ && \
+ $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c
+
+%-marshal.h: %-marshal.list Makefile
+ $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
+
EMPTY_VIEW_SOURCES = \
fm-empty-view.c \
fm-empty-view.h
@@ -56,4 +83,12 @@ ui_DATA = \
caja-list-view-ui.xml \
$(NULL)
-EXTRA_DIST = $(ui_DATA)
+EXTRA_DIST = \
+ $(ui_DATA) \
+ fm-marshal.list
+
+CLEANFILES = \
+ $(BUILT_SOURCES) \
+ fm-marshal.list \
+ $(NULL)
+
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index ae9e4c02..3885ca13 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -31,13 +31,8 @@
#include <X11/Xatom.h>
#include <gtk/gtk.h>
-#include <dirent.h>
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-mate-extensions.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <fcntl.h>
#include <gdk/gdkx.h>
@@ -64,6 +59,12 @@
#include <sys/types.h>
#include <unistd.h>
+#if !GTK_CHECK_VERSION(3, 0, 0)
+#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment
+#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment
+#define GTK_SCROLLABLE GTK_LAYOUT
+#endif
+
/* Timeout to check the desktop directory for updates */
#define RESCAN_TIMEOUT 4
@@ -80,8 +81,6 @@ struct FMDesktopIconViewDetails
gboolean pending_rescan;
};
-static void fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view);
-static void fm_desktop_icon_view_class_init (FMDesktopIconViewClass *klass);
static void default_zoom_level_changed (gpointer user_data);
static gboolean real_supports_auto_layout (FMIconView *view);
static gboolean real_supports_scaling (FMIconView *view);
@@ -93,9 +92,7 @@ static gboolean real_supports_zooming (FMDirectoryVi
static void fm_desktop_icon_view_update_icon_container_fonts (FMDesktopIconView *view);
static void font_changed_callback (gpointer callback_data);
-EEL_CLASS_BOILERPLATE (FMDesktopIconView,
- fm_desktop_icon_view,
- FM_TYPE_ICON_VIEW)
+G_DEFINE_TYPE (FMDesktopIconView, fm_desktop_icon_view, FM_TYPE_ICON_VIEW)
static char *desktop_directory;
static time_t desktop_dir_modify_time;
@@ -226,7 +223,7 @@ net_workarea_changed (FMDesktopIconView *icon_view,
}
else
{
- screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
+ screen = gdk_window_get_screen (window);
icon_container_set_workarea (
icon_container, screen, workareas, length_returned / sizeof (long));
@@ -263,7 +260,7 @@ desktop_icon_view_property_filter (GdkXEvent *gdk_xevent,
}
static void
-fm_desktop_icon_view_destroy (GtkObject *object)
+fm_desktop_icon_view_dispose (GObject *object)
{
FMDesktopIconView *icon_view;
GtkUIManager *ui_manager;
@@ -285,16 +282,6 @@ fm_desktop_icon_view_destroy (GtkObject *object)
&icon_view->details->desktop_action_group);
}
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-fm_desktop_icon_view_finalize (GObject *object)
-{
- FMDesktopIconView *icon_view;
-
- icon_view = FM_DESKTOP_ICON_VIEW (object);
-
g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
default_zoom_level_changed,
icon_view);
@@ -309,17 +296,13 @@ fm_desktop_icon_view_finalize (GObject *object)
desktop_directory_changed_callback,
NULL);
- g_free (icon_view->details);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (fm_desktop_icon_view_parent_class)->dispose (object);
}
static void
fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class)
{
- G_OBJECT_CLASS (class)->finalize = fm_desktop_icon_view_finalize;
-
- GTK_OBJECT_CLASS (class)->destroy = fm_desktop_icon_view_destroy;
+ G_OBJECT_CLASS (class)->dispose = fm_desktop_icon_view_dispose;
FM_DIRECTORY_VIEW_CLASS (class)->merge_menus = real_merge_menus;
FM_DIRECTORY_VIEW_CLASS (class)->update_menus = real_update_menus;
@@ -329,6 +312,8 @@ fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class)
FM_ICON_VIEW_CLASS (class)->supports_scaling = real_supports_scaling;
FM_ICON_VIEW_CLASS (class)->supports_keep_aligned = real_supports_keep_aligned;
FM_ICON_VIEW_CLASS (class)->supports_labels_beside_icons = real_supports_labels_beside_icons;
+
+ g_type_class_add_private (class, sizeof (FMDesktopIconViewDetails));
}
static void
@@ -352,7 +337,7 @@ fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container,
/* build an X event to represent the middle click. */
x_event.type = ButtonPress;
x_event.send_event = True;
- x_event.display = GDK_DISPLAY ();
+ x_event.display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
x_event.window = GDK_ROOT_WINDOW ();
x_event.root = GDK_ROOT_WINDOW ();
x_event.subwindow = 0;
@@ -366,7 +351,7 @@ fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container,
x_event.same_screen = True;
/* Send it to the root window, the window manager will handle it. */
- XSendEvent (GDK_DISPLAY (), GDK_ROOT_WINDOW (), True,
+ XSendEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_ROOT_WINDOW (), True,
ButtonPressMask, (XEvent *) &x_event);
}
@@ -481,7 +466,8 @@ do_desktop_rescan (gpointer data)
}
static void
-done_loading (GtkObject *DirectoryView, FMDesktopIconView *desktop_icon_view)
+done_loading (CajaDirectory *model,
+ FMDesktopIconView *desktop_icon_view)
{
struct stat buf;
@@ -547,6 +533,10 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
GtkAllocation allocation;
GtkAdjustment *hadj, *vadj;
+ desktop_icon_view->details = G_TYPE_INSTANCE_GET_PRIVATE (desktop_icon_view,
+ FM_TYPE_DESKTOP_ICON_VIEW,
+ FMDesktopIconViewDetails);
+
if (desktop_directory == NULL)
{
g_signal_connect_swapped (caja_preferences, "changed::" CAJA_PREFERENCES_DESKTOP_IS_HOME_DIR,
@@ -560,9 +550,6 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
caja_icon_container_set_use_drop_shadows (icon_container, TRUE);
fm_icon_container_set_sort_desktop (FM_ICON_CONTAINER (icon_container), TRUE);
- /* Set up details */
- desktop_icon_view->details = g_new0 (FMDesktopIconViewDetails, 1);
-
/* Do a reload on the desktop if we don't have FAM, a smarter
* way to keep track of the items on the desktop.
*/
@@ -585,8 +572,8 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
gtk_widget_queue_resize (GTK_WIDGET (icon_container));
- hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (icon_container));
- vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (icon_container));
+ hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (icon_container));
+ vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (icon_container));
eel_gtk_adjustment_set_value (hadj, 0);
eel_gtk_adjustment_set_value (vadj, 0);
@@ -716,7 +703,7 @@ real_update_menus (FMDirectoryView *view)
g_assert (FM_IS_DESKTOP_ICON_VIEW (view));
- EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, update_menus, (view));
+ FM_DIRECTORY_VIEW_CLASS (fm_desktop_icon_view_parent_class)->update_menus (view);
desktop_view = FM_DESKTOP_ICON_VIEW (view);
@@ -782,7 +769,7 @@ real_merge_menus (FMDirectoryView *view)
GtkActionGroup *action_group;
const char *ui;
- EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, merge_menus, (view));
+ FM_DIRECTORY_VIEW_CLASS (fm_desktop_icon_view_parent_class)->merge_menus (view);
desktop_view = FM_DESKTOP_ICON_VIEW (view);
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 55b1e5bb..c40a40ba 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -35,6 +35,7 @@
#include "fm-actions.h"
#include "fm-error-reporting.h"
+#include "fm-marshal.h"
#include "fm-properties-window.h"
#include "libcaja-private/caja-open-with-dialog.h"
@@ -46,7 +47,6 @@
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
-#include <eel/eel-marshal.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -71,7 +71,6 @@
#include <libcaja-private/caja-file-private.h> /* for caja_file_get_existing_by_uri */
#include <libcaja-private/caja-global-preferences.h>
#include <libcaja-private/caja-link.h>
-#include <libcaja-private/caja-marshal.h>
#include <libcaja-private/caja-metadata.h>
#include <libcaja-private/caja-mime-actions.h>
#include <libcaja-private/caja-module.h>
@@ -660,7 +659,7 @@ fm_directory_view_confirm_multiple (GtkWindow *parent_window,
g_free (detail);
response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
return response == GTK_RESPONSE_YES;
}
@@ -1026,7 +1025,8 @@ delete_selected_files (FMDirectoryView *view)
caja_file_operations_delete (locations, fm_directory_view_get_containing_window (view), NULL, NULL);
- eel_g_object_list_free (locations);
+ g_list_foreach(locations, (GFunc) g_object_unref, NULL);
+ g_list_free(locations);
caja_file_list_free (selection);
}
@@ -1204,7 +1204,6 @@ select_pattern (FMDirectoryView *view)
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_OK);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
@@ -1334,7 +1333,7 @@ action_save_search_as_callback (GtkAction *action,
dialog = gtk_dialog_new_with_buttons (_("Save Search as"),
fm_directory_view_get_containing_window (directory_view),
- GTK_DIALOG_NO_SEPARATOR,
+ 0,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
save_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
@@ -1936,7 +1935,8 @@ fm_directory_view_set_selection_locations (CajaView *caja_view,
/* If we are still loading, set the list of pending URIs instead.
* done_loading() will eventually select the pending URIs and reveal them.
*/
- eel_g_object_list_free (view->details->pending_locations_selected);
+ g_list_foreach(view->details->pending_locations_selected, (GFunc) g_object_unref, NULL);
+ g_list_free(view->details->pending_locations_selected);
view->details->pending_locations_selected =
eel_g_object_list_copy (selection_locations);
}
@@ -2098,7 +2098,11 @@ real_unmerge_menus (FMDirectoryView *view)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+fm_directory_view_destroy (GtkWidget *object)
+#else
fm_directory_view_destroy (GtkObject *object)
+#endif
{
FMDirectoryView *view;
GList *node, *next;
@@ -2159,7 +2163,11 @@ fm_directory_view_destroy (GtkObject *object)
view->details->directory_as_file = NULL;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ EEL_CALL_PARENT (GTK_WIDGET_CLASS, destroy, (object));
+#else
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+#endif
}
static void
@@ -2170,17 +2178,17 @@ fm_directory_view_finalize (GObject *object)
view = FM_DIRECTORY_VIEW (object);
g_signal_handlers_disconnect_by_func (caja_preferences,
- schedule_update_menus_callback, view);
+ schedule_update_menus_callback, view);
g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
- text_attribute_names_changed_callback, view);
+ text_attribute_names_changed_callback, view);
g_signal_handlers_disconnect_by_func (caja_preferences,
- image_display_policy_changed_callback, view);
+ image_display_policy_changed_callback, view);
g_signal_handlers_disconnect_by_func (caja_preferences,
- click_policy_changed_callback, view);
+ click_policy_changed_callback, view);
g_signal_handlers_disconnect_by_func (caja_preferences,
- sort_directories_first_changed_callback, view);
+ sort_directories_first_changed_callback, view);
g_signal_handlers_disconnect_by_func (mate_lockdown_preferences,
- schedule_update_menus, view);
+ schedule_update_menus, view);
unschedule_pop_up_location_context_menu (view);
if (view->details->location_popup_event != NULL) {
@@ -2542,7 +2550,8 @@ done_loading (FMDirectoryView *view,
fm_directory_view_reveal_selection (view);
}
}
- eel_g_object_list_free (locations_selected);
+ g_list_foreach(locations_selected, (GFunc) g_object_unref, NULL);
+ g_list_free(locations_selected);
fm_directory_view_display_selection_info (view);
}
@@ -2740,7 +2749,7 @@ copy_move_done_callback (GHashTable *debuting_files, gpointer data)
* operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we
* must use connect_after.
*/
- g_signal_connect_data (GTK_OBJECT (directory_view),
+ g_signal_connect_data (directory_view,
"add_file",
G_CALLBACK (debuting_files_add_file_callback),
debuting_files_data,
@@ -3784,7 +3793,8 @@ fm_directory_view_create_links_for_files (FMDirectoryView *view, GList *files,
caja_file_operations_copy_move (uris, relative_item_points, dir_uri, GDK_ACTION_LINK,
GTK_WIDGET (view), copy_move_done_callback, copy_move_done_data);
g_free (dir_uri);
- eel_g_list_free_deep (uris);
+ g_list_foreach(uris, (GFunc) g_free, NULL);
+ g_list_free(uris);
}
static void
@@ -3816,7 +3826,8 @@ fm_directory_view_duplicate_selection (FMDirectoryView *view, GList *files,
copy_move_done_data = pre_copy_move (view);
caja_file_operations_copy_move (uris, relative_item_points, NULL, GDK_ACTION_COPY,
GTK_WIDGET (view), copy_move_done_callback, copy_move_done_data);
- eel_g_list_free_deep (uris);
+ g_list_foreach(uris, (GFunc) g_free, NULL);
+ g_list_free(uris);
}
/* special_link_in_selection
@@ -3920,7 +3931,8 @@ trash_or_delete_files (GtkWindow *parent_window,
parent_window,
(CajaDeleteCallback) trash_or_delete_done_cb,
view);
- eel_g_object_list_free (locations);
+ g_list_foreach(locations, (GFunc) g_object_unref, NULL);
+ g_list_free(locations);
}
static gboolean
@@ -4669,7 +4681,8 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection)
index,
menu_path, popup_path, submenu_visible);
}
- eel_g_object_list_free (applications);
+ g_list_foreach(applications, (GFunc) g_object_unref, NULL);
+ g_list_free(applications);
if (default_app != NULL) {
g_object_unref (default_app);
}
@@ -5964,7 +5977,8 @@ move_copy_selection_to_location (FMDirectoryView *view,
0, 0,
view);
- eel_g_list_free_deep (uris);
+ g_list_foreach(uris, (GFunc) g_free, NULL);
+ g_list_free(uris);
caja_file_list_free (selection);
}
@@ -6104,7 +6118,10 @@ paste_clipboard_data (FMDirectoryView *view,
gtk_clipboard_clear (caja_clipboard_get (GTK_WIDGET (view)));
}
- eel_g_list_free_deep (item_uris);
+ g_list_foreach(item_uris, (GFunc) g_free, NULL);
+ g_list_free(item_uris);
+ g_list_foreach(item_uris, (GFunc) g_free, NULL);
+ g_list_free(item_uris);
}
}
@@ -6901,7 +6918,7 @@ action_connect_to_server_link_callback (GtkAction *action,
title = g_strdup_printf (_("Connect to Server %s"), name);
dialog = gtk_dialog_new_with_buttons (title,
fm_directory_view_get_containing_window (view),
- GTK_DIALOG_NO_SEPARATOR,
+ 0,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Connect"), GTK_RESPONSE_OK,
NULL);
@@ -7098,7 +7115,8 @@ action_location_delete_callback (GtkAction *action,
caja_file_operations_delete (files, fm_directory_view_get_containing_window (view),
NULL, NULL);
- eel_g_object_list_free (files);
+ g_list_foreach(files, (GFunc) g_object_unref, NULL);
+ g_list_free(files);
}
static void
@@ -9781,7 +9799,8 @@ fm_directory_view_stop (FMDirectoryView *view)
view->details->old_added_files = NULL;
file_and_directory_list_free (view->details->old_changed_files);
view->details->old_changed_files = NULL;
- eel_g_object_list_free (view->details->pending_locations_selected);
+ g_list_foreach(view->details->pending_locations_selected, (GFunc) g_object_unref, NULL);
+ g_list_free(view->details->pending_locations_selected);
view->details->pending_locations_selected = NULL;
if (view->details->model != NULL) {
@@ -10559,7 +10578,8 @@ fm_directory_view_handle_uri_list_drop (FMDirectoryView *view,
target_uri != NULL ? target_uri : container_uri,
action, x, y, view);
- eel_g_list_free_deep (real_uri_list);
+ g_list_foreach(real_uri_list, (GFunc) g_free, NULL);
+ g_list_free(real_uri_list);
if (points != NULL)
g_array_free (points, TRUE);
@@ -10796,11 +10816,13 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
widget_class = GTK_WIDGET_CLASS (klass);
scrolled_window_class = GTK_SCROLLED_WINDOW_CLASS (klass);
- G_OBJECT_CLASS (klass)->finalize = fm_directory_view_finalize;
G_OBJECT_CLASS (klass)->set_property = fm_directory_view_set_property;
-
+ G_OBJECT_CLASS (klass)->finalize = fm_directory_view_finalize;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GTK_OBJECT_CLASS (klass)->destroy = fm_directory_view_destroy;
-
+#else
+ widget_class->destroy = fm_directory_view_destroy;
+#endif
widget_class->scroll_event = fm_directory_view_scroll_event;
widget_class->parent_set = fm_directory_view_parent_set;
@@ -10815,7 +10837,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FMDirectoryViewClass, add_file),
NULL, NULL,
- caja_marshal_VOID__OBJECT_OBJECT,
+ fm_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2, CAJA_TYPE_FILE, CAJA_TYPE_DIRECTORY);
signals[BEGIN_FILE_CHANGES] =
g_signal_new ("begin_file_changes",
@@ -10871,7 +10893,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FMDirectoryViewClass, file_changed),
NULL, NULL,
- caja_marshal_VOID__OBJECT_OBJECT,
+ fm_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2, CAJA_TYPE_FILE, CAJA_TYPE_DIRECTORY);
signals[LOAD_ERROR] =
g_signal_new ("load_error",
@@ -10887,7 +10909,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FMDirectoryViewClass, remove_file),
NULL, NULL,
- caja_marshal_VOID__OBJECT_OBJECT,
+ fm_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2, CAJA_TYPE_FILE, CAJA_TYPE_DIRECTORY);
klass->accepts_dragged_files = real_accepts_dragged_files;
@@ -10944,7 +10966,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (FMDirectoryViewClass, trash),
g_signal_accumulator_true_handled, NULL,
- eel_marshal_BOOLEAN__VOID,
+ fm_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
signals[DELETE] =
g_signal_new ("delete",
@@ -10952,15 +10974,15 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (FMDirectoryViewClass, delete),
g_signal_accumulator_true_handled, NULL,
- eel_marshal_BOOLEAN__VOID,
+ fm_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
binding_set = gtk_binding_set_by_class (klass);
- gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0,
"trash", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0,
"trash", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_SHIFT_MASK,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
"delete", 0);
klass->trash = real_trash;
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index eee45185..931df9f8 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -209,7 +209,11 @@ G_DEFINE_TYPE_WITH_CODE (FMIconView, fm_icon_view, FM_TYPE_DIRECTORY_VIEW,
fm_icon_view_iface_init));
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+fm_icon_view_destroy (GtkWidget *object)
+#else
fm_icon_view_destroy (GtkObject *object)
+#endif
{
FMIconView *icon_view;
@@ -237,10 +241,13 @@ fm_icon_view_destroy (GtkObject *object)
icon_view->details->icons_not_positioned = NULL;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (fm_icon_view_parent_class)->destroy (object);
+#else
GTK_OBJECT_CLASS (fm_icon_view_parent_class)->destroy (object);
+#endif
}
-
static void
fm_icon_view_finalize (GObject *object)
{
@@ -271,6 +278,7 @@ fm_icon_view_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (caja_compact_view_preferences,
all_columns_same_width_changed_callback,
icon_view);
+
G_OBJECT_CLASS (fm_icon_view_parent_class)->finalize (object);
}
@@ -2184,6 +2192,8 @@ play_file (gpointer callback_data)
char **argv;
GError *error;
char *uri;
+ GFile *gfile;
+ char *path;
icon_view = FM_ICON_VIEW (callback_data);
@@ -2191,7 +2201,21 @@ play_file (gpointer callback_data)
icon_view->details->audio_preview_timeout = 0;
file = icon_view->details->audio_preview_file;
- uri = caja_file_get_uri (file);
+ gfile = caja_file_get_location (file);
+ path = g_file_get_path (gfile);
+
+ /* if we have a local path, use that instead of the native URI.
+ * this can be useful for special GVfs mounts, such as cdda://
+ */
+ if (path) {
+ uri = g_filename_to_uri (path, NULL, NULL);
+ } else {
+ uri = caja_file_get_uri (file);
+ }
+
+ g_object_unref (gfile);
+ g_free (path);
+
argv = get_preview_argv (uri);
g_free (uri);
if (argv == NULL)
@@ -2829,8 +2853,6 @@ fm_icon_view_sort_directories_first_changed (FMDirectoryView *directory_view)
}
}
-/* GtkObject methods. */
-
static gboolean
icon_view_can_accept_item (CajaIconContainer *container,
CajaFile *target_item,
@@ -3145,9 +3167,11 @@ fm_icon_view_class_init (FMIconViewClass *klass)
G_OBJECT_CLASS (klass)->set_property = fm_icon_view_set_property;
G_OBJECT_CLASS (klass)->finalize = fm_icon_view_finalize;
-
+#if !GTK_CHECK_VERSION (3, 0, 0)
GTK_OBJECT_CLASS (klass)->destroy = fm_icon_view_destroy;
-
+#else
+ GTK_WIDGET_CLASS (klass)->destroy = fm_icon_view_destroy;
+#endif
GTK_WIDGET_CLASS (klass)->screen_changed = fm_icon_view_screen_changed;
GTK_WIDGET_CLASS (klass)->scroll_event = fm_icon_view_scroll_event;
diff --git a/src/file-manager/fm-list-model.c b/src/file-manager/fm-list-model.c
index f7288fe2..f6ba0168 100644
--- a/src/file-manager/fm-list-model.c
+++ b/src/file-manager/fm-list-model.c
@@ -29,8 +29,6 @@
#include <libegg/eggtreemultidnd.h>
#include <string.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -166,13 +164,6 @@ fm_list_model_get_column_type (GtkTreeModel *tree_model, int index)
case FM_LIST_MODEL_LARGE_ICON_COLUMN:
case FM_LIST_MODEL_LARGER_ICON_COLUMN:
case FM_LIST_MODEL_LARGEST_ICON_COLUMN:
- case FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN:
- case FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN:
- case FM_LIST_MODEL_SMALL_EMBLEM_COLUMN:
- case FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN:
- case FM_LIST_MODEL_LARGE_EMBLEM_COLUMN:
- case FM_LIST_MODEL_LARGER_EMBLEM_COLUMN:
- case FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN:
return GDK_TYPE_PIXBUF;
case FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN:
return G_TYPE_BOOLEAN;
@@ -277,10 +268,12 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
CajaFile *file;
char *str;
GdkPixbuf *icon, *rendered_icon;
+ GIcon *gicon, *emblemed_icon, *emblem_icon;
+ CajaIconInfo *icon_info;
+ GEmblem *emblem;
+ GList *emblem_icons, *l;
int icon_size;
- guint emblem_size;
CajaZoomLevel zoom_level;
- GList *emblem_pixbufs;
CajaFile *parent_file;
char *emblems_to_ignore[3];
int i;
@@ -344,7 +337,52 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
}
}
- icon = caja_file_get_icon_pixbuf (file, icon_size, TRUE, flags);
+ gicon = caja_file_get_gicon (file, flags);
+
+ /* render emblems with GEmblemedIcon */
+ parent_file = caja_file_get_parent (file);
+ i = 0;
+ emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH;
+ if (parent_file) {
+ if (!caja_file_can_write (parent_file)) {
+ emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE;
+ }
+ caja_file_unref (parent_file);
+ }
+ emblems_to_ignore[i++] = NULL;
+
+ emblem = NULL;
+ emblem_icons = caja_file_get_emblem_icons (file,
+ emblems_to_ignore);
+
+ if (emblem_icons != NULL) {
+ emblem_icon = emblem_icons->data;
+ emblem = g_emblem_new (emblem_icon);
+ emblemed_icon = g_emblemed_icon_new (gicon, emblem);
+
+ g_object_unref (emblem);
+
+ for (l = emblem_icons->next; l != NULL; l = l->next) {
+ emblem_icon = l->data;
+ emblem = g_emblem_new (emblem_icon);
+ g_emblemed_icon_add_emblem
+ (G_EMBLEMED_ICON (emblemed_icon), emblem);
+
+ g_object_unref (emblem);
+ }
+
+ g_list_foreach (emblem_icons, (GFunc) g_object_unref, NULL);
+ g_list_free(emblem_icons);
+
+ g_object_unref (gicon);
+ gicon = emblemed_icon;
+ }
+
+ icon_info = caja_icon_info_lookup (gicon, icon_size);
+ icon = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size);
+
+ g_object_unref (icon_info);
+ g_object_unref (gicon);
if (model->details->highlight_files != NULL &&
g_list_find_custom (model->details->highlight_files,
@@ -363,48 +401,6 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
g_object_unref (icon);
}
break;
- case FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN:
- case FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN:
- case FM_LIST_MODEL_SMALL_EMBLEM_COLUMN:
- case FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN:
- case FM_LIST_MODEL_LARGE_EMBLEM_COLUMN:
- case FM_LIST_MODEL_LARGER_EMBLEM_COLUMN:
- case FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
-
- if (file != NULL)
- {
- parent_file = caja_file_get_parent (file);
- i = 0;
- emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH;
- if (parent_file)
- {
- if (!caja_file_can_write (parent_file))
- {
- emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE;
- }
- caja_file_unref (parent_file);
- }
- emblems_to_ignore[i++] = NULL;
-
- zoom_level = fm_list_model_get_zoom_level_from_emblem_column_id (column);
- icon_size = caja_get_icon_size_for_zoom_level (zoom_level);
- emblem_size = caja_icon_get_emblem_size_for_icon_size (icon_size);
- if (emblem_size != 0)
- {
- emblem_pixbufs = caja_file_get_emblem_pixbufs (file,
- emblem_size,
- TRUE,
- emblems_to_ignore);
- if (emblem_pixbufs != NULL)
- {
- icon = emblem_pixbufs->data;
- g_value_set_object (value, icon);
- }
- eel_gdk_pixbuf_list_free (emblem_pixbufs);
- }
- }
- break;
case FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN:
g_value_init (value, G_TYPE_BOOLEAN);
@@ -682,7 +678,8 @@ fm_list_model_get_first_iter_for_file (FMListModel *model,
res = TRUE;
*iter = *(GtkTreeIter *)list->data;
}
- eel_g_list_free_deep (list);
+ g_list_foreach(list, (GFunc) g_free, NULL);
+ g_list_free(list);
return res;
}
@@ -1555,54 +1552,6 @@ fm_list_model_get_column_id_from_zoom_level (CajaZoomLevel zoom_level)
g_return_val_if_reached (FM_LIST_MODEL_STANDARD_ICON_COLUMN);
}
-CajaZoomLevel
-fm_list_model_get_zoom_level_from_emblem_column_id (int column)
-{
- switch (column)
- {
- case FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN:
- return CAJA_ZOOM_LEVEL_SMALLEST;
- case FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN:
- return CAJA_ZOOM_LEVEL_SMALLER;
- case FM_LIST_MODEL_SMALL_EMBLEM_COLUMN:
- return CAJA_ZOOM_LEVEL_SMALL;
- case FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN:
- return CAJA_ZOOM_LEVEL_STANDARD;
- case FM_LIST_MODEL_LARGE_EMBLEM_COLUMN:
- return CAJA_ZOOM_LEVEL_LARGE;
- case FM_LIST_MODEL_LARGER_EMBLEM_COLUMN:
- return CAJA_ZOOM_LEVEL_LARGER;
- case FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN:
- return CAJA_ZOOM_LEVEL_LARGEST;
- }
-
- g_return_val_if_reached (CAJA_ZOOM_LEVEL_STANDARD);
-}
-
-int
-fm_list_model_get_emblem_column_id_from_zoom_level (CajaZoomLevel zoom_level)
-{
- switch (zoom_level)
- {
- case CAJA_ZOOM_LEVEL_SMALLEST:
- return FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN;
- case CAJA_ZOOM_LEVEL_SMALLER:
- return FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN;
- case CAJA_ZOOM_LEVEL_SMALL:
- return FM_LIST_MODEL_SMALL_EMBLEM_COLUMN;
- case CAJA_ZOOM_LEVEL_STANDARD:
- return FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN;
- case CAJA_ZOOM_LEVEL_LARGE:
- return FM_LIST_MODEL_LARGE_EMBLEM_COLUMN;
- case CAJA_ZOOM_LEVEL_LARGER:
- return FM_LIST_MODEL_LARGER_EMBLEM_COLUMN;
- case CAJA_ZOOM_LEVEL_LARGEST:
- return FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN;
- }
-
- g_return_val_if_reached (FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN);
-}
-
void
fm_list_model_set_drag_view (FMListModel *model,
GtkTreeView *view,
@@ -1857,7 +1806,8 @@ refresh_row (gpointer data,
gtk_tree_path_free (path);
}
- eel_g_list_free_deep (iters);
+ g_list_foreach(iters, (GFunc) g_free, NULL);
+ g_list_free(iters);
}
void
diff --git a/src/file-manager/fm-list-model.h b/src/file-manager/fm-list-model.h
index a44fb28a..2d4ff88b 100644
--- a/src/file-manager/fm-list-model.h
+++ b/src/file-manager/fm-list-model.h
@@ -54,13 +54,6 @@ enum
FM_LIST_MODEL_LARGE_ICON_COLUMN,
FM_LIST_MODEL_LARGER_ICON_COLUMN,
FM_LIST_MODEL_LARGEST_ICON_COLUMN,
- FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN,
- FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN,
- FM_LIST_MODEL_SMALL_EMBLEM_COLUMN,
- FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN,
- FM_LIST_MODEL_LARGE_EMBLEM_COLUMN,
- FM_LIST_MODEL_LARGER_EMBLEM_COLUMN,
- FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN,
FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN,
FM_LIST_MODEL_NUM_COLUMNS
};
@@ -115,8 +108,6 @@ void fm_list_model_sort_files (FMListModel *model,
CajaZoomLevel fm_list_model_get_zoom_level_from_column_id (int column);
int fm_list_model_get_column_id_from_zoom_level (CajaZoomLevel zoom_level);
-CajaZoomLevel fm_list_model_get_zoom_level_from_emblem_column_id (int column);
-int fm_list_model_get_emblem_column_id_from_zoom_level (CajaZoomLevel zoom_level);
CajaFile * fm_list_model_file_for_path (FMListModel *model, GtkTreePath *path);
gboolean fm_list_model_load_subdirectory (FMListModel *model, GtkTreePath *path, CajaDirectory **directory);
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index e8eb16a8..f487c333 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -59,7 +59,6 @@
#include <libcaja-private/caja-tree-view-drag-dest.h>
#include <libcaja-private/caja-view-factory.h>
#include <libcaja-private/caja-clipboard.h>
-#include <libcaja-private/caja-cell-renderer-pixbuf-emblem.h>
#include <libcaja-private/caja-cell-renderer-text-ellipsized.h>
struct FMListViewDetails
@@ -1109,14 +1108,14 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
switch (event->keyval)
{
- case GDK_F10:
+ case GDK_KEY_F10:
if (event->state & GDK_CONTROL_MASK)
{
fm_directory_view_pop_up_background_context_menu (view, &button_event);
handled = TRUE;
}
break;
- case GDK_Right:
+ case GDK_KEY_Right:
gtk_tree_view_get_cursor (tree_view, &path, NULL);
if (path)
{
@@ -1125,7 +1124,7 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
}
handled = TRUE;
break;
- case GDK_Left:
+ case GDK_KEY_Left:
gtk_tree_view_get_cursor (tree_view, &path, NULL);
if (path)
{
@@ -1134,7 +1133,7 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
}
handled = TRUE;
break;
- case GDK_space:
+ case GDK_KEY_space:
if (event->state & GDK_CONTROL_MASK)
{
handled = FALSE;
@@ -1155,8 +1154,8 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
}
handled = TRUE;
break;
- case GDK_Return:
- case GDK_KP_Enter:
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter:
if ((event->state & GDK_SHIFT_MASK) != 0)
{
activate_selected_items_alternate (FM_LIST_VIEW (view), NULL, TRUE);
@@ -1167,7 +1166,7 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
}
handled = TRUE;
break;
- case GDK_v:
+ case GDK_KEY_v:
/* Eat Control + v to not enable type ahead */
if ((event->state & GDK_CONTROL_MASK) != 0)
{
@@ -1642,7 +1641,7 @@ create_and_set_up_tree_view (FMListView *view)
/* Don't handle backspace key. It's used to open the parent folder. */
binding_set = gtk_binding_set_by_class (GTK_WIDGET_GET_CLASS (view->details->tree_view));
- gtk_binding_entry_remove (binding_set, GDK_BackSpace, 0);
+ gtk_binding_entry_remove (binding_set, GDK_KEY_BackSpace, 0);
view->details->drag_dest =
caja_tree_view_drag_dest_new (view->details->tree_view);
@@ -1740,7 +1739,7 @@ create_and_set_up_tree_view (FMListView *view)
if (!strcmp (name, "name"))
{
/* Create the file name column */
- cell = caja_cell_renderer_pixbuf_emblem_new ();
+ cell = gtk_cell_renderer_pixbuf_new ();
view->details->pixbuf_cell = (GtkCellRendererPixbuf *)cell;
view->details->file_name_column = gtk_tree_view_column_new ();
@@ -1764,7 +1763,6 @@ create_and_set_up_tree_view (FMListView *view)
gtk_tree_view_column_set_attributes (view->details->file_name_column,
cell,
"pixbuf", FM_LIST_MODEL_SMALLEST_ICON_COLUMN,
- "pixbuf_emblem", FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN,
NULL);
cell = gtk_cell_renderer_text_new ();
@@ -2327,7 +2325,8 @@ fm_list_view_set_selection (FMDirectoryView *view, GList *selection)
gtk_tree_selection_select_iter (tree_selection,
(GtkTreeIter *)l->data);
}
- eel_g_list_free_deep (iters);
+ g_list_foreach(iters, (GFunc) g_free, NULL);
+ g_list_free(iters);
}
g_signal_handlers_unblock_by_func (tree_selection, list_selection_changed_callback, view);
@@ -2364,7 +2363,8 @@ fm_list_view_invert_selection (FMDirectoryView *view)
gtk_tree_selection_unselect_iter (tree_selection,
(GtkTreeIter *)l->data);
}
- eel_g_list_free_deep (iters);
+ g_list_foreach(iters, (GFunc) g_free, NULL);
+ g_list_free(iters);
}
g_list_free (selection);
@@ -2734,7 +2734,7 @@ fm_list_view_set_zoom_level (FMListView *view,
gboolean always_emit)
{
int icon_size;
- int column, emblem_column;
+ int column;
g_return_if_fail (FM_IS_LIST_VIEW (view));
g_return_if_fail (new_level >= CAJA_ZOOM_LEVEL_SMALLEST &&
@@ -2760,11 +2760,9 @@ fm_list_view_set_zoom_level (FMListView *view,
/* Select correctly scaled icons. */
column = fm_list_model_get_column_id_from_zoom_level (new_level);
- emblem_column = fm_list_model_get_emblem_column_id_from_zoom_level (new_level);
gtk_tree_view_column_set_attributes (view->details->file_name_column,
GTK_CELL_RENDERER (view->details->pixbuf_cell),
"pixbuf", column,
- "pixbuf_emblem", emblem_column,
NULL);
/* Scale text. */
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c
index 7ec253c0..4a7b7c54 100644
--- a/src/file-manager/fm-properties-window.c
+++ b/src/file-manager/fm-properties-window.c
@@ -37,7 +37,6 @@
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-labeled-image.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <eel/eel-wrap-table.h>
#include <gtk/gtk.h>
@@ -45,7 +44,6 @@
#include <glib/gi18n.h>
#include <libmateui/mate-desktop-thumbnail.h>
#include <libcaja-extension/caja-property-page-provider.h>
-#include <libcaja-private/caja-customization-data.h>
#include <libcaja-private/caja-entry.h>
#include <libcaja-private/caja-file-attributes.h>
#include <libcaja-private/caja-file-operations.h>
@@ -701,7 +699,7 @@ update_name_field (FMPropertiesWindow *window)
set_name_field (window, original_name, current_name);
if (original_name == NULL ||
- eel_strcmp (original_name, current_name) != 0) {
+ g_strcmp0 (original_name, current_name) != 0) {
g_object_set_data_full (G_OBJECT (window->details->name_field),
"original_name",
current_name,
@@ -843,7 +841,8 @@ file_has_keyword (CajaFile *file, const char *keyword)
keywords = caja_file_get_keywords (file);
word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp);
- eel_g_list_free_deep (keywords);
+ g_list_foreach(keywords, (GFunc) g_free, NULL);
+ g_list_free(keywords);
return (word != NULL);
}
@@ -933,7 +932,8 @@ emblem_button_toggled (GtkToggleButton *button,
keywords = g_list_prepend (keywords, g_strdup (name));
}
caja_file_set_keywords (file, keywords);
- eel_g_list_free_deep (keywords);
+ g_list_foreach(keywords, (GFunc) g_free, NULL);
+ g_list_free(keywords);
}
for (l = files_off; l != NULL; l = l->next) {
@@ -946,10 +946,12 @@ emblem_button_toggled (GtkToggleButton *button,
word = g_list_find_custom (keywords, name, (GCompareFunc)strcmp);
if (word) {
keywords = g_list_remove_link (keywords, word);
- eel_g_list_free_deep (word);
+ g_list_foreach(word, (GFunc) g_free, NULL);
+ g_list_free(word);
}
caja_file_set_keywords (file, keywords);
- eel_g_list_free_deep (keywords);
+ g_list_foreach(keywords, (GFunc) g_free, NULL);
+ g_list_free(keywords);
}
g_list_free (files_on);
@@ -1205,7 +1207,8 @@ properties_window_update (FMPropertiesWindow *window,
refresh_extension_pages (window);
}
- eel_g_list_free_deep (window->details->mime_list);
+ g_list_foreach(window->details->mime_list, (GFunc) g_free, NULL);
+ g_list_free(window->details->mime_list);
window->details->mime_list = mime_list;
}
}
@@ -1636,7 +1639,7 @@ changed_group_callback (GtkComboBox *combo_box, CajaFile *file)
g_assert (GTK_IS_COMBO_BOX (combo_box));
g_assert (CAJA_IS_FILE (file));
- group = gtk_combo_box_get_active_text (combo_box);
+ group = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo_box));
cur_group = caja_file_get_group_name (file);
if (group != NULL && strcmp (group, cur_group) != 0) {
@@ -1791,7 +1794,7 @@ synch_groups_combo_box (GtkComboBox *combo_box, CajaFile *file)
for (node = groups, group_index = 0; node != NULL; node = node->next, ++group_index) {
group_name = (const char *)node->data;
- gtk_combo_box_append_text (combo_box, group_name);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), group_name);
}
}
@@ -1805,16 +1808,17 @@ synch_groups_combo_box (GtkComboBox *combo_box, CajaFile *file)
if (current_group_index < 0 && current_group_name != NULL) {
if (groups != NULL) {
/* add separator */
- gtk_combo_box_prepend_text (combo_box, "-");
+ gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (combo_box), "-");
}
- gtk_combo_box_prepend_text (combo_box, current_group_name);
+ gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (combo_box), current_group_name);
current_group_index = 0;
}
gtk_combo_box_set_active (combo_box, current_group_index);
g_free (current_group_name);
- eel_g_list_free_deep (groups);
+ g_list_foreach(groups, (GFunc) g_free, NULL);
+ g_list_free(groups);
}
static gboolean
@@ -1850,7 +1854,7 @@ attach_combo_box (GtkTable *table,
GtkWidget *aligner;
if (!two_columns) {
- combo_box = gtk_combo_box_new_text ();
+ combo_box = gtk_combo_box_text_new ();
} else {
GtkTreeModel *model;
GtkCellRenderer *renderer;
@@ -2169,7 +2173,8 @@ synch_user_menu (GtkComboBox *combo_box, CajaFile *file)
gtk_combo_box_set_active (combo_box, owner_index);
g_free (owner_name);
- eel_g_list_free_deep (users);
+ g_list_foreach(users, (GFunc) g_free, NULL);
+ g_list_free(users);
}
static GtkComboBox*
@@ -2744,10 +2749,15 @@ should_show_volume_usage (FMPropertiesWindow *window)
}
static void
-paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
+paint_used_legend (GtkWidget *widget,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
+ GdkEventExpose *eev,
+#endif
+ gpointer data)
{
FMPropertiesWindow *window;
- cairo_t *cr;
gint width, height;
GtkAllocation allocation;
@@ -2758,7 +2768,9 @@ paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
window = FM_PROPERTIES_WINDOW (data);
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#if !GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#endif
cairo_rectangle (cr,
2,
@@ -2766,20 +2778,32 @@ paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
width - 4,
height - 4);
- cairo_set_source_rgb (cr, (double) window->details->used_color.red / 65535, (double) window->details->used_color.green / 65535, (double) window->details->used_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->used_color.red / 65535,
+ (double) window->details->used_color.green / 65535,
+ (double) window->details->used_color.blue / 65535);
cairo_fill_preserve (cr);
- cairo_set_source_rgb (cr, (double) window->details->used_stroke_color.red / 65535, (double) window->details->used_stroke_color.green / 65535, (double) window->details->used_stroke_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->used_stroke_color.red / 65535,
+ (double) window->details->used_stroke_color.green / 65535,
+ (double) window->details->used_stroke_color.blue / 65535);
cairo_stroke (cr);
+#if !GTK_CHECK_VERSION(3,0,0)
cairo_destroy (cr);
+#endif
}
static void
-paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
+paint_free_legend (GtkWidget *widget,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr, gpointer data)
+#else
+ GdkEventExpose *eev, gpointer data)
+#endif
{
FMPropertiesWindow *window;
- cairo_t *cr;
gint width, height;
GtkAllocation allocation;
@@ -2788,7 +2812,9 @@ paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
width = allocation.width;
height = allocation.height;
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#if !GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#endif
cairo_rectangle (cr,
2,
@@ -2796,21 +2822,34 @@ paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
width - 4,
height - 4);
- cairo_set_source_rgb (cr, (double) window->details->free_color.red / 65535, (double) window->details->free_color.green / 65535, (double) window->details->free_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->free_color.red / 65535,
+ (double) window->details->free_color.green / 65535,
+ (double) window->details->free_color.blue / 65535);
cairo_fill_preserve(cr);
- cairo_set_source_rgb (cr, (double) window->details->free_stroke_color.red / 65535, (double) window->details->free_stroke_color.green / 65535, (double) window->details->free_stroke_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->free_stroke_color.red / 65535,
+ (double) window->details->free_stroke_color.green / 65535,
+ (double) window->details->free_stroke_color.blue / 65535);
cairo_stroke (cr);
+#if !GTK_CHECK_VERSION(3,0,0)
cairo_destroy (cr);
+#endif
}
static void
-paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
+paint_pie_chart (GtkWidget *widget,
+#if GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr,
+#else
+ GdkEventExpose *eev,
+#endif
+ gpointer data)
{
FMPropertiesWindow *window;
- cairo_t *cr;
gint width, height;
double free, used;
double angle1, angle2, split, xc, yc, radius;
@@ -2832,7 +2871,9 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
xc = width / 2;
yc = height / 2;
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#if !GTK_CHECK_VERSION(3,0,0)
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+#endif
if (width < height) {
radius = width / 2 - 8;
@@ -2859,10 +2900,16 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
cairo_line_to (cr,xc,yc);
}
- cairo_set_source_rgb (cr, (double) window->details->used_color.red / 65535, (double) window->details->used_color.green / 65535, (double) window->details->used_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->used_color.red / 65535,
+ (double) window->details->used_color.green / 65535,
+ (double) window->details->used_color.blue / 65535);
cairo_fill_preserve (cr);
- cairo_set_source_rgb (cr, (double) window->details->used_stroke_color.red / 65535, (double) window->details->used_stroke_color.green / 65535, (double) window->details->used_stroke_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->used_stroke_color.red / 65535,
+ (double) window->details->used_stroke_color.green / 65535,
+ (double) window->details->used_stroke_color.blue / 65535);
cairo_stroke (cr);
}
@@ -2877,14 +2924,22 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
cairo_line_to (cr,xc,yc);
}
- cairo_set_source_rgb (cr, (double) window->details->free_color.red / 65535, (double) window->details->free_color.green / 65535,(double) window->details->free_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->free_color.red / 65535,
+ (double) window->details->free_color.green / 65535,
+ (double) window->details->free_color.blue / 65535);
cairo_fill_preserve(cr);
- cairo_set_source_rgb (cr, (double) window->details->free_stroke_color.red / 65535, (double) window->details->free_stroke_color.green / 65535, (double) window->details->free_stroke_color.blue / 65535);
+ cairo_set_source_rgb (cr,
+ (double) window->details->free_stroke_color.red / 65535,
+ (double) window->details->free_stroke_color.green / 65535,
+ (double) window->details->free_stroke_color.blue / 65535);
cairo_stroke (cr);
}
+#if !GTK_CHECK_VERSION(3,0,0)
cairo_destroy (cr);
+#endif
}
@@ -3173,9 +3228,21 @@ create_pie_widget (FMPropertiesWindow *window)
gtk_table_attach (table, capacity_label , 1, 3, 2, 3, GTK_FILL, 0, 5, 5);
gtk_table_attach (table, fstype_label , 1, 3, 3, 4, GTK_FILL, 0, 5, 5);
- g_signal_connect (G_OBJECT (pie_canvas), "expose-event", G_CALLBACK (paint_pie_chart), window);
- g_signal_connect (G_OBJECT (used_canvas), "expose-event", G_CALLBACK (paint_used_legend), window);
- g_signal_connect (G_OBJECT (free_canvas), "expose-event", G_CALLBACK (paint_free_legend), window);
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect (pie_canvas, "draw",
+ G_CALLBACK (paint_pie_chart), window);
+ g_signal_connect (used_canvas, "draw",
+ G_CALLBACK (paint_used_legend), window);
+ g_signal_connect (free_canvas, "draw",
+ G_CALLBACK (paint_free_legend), window);
+#else
+ g_signal_connect (G_OBJECT (pie_canvas), "expose-event",
+ G_CALLBACK (paint_pie_chart), window);
+ g_signal_connect (G_OBJECT (used_canvas), "expose-event",
+ G_CALLBACK (paint_used_legend), window);
+ g_signal_connect (G_OBJECT (free_canvas), "expose-event",
+ G_CALLBACK (paint_free_legend), window);
+#endif
return GTK_WIDGET (table);
}
@@ -3363,7 +3430,7 @@ get_initial_emblems (GList *files)
ret = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
- (GDestroyNotify)eel_g_list_free_deep);
+ (GFunc) g_free);
for (l = files; l != NULL; l = l->next) {
CajaFile *file;
@@ -3502,7 +3569,8 @@ create_emblems_page (FMPropertiesWindow *window)
gtk_container_add (GTK_CONTAINER (emblems_table), button);
}
- eel_g_list_free_deep (icons);
+ g_list_foreach(icons, (GFunc) g_free, NULL);
+ g_list_free(icons);
gtk_widget_show_all (emblems_table);
}
@@ -4986,7 +5054,8 @@ get_pending_key (GList *file_list)
g_string_append (key, ";");
}
- eel_g_list_free_deep (uris);
+ g_list_foreach(uris, (GFunc) g_free, NULL);
+ g_list_free(uris);
ret = key->str;
g_string_free (key, FALSE);
@@ -5235,7 +5304,6 @@ create_properties_window (StartupData *startup_data)
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (window))), 12);
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (window))), 0);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), 12);
- gtk_dialog_set_has_separator (GTK_DIALOG (window), FALSE);
/* Update from initial state */
properties_window_update (window, NULL);
@@ -5484,7 +5552,11 @@ real_response (GtkDialog *dialog,
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+real_destroy (GtkWidget *object)
+#else
real_destroy (GtkObject *object)
+#endif
{
FMPropertiesWindow *window;
GList *l;
@@ -5542,7 +5614,11 @@ real_destroy (GtkObject *object)
window->details->update_files_timeout_id = 0;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (parent_class)->destroy (object);
+#else
GTK_OBJECT_CLASS (parent_class)->destroy (object);
+#endif
}
static void
@@ -5552,7 +5628,8 @@ real_finalize (GObject *object)
window = FM_PROPERTIES_WINDOW (object);
- eel_g_list_free_deep (window->details->mime_list);
+ g_list_foreach(window->details->mime_list, (GFunc) g_free, NULL);
+ g_list_free(window->details->mime_list);
g_free (window->details->pending_name);
g_free (window->details);
@@ -5797,11 +5874,15 @@ fm_properties_window_class_init (FMPropertiesWindowClass *class)
GtkBindingSet *binding_set;
G_OBJECT_CLASS (class)->finalize = real_finalize;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GTK_OBJECT_CLASS (class)->destroy = real_destroy;
+#else
+ GTK_WIDGET_CLASS (class)->destroy = real_destroy;
+#endif
GTK_DIALOG_CLASS (class)->response = real_response;
binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0,
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
"close", 0);
}
diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c
index 15071b8c..3423e2d1 100644
--- a/src/file-manager/fm-tree-model.c
+++ b/src/file-manager/fm-tree-model.c
@@ -29,7 +29,6 @@
#include <config.h>
#include "fm-tree-model.h"
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <glib/gi18n.h>
#include <libcaja-private/caja-directory.h>
@@ -67,7 +66,6 @@ struct TreeNode
GMount *mount;
GdkPixbuf *closed_pixbuf;
GdkPixbuf *open_pixbuf;
- GdkPixbuf *emblem_pixbuf;
FMTreeModelRoot *root;
@@ -221,7 +219,6 @@ tree_node_destroy (FMTreeModel *model, TreeNode *node)
object_unref_if_not_NULL (node->icon);
object_unref_if_not_NULL (node->closed_pixbuf);
object_unref_if_not_NULL (node->open_pixbuf);
- object_unref_if_not_NULL (node->emblem_pixbuf);
g_assert (node->done_loading_id == 0);
g_assert (node->files_added_id == 0);
@@ -278,17 +275,59 @@ get_menu_icon_for_file (TreeNode *node,
CajaFileIconFlags flags)
{
CajaIconInfo *info;
+ GIcon *gicon, *emblem_icon, *emblemed_icon;
+ GEmblem *emblem;
GdkPixbuf *pixbuf, *retval;
gboolean highlight;
int size;
FMTreeModel *model;
+ GList *emblem_icons, *l;
+ char *emblems_to_ignore[3];
+ int i;
size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
- info = caja_file_get_icon (file, size, flags);
+ gicon = caja_file_get_gicon (file, flags);
+
+ i = 0;
+ emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH;
+
+ if (node->parent && node->parent->file) {
+ if (!caja_file_can_write (node->parent->file)) {
+ emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE;
+ }
+ }
+
+ emblems_to_ignore[i++] = NULL;
+
+ emblem = NULL;
+ emblem_icons = caja_file_get_emblem_icons (node->file,
+ emblems_to_ignore);
+
+ /* pick only the first emblem we can render for the tree view */
+ for (l = emblem_icons; l != NULL; l = l->next) {
+ emblem_icon = l->data;
+ if (caja_icon_theme_can_render (G_THEMED_ICON (emblem_icon))) {
+ emblem = g_emblem_new (emblem_icon);
+ emblemed_icon = g_emblemed_icon_new (gicon, emblem);
+
+ g_object_unref (gicon);
+ g_object_unref (emblem);
+ gicon = emblemed_icon;
+
+ break;
+ }
+ }
+
+ g_list_foreach (emblem_icons, (GFunc) g_object_unref, NULL);
+ g_list_free(emblem_icons);
+
+ info = caja_icon_info_lookup (gicon, size);
retval = caja_icon_info_get_pixbuf_nodefault_at_size (info, size);
model = node->root->model;
+ g_object_unref (gicon);
+
highlight = (g_list_find_custom (model->details->highlighted_files,
file, (GCompareFunc) caja_file_compare_location) != NULL);
@@ -353,67 +392,6 @@ tree_node_update_open_pixbuf (TreeNode *node)
return tree_node_update_pixbuf (node, &node->open_pixbuf, CAJA_FILE_ICON_FLAGS_FOR_OPEN_FOLDER);
}
-static GdkPixbuf *
-tree_node_get_emblem_pixbuf_internal (TreeNode *node)
-{
- GdkPixbuf *pixbuf;
- GList *emblem_pixbufs;
- char *emblems_to_ignore[3];
- int i;
-
- i = 0;
- emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH;
-
- if (node->parent && node->parent->file)
- {
- if (!caja_file_can_write (node->parent->file))
- {
- emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE;
- }
- }
-
- emblems_to_ignore[i++] = NULL;
-
- emblem_pixbufs = caja_file_get_emblem_pixbufs (node->file,
- caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU),
- TRUE,
- emblems_to_ignore);
-
-
- if (emblem_pixbufs != NULL)
- {
- pixbuf = g_object_ref (emblem_pixbufs->data);
- }
- else
- {
- pixbuf = NULL;
- }
-
- eel_gdk_pixbuf_list_free (emblem_pixbufs);
-
- return pixbuf;
-}
-
-static gboolean
-tree_node_update_emblem_pixbuf (TreeNode *node)
-{
- GdkPixbuf *pixbuf;
-
- if (node->emblem_pixbuf == NULL)
- {
- return FALSE;
- }
- pixbuf = tree_node_get_emblem_pixbuf_internal (node);
- if (pixbuf == node->emblem_pixbuf)
- {
- g_object_unref (pixbuf);
- return FALSE;
- }
- g_object_unref (node->emblem_pixbuf);
- node->emblem_pixbuf = pixbuf;
- return TRUE;
-}
-
static gboolean
tree_node_update_display_name (TreeNode *node)
{
@@ -459,16 +437,6 @@ tree_node_get_open_pixbuf (TreeNode *node)
return node->open_pixbuf;
}
-static GdkPixbuf *
-tree_node_get_emblem_pixbuf (TreeNode *node)
-{
- if (node->emblem_pixbuf == NULL)
- {
- node->emblem_pixbuf = tree_node_get_emblem_pixbuf_internal (node);
- }
- return node->emblem_pixbuf;
-}
-
static const char *
tree_node_get_display_name (TreeNode *node)
{
@@ -919,7 +887,6 @@ update_node_without_reporting (FMTreeModel *model, TreeNode *node)
changed |= tree_node_update_display_name (node);
changed |= tree_node_update_closed_pixbuf (node);
changed |= tree_node_update_open_pixbuf (node);
- changed |= tree_node_update_emblem_pixbuf (node);
return changed;
}
@@ -1244,8 +1211,6 @@ fm_tree_model_get_column_type (GtkTreeModel *model, int index)
return GDK_TYPE_PIXBUF;
case FM_TREE_MODEL_OPEN_PIXBUF_COLUMN:
return GDK_TYPE_PIXBUF;
- case FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN:
- return GDK_TYPE_PIXBUF;
case FM_TREE_MODEL_FONT_STYLE_COLUMN:
return PANGO_TYPE_STYLE;
default:
@@ -1412,18 +1377,11 @@ fm_tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, int column, GVa
g_value_init (value, GDK_TYPE_PIXBUF);
g_value_set_object (value, node == NULL ? NULL : tree_node_get_open_pixbuf (node));
break;
- case FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
- g_value_set_object (value, node == NULL ? NULL : tree_node_get_emblem_pixbuf (node));
- break;
case FM_TREE_MODEL_FONT_STYLE_COLUMN:
g_value_init (value, PANGO_TYPE_STYLE);
- if (node == NULL)
- {
+ if (node == NULL) {
g_value_set_enum (value, PANGO_STYLE_ITALIC);
- }
- else
- {
+ } else {
g_value_set_enum (value, PANGO_STYLE_NORMAL);
}
break;
diff --git a/src/file-manager/fm-tree-model.h b/src/file-manager/fm-tree-model.h
index bfca06e4..2e459392 100644
--- a/src/file-manager/fm-tree-model.h
+++ b/src/file-manager/fm-tree-model.h
@@ -49,7 +49,6 @@ enum
FM_TREE_MODEL_DISPLAY_NAME_COLUMN,
FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
FM_TREE_MODEL_OPEN_PIXBUF_COLUMN,
- FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN,
FM_TREE_MODEL_FONT_STYLE_COLUMN,
FM_TREE_MODEL_NUM_COLUMNS
};
diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c
index 71ec5a95..37559f53 100644
--- a/src/file-manager/fm-tree-view.c
+++ b/src/file-manager/fm-tree-view.c
@@ -35,10 +35,7 @@
#include "fm-tree-model.h"
#include "fm-properties-window.h"
#include <string.h>
-#include <eel/eel-alert-dialog.h>
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-stock-dialogs.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
@@ -53,7 +50,6 @@
#include <libcaja-private/caja-icon-names.h>
#include <libcaja-private/caja-program-choosing.h>
#include <libcaja-private/caja-tree-view-drag-dest.h>
-#include <libcaja-private/caja-cell-renderer-pixbuf-emblem.h>
#include <libcaja-private/caja-sidebar-provider.h>
#include <libcaja-private/caja-module.h>
#include <libcaja-private/caja-window-info.h>
@@ -1063,7 +1059,8 @@ paste_clipboard_data (FMTreeView *view,
gtk_clipboard_clear (caja_clipboard_get (GTK_WIDGET (view)));
}
- eel_g_list_free_deep (item_uris);
+ g_list_foreach(item_uris, (GFunc) g_free, NULL);
+ g_list_free(item_uris);
}
}
@@ -1126,7 +1123,8 @@ fm_tree_view_trash_cb (GtkWidget *menu_item,
caja_file_operations_trash_or_delete (list,
fm_tree_view_get_containing_window (view),
NULL, NULL);
- eel_g_object_list_free (list);
+ g_list_foreach(list, (GFunc) g_object_unref, NULL);
+ g_list_free(list);
}
static void
@@ -1144,7 +1142,8 @@ fm_tree_view_delete_cb (GtkWidget *menu_item,
caja_file_get_location (view->details->popup_file));
caja_file_operations_delete (location_list, fm_tree_view_get_containing_window (view), NULL, NULL);
- eel_g_object_list_free (location_list);
+ g_list_foreach(location_list, (GFunc) g_object_unref, NULL);
+ g_list_free(location_list);
}
static void
@@ -1475,13 +1474,12 @@ create_tree (FMTreeView *view)
/* Create column */
column = gtk_tree_view_column_new ();
- cell = caja_cell_renderer_pixbuf_emblem_new ();
+ cell = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, cell, FALSE);
gtk_tree_view_column_set_attributes (column, cell,
"pixbuf", FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
"pixbuf_expander_closed", FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
"pixbuf_expander_open", FM_TREE_MODEL_OPEN_PIXBUF_COLUMN,
- "pixbuf_emblem", FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN,
NULL);
cell = gtk_cell_renderer_text_new ();
diff --git a/test/Makefile.am b/test/Makefile.am
index 9e3d2099..92b9fda0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -21,7 +21,6 @@ noinst_PROGRAMS =\
test-caja-copy \
test-eel-background \
test-eel-editable-label \
- test-eel-image-scrolled \
test-eel-image-table \
test-eel-labeled-image \
test-eel-pixbuf-scale \
@@ -36,7 +35,6 @@ test_caja_search_engine_SOURCES = test-caja-search-engine.c
test_caja_directory_async_SOURCES = test-caja-directory-async.c
test_eel_background_SOURCES = test-eel-background.c
-test_eel_image_scrolled_SOURCES = test-eel-image-scrolled.c test.c test.h
test_eel_image_table_SOURCES = test-eel-image-table.c test.c
test_eel_labeled_image_SOURCES = test-eel-labeled-image.c test.c test.h
test_eel_pixbuf_scale_SOURCES = test-eel-pixbuf-scale.c test.c test.h
diff --git a/test/test-eel-image-scrolled.c b/test/test-eel-image-scrolled.c
deleted file mode 100644
index c89cfe9f..00000000
--- a/test/test-eel-image-scrolled.c
+++ /dev/null
@@ -1,187 +0,0 @@
-#include "test.h"
-
-#if 0
-typedef struct
-{
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *entry;
- GtkWidget *hbox;
- GtkWidget *smooth_toggle;
- GtkWidget *frame;
- GtkWidget *label;
-} Window;
-
-#if 0
-static void
-toggle_smooth_callback (GtkWidget *widget, gpointer callback_data)
-{
- Window *window;
- EelLabel *label;
-
- window = (Window *) callback_data;
-
- if (!EEL_IS_LABEL (window->label)) {
- return;
- }
-
- label = GTK_LABEL (window->label);
-
- gtk_label_set_is_smooth (label, !gtk_label_get_is_smooth (label));
-}
-#endif
-
-static Window *
-window_new (const char *title, guint border_width)
-{
- Window *window;
- GtkWidget *main_vbox;
-
- window = g_new0 (Window, 1);
-
- window->window = test_window_new (title, border_width);
-
- main_vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (window->window), main_vbox);
-
- window->vbox = gtk_vbox_new (FALSE, 0);
- window->entry = gtk_entry_new ();
- window->hbox = gtk_hbox_new (FALSE, 0);
-// window->smooth_toggle = gtk_check_button_new_with_label ("Smooth");
-
- gtk_box_pack_start (GTK_BOX (main_vbox), window->vbox, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (main_vbox), window->hbox, FALSE, FALSE, 0);
- gtk_box_pack_end (GTK_BOX (main_vbox), window->entry, FALSE, FALSE, 0);
-
-// gtk_box_pack_start (GTK_BOX (window->hbox), window->smooth_toggle, FALSE, FALSE, 0);
-
- gtk_widget_show (main_vbox);
- gtk_widget_show (window->vbox);
- gtk_widget_show (window->hbox);
- gtk_widget_show (window->entry);
-
- return window;
-}
-
-static Window *
-label_window_new (const char *title,
- guint border_width,
- const char *file_name,
- const char *tile_file_name)
-{
- Window *window;
-
- window = window_new (title, border_width);
-
- window->frame = gtk_frame_new ("Foo");
- window->label = gtk_label_new (file_name);
-
- if (tile_file_name != NULL) {
- gtk_label_set_tile_pixbuf_from_file_name (GTK_LABEL (window->label),
- tile_file_name);
- }
-
- gtk_container_add (GTK_CONTAINER (window->frame), window->label);
-
- gtk_box_pack_start (GTK_BOX (window->vbox), window->frame, TRUE, TRUE, 0);
-
- gtk_widget_show (window->label);
- gtk_widget_show (window->frame);
-
- return window;
-}
-#endif
-
-static const char text[] =
-"The Eel shell is under development; it's not "
-"ready for daily use. Some features are not yet done, "
-"partly done, or unstable. The program doesn't look "
-"or act exactly the way it will in version 1.0."
-"\n\n"
-"If you do decide to test this version of Eel, "
-"beware. The program could do something "
-"unpredictable and may even delete or overwrite "
-"files on your computer."
-"\n\n"
-"For more information, visit http://eel.eazel.com.";
-
-static GtkWidget *
-label_window_new (void)
-{
- GtkWidget *window;
- GtkWidget *label;
- EelBackground *background;
-
- window = test_window_new ("Scrolled Label Test", 10);
-
- background = eel_get_widget_background (GTK_WIDGET (window));
- eel_background_set_color (background, "white");
-
- /* Label */
- label = gtk_label_new (text);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-
- gtk_container_add (GTK_CONTAINER (window), label);
-
- gtk_widget_show (label);
-
- return window;
-}
-
-static GtkWidget *
-label_window_new_scrolled (void)
-{
- GtkWidget *window;
- GtkWidget *scrolled;
- GtkWidget *viewport;
- GtkWidget *label;
- EelBackground *background;
-
- window = test_window_new ("Scrolled Label Test", 10);
-
- /* Scrolled window */
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (window), scrolled);
-
- /* Viewport */
- viewport = gtk_viewport_new (NULL, NULL);
- gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT);
- gtk_container_add (GTK_CONTAINER (scrolled), viewport);
-
- background = eel_get_widget_background (GTK_WIDGET (viewport));
- eel_background_set_color (background, "white");
-
- /* Label */
- label = gtk_label_new (text);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-
- gtk_container_add (GTK_CONTAINER (viewport), label);
-
- gtk_widget_show (label);
- gtk_widget_show (viewport);
- gtk_widget_show (scrolled);
-
- return window;
-}
-
-int
-main (int argc, char* argv[])
-{
- GtkWidget *label_window;
- GtkWidget *scrolled_label_window;
-
- test_init (&argc, &argv);
-
- label_window = label_window_new ();
- scrolled_label_window = label_window_new_scrolled ();
-
- gtk_widget_show (scrolled_label_window);
- gtk_widget_show (label_window);
-
- gtk_main ();
-
- return 0;
-}
diff --git a/test/test-eel-image-table.c b/test/test-eel-image-table.c
index d60aa91b..9677537a 100644
--- a/test/test-eel-image-table.c
+++ b/test/test-eel-image-table.c
@@ -63,7 +63,7 @@ labeled_image_new (const char *text,
{
GtkWidget *image;
GdkPixbuf *pixbuf = NULL;
-
+
if (icon_name) {
float sizes[] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0 };
@@ -194,7 +194,7 @@ image_table_size_allocate (GtkWidget *image_table,
gtk_widget_get_allocation (GTK_WIDGET (image_table), &w_allocation);
if (0) gtk_widget_size_allocate (GTK_WIDGET (image_table),
&w_allocation);
-
+
g_print ("%s(%d)\n", G_STRFUNC, recursion_count);
recursion_count--;
@@ -264,8 +264,6 @@ image_table_new_scrolled (void)
G_CALLBACK (image_table_child_clicked_callback),
NULL);
- eel_gtk_widget_set_background_color (viewport, BG_COLOR_SPEC);
-
for (i = 0; i < 100; i++) {
char *text;
GtkWidget *image;
@@ -283,11 +281,11 @@ image_table_new_scrolled (void)
gtk_widget_show (viewport);
gtk_widget_show (scrolled);
gtk_widget_show (image_table);
-
+
return window;
}
-int
+int
main (int argc, char* argv[])
{
GtkWidget *window = NULL;
@@ -295,10 +293,10 @@ main (int argc, char* argv[])
test_init (&argc, &argv);
window = image_table_new_scrolled ();
-
+
gtk_widget_show (window);
-
+
gtk_main ();
-
+
return 0;
}