summaryrefslogtreecommitdiff
path: root/src
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 /src
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
Diffstat (limited to 'src')
-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
64 files changed, 3698 insertions, 2670 deletions
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 ();