xapantu has proposed merging lp:~xapantu/marlin/tests into lp:marlin.

Requested reviews:
  The elementary Project (elementaryproject)

For more details, see:
https://code.launchpad.net/~xapantu/marlin/tests/+merge/58024

Changes:
- Improvements to the build system, it supports unit tests using make check. 
The code is in src/tests
- Keyboard navigation in miller columns (change of columns using left and right 
keys)
- Vertical ContextView by default for miller columns, horizontal was weird.

- Code cleanup: remove useless function in marlin-window-columns.c, remove 
nonexistent function in marlin-window-columns.h, the code is easier to read
- Add code comments in the function headers (gtk-doc style)
-- 
https://code.launchpad.net/~xapantu/marlin/tests/+merge/58024
Your team The elementary Project is requested to review the proposed merge of 
lp:~xapantu/marlin/tests into lp:marlin.
=== modified file '.bzrignore'
--- .bzrignore	2011-04-13 17:13:56 +0000
+++ .bzrignore	2011-04-17 09:37:23 +0000
@@ -57,3 +57,4 @@
 src/marlin-vala.h
 src/marlin.vala.stamp
 src/View/Animations.c
+src/marlintests

=== modified file 'configure.ac'
--- configure.ac	2011-03-30 21:49:20 +0000
+++ configure.ac	2011-04-17 09:37:23 +0000
@@ -183,6 +183,7 @@
 data/Makefile
 icons/Makefile
 po/Makefile.in
+src/tests/Makefile
 ])
 AC_OUTPUT
 

=== modified file 'src/Makefile.am'
--- src/Makefile.am	2011-04-10 21:52:44 +0000
+++ src/Makefile.am	2011-04-17 09:37:23 +0000
@@ -52,7 +52,6 @@
     $(NULL)
 
 marlin_CSOURCES = \
-    marlin-main.c                           \
     marlin-application.c                    \
     mysignal.c                              \
     eel-fcts.c                              \
@@ -100,6 +99,7 @@
 marlin_SOURCES = \
     $(marlin_VALASOURCES:.vala=.c)          \
     $(marlin_CSOURCES)                      \
+	marlin-main.c                           \
     $(NULL)
 
 nodist_marlin_SOURCES = \
@@ -147,3 +147,22 @@
 	$(marlin_VALASOURCES:.vala=.c) \
 	$(NULL)
 
+# GLIB - Library of useful C routines
+
+#GTESTER = gtester 			# for non-GLIB packages
+GTESTER = /usr/bin/gtester		# for the GLIB package
+GTESTER_REPORT = /usr/bin/gtester-report	# for the GLIB package
+
+check_PROGRAMS = marlintests
+marlintests_SOURCES = tests/marlintests.c             \
+					  tests/mwc_tests.c               \
+					  $(marlin_VALASOURCES:.vala=.c)  \
+				      $(marlin_CSOURCES)              \
+					  $(BUILT_SOURCES)                \
+					  $(NULL)
+marlintests_LDADD = $(CORE_LIBS) $(NULL)
+marlintests_CFLAGS = $(CORE_CFLAGS) $(NULL) -I..
+marlintests_CPPFLAGS = $(marlin_CPPFLAGS)
+TESTS_ENVIRONMENT= $(GTESTER)
+TESTS = marlintests
+

=== modified file 'src/fm-columns-view.c'
--- src/fm-columns-view.c	2011-03-27 01:38:14 +0000
+++ src/fm-columns-view.c	2011-04-17 09:37:23 +0000
@@ -652,40 +652,6 @@
     return FM_COLUMNS_VIEW (view)->details->selection;
 }
 
-/*static void
-  fm_columns_view_set_selection (FMColumnsView *list_view, GList *selection)
-  {
-  GtkTreeSelection *tree_selection;
-  GList *node;
-  GList *iters, *l;
-  GOFFile *file;
-
-  tree_selection = gtk_tree_view_get_selection (list_view->tree);
-
-//g_signal_handlers_block_by_func (tree_selection, list_selection_changed_callback, view);
-
-gtk_tree_selection_unselect_all (tree_selection);
-for (node = selection; node != NULL; node = node->next) {
-file = node->data;
-iters = fm_list_model_get_all_iters_for_file (list_view->model, file);
-
-for (l = iters; l != NULL; l = l->next) {
-gtk_tree_selection_select_iter (tree_selection,
-(GtkTreeIter *)l->data);
-}
-//eel_g_list_free_deep (iters);
-}
-
-//g_signal_handlers_unblock_by_func (tree_selection, list_selection_changed_callback, view);
-//fm_directory_view_notify_selection_changed (view);
-}
-
-static void
-fm_columns_view_select_all (FMColumnsView *view)
-{
-gtk_tree_selection_select_all (gtk_tree_view_get_selection (view->tree));
-}*/
-
 static GtkTreePath*
 fm_columns_view_get_path_at_pos (FMDirectoryView *view, gint x, gint y)
 {

=== modified file 'src/fm-directory-view.c'
--- src/fm-directory-view.c	2011-04-06 19:41:33 +0000
+++ src/fm-directory-view.c	2011-04-17 09:37:23 +0000
@@ -670,7 +670,7 @@
 void
 fm_directory_view_column_add_preview (FMDirectoryView *dview, GOFFile *file)
 {
-    MarlinViewContextView *contextview = marlin_view_context_view_new (MARLIN_VIEW_WINDOW (dview->details->window), FALSE, GTK_ORIENTATION_VERTICAL);
+    MarlinViewContextView *contextview = marlin_view_context_view_new (MARLIN_VIEW_WINDOW (dview->details->window), FALSE, GTK_ORIENTATION_HORIZONTAL);
     marlin_view_context_view_update (contextview, file);
     /* resize context view to match the default columns size 180+2 border px */
     gtk_widget_set_size_request (GTK_WIDGET (contextview), 182, -1);

=== modified file 'src/gof-window-slot.c'
--- src/gof-window-slot.c	2011-03-23 18:03:03 +0000
+++ src/gof-window-slot.c	2011-04-17 09:37:23 +0000
@@ -38,140 +38,102 @@
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-#if 0
-static void
-real_active (NautilusWindowSlot *slot)
-{
-    NautilusWindow *window;
-
-    window = slot->pane->window;
-
-    /* sync window to new slot */
-    nautilus_window_sync_status (window);
-    nautilus_window_sync_allow_stop (window, slot);
-    nautilus_window_sync_title (window, slot);
-    nautilus_window_sync_zoom_widgets (window);
-    nautilus_window_pane_sync_location_widgets (slot->pane);
-    nautilus_window_pane_sync_search_widgets (slot->pane);
-
-    if (slot->viewed_file != NULL) {
-        nautilus_window_load_view_as_menus (window);
-        nautilus_window_load_extension_menus (window);
-    }
-}
-
-static void
-nautilus_window_slot_active (NautilusWindowSlot *slot)
-{
-    NautilusWindow *window;
-    NautilusWindowPane *pane;
-
-    g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-
-    pane = NAUTILUS_WINDOW_PANE (slot->pane);
-    window = NAUTILUS_WINDOW (slot->pane->window);
-    g_assert (g_list_find (pane->slots, slot) != NULL);
-    g_assert (slot == window->details->active_pane->active_slot);
-
-    EEL_CALL_METHOD (NAUTILUS_WINDOW_SLOT_CLASS, slot,
-                     active, (slot));
-}
-
-static void
-real_inactive (NautilusWindowSlot *slot)
-{
-    NautilusWindow *window;
-
-    window = NAUTILUS_WINDOW (slot->pane->window);
-    g_assert (slot == window->details->active_pane->active_slot);
-}
-
-static void
-nautilus_window_slot_inactive (NautilusWindowSlot *slot)
-{
-    NautilusWindow *window;
-    NautilusWindowPane *pane;
-
-    g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-
-    pane = NAUTILUS_WINDOW_PANE (slot->pane);
-    window = NAUTILUS_WINDOW (pane->window);
-
-    g_assert (g_list_find (pane->slots, slot) != NULL);
-    g_assert (slot == window->details->active_pane->active_slot);
-
-    EEL_CALL_METHOD (NAUTILUS_WINDOW_SLOT_CLASS, slot,
-                     inactive, (slot));
-}
-#endif
-
+
+static void
+gof_window_slot_init (GOFWindowSlot *slot)
+{
+}
+
+static void
+gof_window_slot_class_init (GOFWindowSlotClass *class)
+{
+    signals[ACTIVE] =
+	g_signal_new ("active",
+		      G_TYPE_FROM_CLASS (class),
+		      G_SIGNAL_RUN_LAST,
+		      G_STRUCT_OFFSET (GOFWindowSlotClass, active),
+		      NULL, NULL,
+		      g_cclosure_marshal_VOID__VOID,
+		      G_TYPE_NONE, 0);
+
+    signals[INACTIVE] =
+	g_signal_new ("inactive",
+		      G_TYPE_FROM_CLASS (class),
+		      G_SIGNAL_RUN_LAST,
+		      G_STRUCT_OFFSET (GOFWindowSlotClass, inactive),
+		      NULL, NULL,
+		      g_cclosure_marshal_VOID__VOID,
+		      G_TYPE_NONE, 0);
+
+    G_OBJECT_CLASS (class)->finalize = gof_window_slot_finalize;
+}
+
+static void
+gof_window_slot_finalize (GObject *object)
+{
+    GOFWindowSlot *slot = GOF_WINDOW_SLOT (object);
+    log_printf (LOG_LEVEL_UNDEFINED, "%s %s\n", G_STRFUNC, g_file_get_uri (slot->directory->location));
+
+    //load_dir_async_cancel(slot->directory);
+    g_object_unref(slot->directory);
+    g_object_unref(slot->location);
+    G_OBJECT_CLASS (parent_class)->finalize (object);
+    printf ("test %s\n", G_STRFUNC);
+    /* avoid a warning in vala code: slot is freed in ViewContainer */
+    //slot = NULL;
+}
 
 void
 gof_window_column_add (GOFWindowSlot *slot, GtkWidget *column)
 {
-    //GtkWidget *scrolled;
-
     GtkWidget *hpane = gtk_hpaned_new();
     gtk_widget_show (hpane);
-    //gtk_paned_set_position(GTK_PANED (hpane), 200);
     gtk_container_add(GTK_CONTAINER(slot->colpane), hpane);
-    //gtk_box_pack_end(GTK_BOX(slot->colpane), hpane, TRUE, FALSE, 0);
-    GtkWidget *vbox2 = gtk_hbox_new(FALSE, 0);
+    GtkWidget *vbox2 = gtk_hbox_new(FALSE /* homogeneous */, 0 /* padding */);
     gtk_widget_show (vbox2);
     slot->colpane = vbox2;
     slot->hpane = hpane;
 
-    /*scrolled = gtk_scrolled_window_new(0, 0);
-      gtk_widget_show(scrolled);
-      gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (scrolled), column);
-      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
-      GTK_POLICY_NEVER,
-      GTK_POLICY_AUTOMATIC);*/
-    //gtk_container_add(GTK_CONTAINER(scrolled), column);
-    gtk_widget_set_size_request (column, 180,-1);
+    gtk_widget_set_size_request (column, 180, -1 /* means auto */);
 
     gtk_paned_pack1 (GTK_PANED (hpane), column, FALSE, FALSE);
-    //gtk_paned_pack1 (GTK_PANED (hpane), column, TRUE, TRUE);
-    //gtk_paned_pack1 (GTK_PANED (hpane), scrolled, FALSE, FALSE);
     gtk_paned_pack2 (GTK_PANED (hpane), vbox2, TRUE, FALSE);
 }
 
 void
 gof_window_columns_add_location (GOFWindowSlot *slot, GFile *location)
 {
-    log_printf (LOG_LEVEL_UNDEFINED, "%s\n", G_STRFUNC);
+    gint current_slot_position = 0;
+    gint i;
+    GList* mwcols_slot_tmp = slot->mwcols->slot;
     slot->mwcols->active_slot = slot;
-    //GList *childs = gtk_container_get_children (slot->colpane);
     gtk_container_foreach (GTK_CONTAINER (slot->colpane), (GtkCallback)gtk_widget_destroy, NULL);
+    
+    current_slot_position = g_list_index(slot->mwcols->slot, slot);
+    if(current_slot_position == -1)
+    {
+        g_warning("Can't find the slot you are viewing, this should *not* happen.");
+    }
+    else
+    {
+        slot->mwcols->slot = NULL;
+        for(i = 0; i <= current_slot_position; i++)
+        {
+            slot->mwcols->slot = g_list_append(slot->mwcols->slot, g_list_nth_data(mwcols_slot_tmp, i));
+        }
+    }
+    
     marlin_window_columns_add (slot->mwcols, location);
-    /*GOFWindowSlot *slot = gof_window_slot_column_new (location);
-      slot->mwcols = mwcols;
-      mwcols->active_slot = slot;
-      add_column(mwcols, slot->view_box);*/
 }
 
 void
 gof_window_columns_add_preview (GOFWindowSlot *slot, GtkWidget *context_view)
 {
+    slot->mwcols->active_slot = slot;
     gtk_container_foreach (GTK_CONTAINER (slot->colpane), (GtkCallback)gtk_widget_destroy, NULL);
     gtk_container_add(GTK_CONTAINER(slot->colpane), context_view);
 }
 
-static void
-gof_window_slot_finalize (GObject *object)
-{
-    GOFWindowSlot *slot = GOF_WINDOW_SLOT (object);
-    log_printf (LOG_LEVEL_UNDEFINED, "%s %s\n", G_STRFUNC, g_file_get_uri (slot->directory->location));
-
-    //load_dir_async_cancel(slot->directory);
-    g_object_unref(slot->directory);
-    g_object_unref(slot->location);
-    G_OBJECT_CLASS (parent_class)->finalize (object);
-    printf ("test %s\n", G_STRFUNC);
-    /* avoid a warning in vala code: slot is freed in ViewContainer */
-    //slot = NULL;
-}
-
 GOFWindowSlot *
 gof_window_slot_new (GFile *location, GObject *ctab)
 {
@@ -181,47 +143,16 @@
     slot->location = g_object_ref (location);
     slot->ctab = ctab;
 
-    //amtest
-    //slot->directory = gof_directory_async_new(slot->location);
     slot->directory = gof_directory_get (slot->location);
-    /*slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW,
-                                               "window-slot", slot, NULL));*/
-    //slot->view_box = gtk_label_new ("test");
-    //marlin_window_set_active_slot (MARLIN_WINDOW (window), slot);
-    //marlin_view_window_set_active_slot (MARLIN_VIEW_WINDOW (window), slot);
-#if 0
-    slot->colpane = gtk_hbox_new (FALSE, 0);
-    gtk_widget_show (slot->colpane);
-    slot->view_box = gtk_scrolled_window_new(0, 0);
-
-    //gtk_container_add (GTK_CONTAINER (view), hpane);
-    //gtk_container_add (GTK_CONTAINER (slot->view_box), slot->colpane);
-    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (slot->view_box), slot->colpane);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (slot->view_box),
-                                    GTK_POLICY_AUTOMATIC,
-                                    GTK_POLICY_NEVER);
-    /*add_column(slot, GTK_WIDGET (g_object_new (FM_TYPE_COLUMNS_VIEW,
-      "window-slot", slot, NULL)));*/
-    /*slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_COLUMNS_VIEW,
-      "window-slot", slot, NULL));*/
-    gtk_widget_show (slot->view_box);
-
-    /*int i;
-      for (i=0; i<4; i++) {
-      GtkWidget *test = gtk_label_new ("test");
-    //gtk_widget_set_size_request(test, 100,-1);
-    gtk_widget_show(test);
-    add_column(slot, test);
-    }*/
-#endif
-    /*gtk_container_add( GTK_CONTAINER(window), slot->view_box);*/
-    //marlin_view_window_set_content (window, slot->view_box);
-    /*marlin_view_view_container_set_content (ctab, slot->view_box);
-    load_dir_async (slot->directory);*/
 
     return slot;
 }
 
+/**
+ * Used to make a view in the list view.
+ * It replaces the content of the current tab by it own widget (wich is a list
+ * of the current files of this directory).
+ **/
 void
 gof_window_slot_make_view (GOFWindowSlot *slot)
 {
@@ -231,6 +162,15 @@
     load_dir_async (slot->directory);
 }
 
+/**
+ * Used to make a view in the column view.
+ * It replaces the content of the current tab by it own widget (wich is a list
+ * of the current files of this directory).
+ *
+ * Note:
+ * In miller column view, you'll have multiple column displayed, not only this
+ * one.
+ **/
 void
 gof_window_slot_make_column_view (GOFWindowSlot *slot)
 {
@@ -238,89 +178,6 @@
                                                "window-slot", slot, NULL));
     load_dir_async (slot->directory);
 }
-
-static void
-gof_window_slot_init (GOFWindowSlot *slot)
-{
-#if 0
-    GtkWidget *content_box, *eventbox, *extras_vbox, *frame, *hsep;
-
-    content_box = gtk_vbox_new (FALSE, 0);
-    slot->content_box = content_box;
-    gtk_widget_show (content_box);
-
-    frame = gtk_frame_new (NULL);
-    gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
-    gtk_box_pack_start (GTK_BOX (content_box), frame, TRUE, TRUE, 0);
-    gtk_widget_show (frame);
-
-    slot->view_box = gtk_vbox_new (FALSE, 0);
-    gtk_container_add (GTK_CONTAINER (frame), slot->view_box);
-    gtk_widget_show (slot->view_box);
-#endif
-    //slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW, NULL));
-    /*slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW,
-      "window-slot", slot, NULL));*/
-    //gtk_box_pack_start (GTK_BOX (slot->content_box), GTK_WIDGET (slot->list_view->tree), TRUE, TRUE, 0);
-
-
-    /*GtkWidget *m_scwin;
-      m_scwin = gtk_scrolled_window_new(NULL,NULL);
-      slot->content_box = m_scwin;
-      gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_scwin), GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC);
-      gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_scwin), GTK_SHADOW_NONE);*/
-
-    //gtk_container_add( GTK_CONTAINER(m_scwin), GTK_WIDGET (slot->list_view->tree));
-
-
-#if 0
-    eventbox = gtk_event_box_new ();
-    slot->extra_location_event_box = eventbox;
-    gtk_widget_set_name (eventbox, "nautilus-extra-view-widget");
-    gtk_box_pack_start (GTK_BOX (slot->view_box), eventbox, FALSE, FALSE, 0);
-
-    extras_vbox = gtk_vbox_new (FALSE, 6);
-    gtk_container_set_border_width (GTK_CONTAINER (extras_vbox), 6);
-    slot->extra_location_widgets = extras_vbox;
-    gtk_container_add (GTK_CONTAINER (eventbox), extras_vbox);
-    gtk_widget_show (extras_vbox);
-
-    hsep = gtk_hseparator_new ();
-    gtk_box_pack_start (GTK_BOX (slot->view_box), hsep, FALSE, FALSE, 0);
-    slot->extra_location_separator = hsep;
-
-    slot->title = g_strdup (_("Loading..."));
-#endif
-}
-
-static void
-gof_window_slot_class_init (GOFWindowSlotClass *class)
-{
-    /*class->active = real_active;
-      class->inactive = real_inactive;
-      class->update_query_editor = real_update_query_editor; */
-
-    signals[ACTIVE] =
-	g_signal_new ("active",
-		      G_TYPE_FROM_CLASS (class),
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET (GOFWindowSlotClass, active),
-		      NULL, NULL,
-		      g_cclosure_marshal_VOID__VOID,
-		      G_TYPE_NONE, 0);
-
-    signals[INACTIVE] =
-	g_signal_new ("inactive",
-		      G_TYPE_FROM_CLASS (class),
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET (GOFWindowSlotClass, inactive),
-		      NULL, NULL,
-		      g_cclosure_marshal_VOID__VOID,
-		      G_TYPE_NONE, 0);
-
-    G_OBJECT_CLASS (class)->finalize = gof_window_slot_finalize;
-}
-
 GFile *
 gof_window_slot_get_location (GOFWindowSlot *slot)
 {
@@ -338,110 +195,4 @@
     return NULL;
 }
 
-#if 0
-char *
-nautilus_window_slot_get_title (GOFWindowSlot *slot)
-{
-    g_assert (GOF_IS_WINDOW_SLOT (slot));
-
-    if (slot->content_view != NULL) {
-        title = nautilus_view_get_title (slot->content_view);
-    }
-
-    if (title == NULL) {
-        title = nautilus_compute_title_for_location (slot->location);
-    }
-
-    return title;
-}
-#endif
-
-#if 0
-/* nautilus_window_slot_update_icon:
- * 
- * Re-calculate the slot icon
- * Called when the location or view or icon set has changed.
- * @slot: The NautilusWindowSlot in question.
- */
-void
-nautilus_window_slot_update_icon (NautilusWindowSlot *slot)
-{
-    NautilusWindow *window;
-    NautilusIconInfo *info;
-    const char *icon_name;
-    GdkPixbuf *pixbuf;
-
-    window = slot->pane->window;
-
-    g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
-    info = EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, window,
-                                              get_icon, (window, slot));
-
-    icon_name = NULL;
-    if (info) {
-        icon_name = nautilus_icon_info_get_used_name (info);
-        if (icon_name != NULL) {
-            /* Gtk+ doesn't short circuit this (yet), so avoid lots of work
-             * if we're setting to the same icon. This happens a lot e.g. when
-             * the trash directory changes due to the file count changing.
-             */
-            if (g_strcmp0 (icon_name, gtk_window_get_icon_name (GTK_WINDOW (window))) != 0) {			
-                gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
-            }
-        } else {
-            pixbuf = nautilus_icon_info_get_pixbuf_nodefault (info);
-
-            if (pixbuf) {
-                gtk_window_set_icon (GTK_WINDOW (window), pixbuf);
-                g_object_unref (pixbuf);
-            } 
-        }
-
-        g_object_unref (info);
-    }
-}
-#endif
-
-#if 0
-static void
-remove_all (GtkWidget *widget,
-            gpointer data)
-{
-    GtkContainer *container;
-    container = GTK_CONTAINER (data);
-
-    gtk_container_remove (container, widget);
-}
-
-void
-nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *slot)
-{
-    gtk_container_foreach (GTK_CONTAINER (slot->extra_location_widgets),
-                           remove_all,
-                           slot->extra_location_widgets);
-    gtk_widget_hide (slot->extra_location_event_box);
-    gtk_widget_hide (slot->extra_location_separator);
-}
-
-void
-nautilus_window_slot_add_extra_location_widget (NautilusWindowSlot *slot,
-                                                GtkWidget *widget)
-{
-    gtk_box_pack_start (GTK_BOX (slot->extra_location_widgets),
-                        widget, TRUE, TRUE, 0);
-    gtk_widget_show (slot->extra_location_event_box);
-    gtk_widget_show (slot->extra_location_separator);
-}
-
-void
-nautilus_window_slot_add_current_location_to_history_list (NautilusWindowSlot *slot)
-{
-
-    if ((slot->pane->window == NULL || !NAUTILUS_IS_DESKTOP_WINDOW (slot->pane->window)) &&
-        nautilus_add_bookmark_to_history_list (slot->current_location_bookmark)) {
-        nautilus_send_history_list_changed ();
-    }
-}
-#endif
 

=== modified file 'src/marlin-global-preferences.h'
--- src/marlin-global-preferences.h	2011-01-12 02:19:44 +0000
+++ src/marlin-global-preferences.h	2011-04-17 09:37:23 +0000
@@ -1,3 +1,6 @@
+#ifndef H_MARLIN_GLOBAL_PREFERENCES
+#define H_MARLIN_GLOBAL_PREFERENCES
+
 GSettings  *settings;
 
 static gchar *tags_colors[10] = { NULL, "#fce94f", "#fcaf3e", "#997666", "#8ae234", "#729fcf", "#ad7fa8", "#ef2929", "#d3d7cf", "#888a85" };
@@ -9,3 +12,5 @@
 #define MARLIN_PREFERENCES_SIDEBAR_CAT_DEVICES_EXPANDER     "sidebar-cat-devices-expander"
 #define MARLIN_PREFERENCES_SIDEBAR_CAT_NETWORK_EXPANDER     "sidebar-cat-network-expander"
 #define MARLIN_PREFERENCES_CONFIRM_TRASH                    "confirm-trash"
+
+#endif

=== modified file 'src/marlin-window-columns.c'
--- src/marlin-window-columns.c	2011-04-10 21:52:44 +0000
+++ src/marlin-window-columns.c	2011-04-17 09:37:23 +0000
@@ -18,6 +18,7 @@
  */
 
 #include "marlin-window-columns.h"
+#include <gdk/gdkkeysyms.h>
 //#include "gof-directory-async.h"
 //#include "fm-list-view.h"
 #include "fm-columns-view.h"
@@ -39,6 +40,59 @@
     gtk_adjustment_value_changed (hadj);
 }
 
+/**
+ * Handle key release events, like the left and right keys to change the
+ * active column. It is a GObject callback.
+ **/
+static gboolean marlin_window_columns_key_pressed(GtkWidget* box, GdkEventKey* event, MarlinWindowColumns* mwcols)
+{
+    GOFWindowSlot* to_active = NULL;
+    /* The active slot position in the GList where there are all the slots */
+    int active_position = 0;
+    switch(event->keyval)
+    {
+    case GDK_KEY_Left:
+        active_position = g_list_index(mwcols->slot, mwcols->active_slot);
+        /* Get previous file list to grab_focus on it */
+        if(active_position > 0)
+        {
+            to_active = GOF_WINDOW_SLOT(g_list_nth_data(mwcols->slot, active_position-1));
+        }
+        /* If it has been found in the GList mwcols->slot (and if it is not the first) */
+        if(to_active != NULL)
+        {
+            gtk_widget_grab_focus(to_active->view_box);
+            printf("GRAB FOCUS on : %d\n", active_position-1);
+            mwcols->active_slot = to_active;
+        }
+        break;
+
+    case GDK_KEY_Right:
+        active_position = g_list_index(mwcols->slot, mwcols->active_slot);
+        /* Get previous file list to grab_focus on it */
+        if(active_position < g_list_length(mwcols->slot))
+        {
+            to_active =  GOF_WINDOW_SLOT(g_list_nth_data(mwcols->slot, active_position+1));
+        }
+        if(to_active != NULL)
+        {
+            gtk_widget_grab_focus(to_active->view_box);
+            printf("GRAB FOCUS on : %d\n", active_position+1);
+            mwcols->active_slot = to_active;
+        }
+        break;
+    }
+}
+
+/**
+ * Create a new MarlinWindowColumns
+ *
+ * @param location: a GFile, it is the location where you want start your
+ * MarlinWindowColumns
+ *
+ * @param ctab: TODO: What is it?
+ *
+ **/
 MarlinWindowColumns *
 marlin_window_columns_new (GFile *location, GObject *ctab)
 {
@@ -51,39 +105,13 @@
     GOFWindowSlot *slot = gof_window_slot_new (location, mwcols->ctab);
     slot->mwcols = mwcols;
     mwcols->active_slot = slot;
-
-#if 0
-    gof_window_slot_make_column_view (slot);
-
-    mwcols->colpane = gtk_hbox_new (FALSE, 0);
-    slot->colpane = mwcols->colpane;
-    gtk_widget_show (mwcols->colpane);
-    mwcols->view_box = gtk_scrolled_window_new (0, 0);
-    GtkWidget *viewport = gtk_viewport_new (0, 0);
-    gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
-    gtk_container_add (GTK_CONTAINER (viewport), mwcols->colpane);
-    gtk_widget_show (viewport);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mwcols->view_box),
-                                    GTK_POLICY_AUTOMATIC,
-                                    GTK_POLICY_NEVER);
-    gtk_widget_show (mwcols->view_box);
-    gtk_container_add (GTK_CONTAINER (mwcols->view_box), viewport);
-
-    GtkAdjustment *hadj;
-    hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (slot->mwcols->view_box));
-
-    /* autoscroll Miller Columns */
-    g_signal_connect(hadj, "changed", (GCallback) hadj_changed, mwcols);
-
-    gof_window_column_add(slot, slot->view_box);
-
-    //gtk_container_add( GTK_CONTAINER(window), mwcols->view_box);
-    //marlin_view_window_set_content (window, mwcols->view_box);
-    marlin_view_view_container_set_content (ctab, mwcols->view_box);
-#endif
+    mwcols->slot = g_list_append(mwcols->slot, slot);
     return mwcols;
 }
 
+/**
+ * TODO: doc
+ **/
 void
 marlin_window_columns_make_view (MarlinWindowColumns *mwcols)
 {
@@ -113,11 +141,24 @@
 
     gof_window_column_add(slot, slot->view_box);
 
-    //gtk_container_add( GTK_CONTAINER(window), mwcols->view_box);
-    //marlin_view_window_set_content (window, mwcols->view_box);
     marlin_view_view_container_set_content (mwcols->ctab, mwcols->view_box);
+    
+    /* Left/Right events */
+    gtk_widget_add_events (GTK_WIDGET(mwcols->colpane), GDK_KEY_RELEASE_MASK);
+    g_signal_connect(mwcols->colpane, "key_release_event", (GCallback)marlin_window_columns_key_pressed, mwcols);
 }
 
+/**
+ * Add a new column
+ **/
+void
+marlin_window_columns_add_location (MarlinWindowColumns *mwcols, GFile *location)
+{
+    gof_window_columns_add_location(mwcols->active_slot, location);
+}
+/**
+ * Add a new column
+ **/
 void
 marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location)
 {
@@ -125,119 +166,30 @@
     gof_window_slot_make_column_view (slot);
     slot->mwcols = mwcols;
     slot->colpane = mwcols->active_slot->colpane;
+    gof_window_column_add(slot, slot->view_box);
     //mwcols->active_slot = slot;
-    //add_column(mwcols, slot->view_box);
-    gof_window_column_add(slot, slot->view_box);
+    /* Add it in our GList */
+    mwcols->slot = g_list_append(mwcols->slot, slot);
+    //gtk_widget_grab_focus(slot->view_box);
 }
 
 static void
 marlin_window_columns_init (MarlinWindowColumns *mwcol)
 {
-#if 0
-    GtkWidget *content_box, *eventbox, *extras_vbox, *frame, *hsep;
-
-    content_box = gtk_vbox_new (FALSE, 0);
-    slot->content_box = content_box;
-    gtk_widget_show (content_box);
-
-    frame = gtk_frame_new (NULL);
-    gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
-    gtk_box_pack_start (GTK_BOX (content_box), frame, TRUE, TRUE, 0);
-    gtk_widget_show (frame);
-
-    slot->view_box = gtk_vbox_new (FALSE, 0);
-    gtk_container_add (GTK_CONTAINER (frame), slot->view_box);
-    gtk_widget_show (slot->view_box);
-#endif
-    //slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW, NULL));
-    /*slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_LIST_VIEW,
-      "window-slot", slot, NULL));*/
-    //gtk_box_pack_start (GTK_BOX (slot->content_box), GTK_WIDGET (slot->list_view->tree), TRUE, TRUE, 0);
-
-
-    /*GtkWidget *m_scwin;
-      m_scwin = gtk_scrolled_window_new(NULL,NULL);
-      slot->content_box = m_scwin;
-      gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_scwin), GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC);
-      gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_scwin), GTK_SHADOW_NONE);*/
-
-    //gtk_container_add( GTK_CONTAINER(m_scwin), GTK_WIDGET (slot->list_view->tree));
-
-
-#if 0
-    eventbox = gtk_event_box_new ();
-    slot->extra_location_event_box = eventbox;
-    gtk_widget_set_name (eventbox, "nautilus-extra-view-widget");
-    gtk_box_pack_start (GTK_BOX (slot->view_box), eventbox, FALSE, FALSE, 0);
-
-    extras_vbox = gtk_vbox_new (FALSE, 6);
-    gtk_container_set_border_width (GTK_CONTAINER (extras_vbox), 6);
-    slot->extra_location_widgets = extras_vbox;
-    gtk_container_add (GTK_CONTAINER (eventbox), extras_vbox);
-    gtk_widget_show (extras_vbox);
-
-    hsep = gtk_hseparator_new ();
-    gtk_box_pack_start (GTK_BOX (slot->view_box), hsep, FALSE, FALSE, 0);
-    slot->extra_location_separator = hsep;
-
-    slot->title = g_strdup (_("Loading..."));
-#endif
 }
 
 static void
 marlin_window_columns_class_init (MarlinWindowColumnsClass *class)
 {
-    /*class->active = real_active;
-      class->inactive = real_inactive;
-      class->update_query_editor = real_update_query_editor; */
-
     G_OBJECT_CLASS (class)->finalize = marlin_window_columns_finalize;
 }
 
-/*GOFWindowSlot *
-  marlin_window_columns_get_active_slot (MarlinWindowColumns *mwcols)
-  {
-  return (mwcols->active_slot);
-  }*/
-
 GFile *
 marlin_window_columns_get_location (MarlinWindowColumns *mwcols)
 {
     return mwcols->location;
 }
 
-#if 0
-void
-nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *slot)
-{
-    gtk_container_foreach (GTK_CONTAINER (slot->extra_location_widgets),
-                           remove_all,
-                           slot->extra_location_widgets);
-    gtk_widget_hide (slot->extra_location_event_box);
-    gtk_widget_hide (slot->extra_location_separator);
-}
-
-void
-nautilus_window_slot_add_extra_location_widget (NautilusWindowSlot *slot,
-                                                GtkWidget *widget)
-{
-    gtk_box_pack_start (GTK_BOX (slot->extra_location_widgets),
-                        widget, TRUE, TRUE, 0);
-    gtk_widget_show (slot->extra_location_event_box);
-    gtk_widget_show (slot->extra_location_separator);
-}
-
-void
-nautilus_window_slot_add_current_location_to_history_list (NautilusWindowSlot *slot)
-{
-
-    if ((slot->pane->window == NULL || !NAUTILUS_IS_DESKTOP_WINDOW (slot->pane->window)) &&
-        nautilus_add_bookmark_to_history_list (slot->current_location_bookmark)) {
-        nautilus_send_history_list_changed ();
-    }
-}
-#endif
-
 static void
 marlin_window_columns_finalize (GObject *object)
 {
@@ -247,39 +199,5 @@
     g_object_unref(mwcols->location);
 
     G_OBJECT_CLASS (parent_class)->finalize (object);
-
-#if 0
-    GtkWidget *widget;
-
-    if (slot->content_view) {
-        widget = nautilus_view_get_widget (slot->content_view);
-        gtk_widget_destroy (widget);
-        g_object_unref (slot->content_view);
-        slot->content_view = NULL;
-    }
-
-    if (slot->new_content_view) {
-        widget = nautilus_view_get_widget (slot->new_content_view);
-        gtk_widget_destroy (widget);
-        g_object_unref (slot->new_content_view);
-        slot->new_content_view = NULL;
-    }
-
-    nautilus_window_slot_set_viewed_file (slot, NULL);
-    /* TODO? why do we unref here? the file is NULL.
-     * It was already here before the slot move, though */
-    nautilus_file_unref (slot->viewed_file);
-
-
-    eel_g_list_free_deep (slot->pending_selection);
-    slot->pending_selection = NULL;
-
-    g_free (slot->title);
-    slot->title = NULL;
-
-    g_free (slot->status_text);
-    slot->status_text = NULL;
-#endif
-    //G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 

=== modified file 'src/marlin-window-columns.h'
--- src/marlin-window-columns.h	2010-12-26 08:20:50 +0000
+++ src/marlin-window-columns.h	2011-04-17 09:37:23 +0000
@@ -107,11 +107,8 @@
 
 MarlinWindowColumns     *marlin_window_columns_new (GFile *location, GObject *ctab);
 void                    marlin_window_columns_make_view (MarlinWindowColumns *mwcols);
-//void                    marlin_window_columns_change_location (GOFWindowSlot *slot, GFile *location);
 
 void                    marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location);
 GFile                   *marlin_window_columns_get_location (MarlinWindowColumns *mwcol);
-//GOFWindowSlot   *marlin_window_columns_get_active_slot (MarlinWindowColumns *mwcols);
-void                    marlin_window_columns_change_location (GOFWindowSlot *slot, GFile *location);
 
 #endif /* MARLIN_WINDOW_COLUMNS_H */

=== added directory 'src/tests'
=== added file 'src/tests/Makefile.am'
--- src/tests/Makefile.am	1970-01-01 00:00:00 +0000
+++ src/tests/Makefile.am	2011-04-17 09:37:23 +0000
@@ -0,0 +1,1 @@
+

=== added file 'src/tests/marlintests.c'
--- src/tests/marlintests.c	1970-01-01 00:00:00 +0000
+++ src/tests/marlintests.c	2011-04-17 09:37:23 +0000
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011, Lucas Baudin <[email protected]>
+ *
+ * Marlin 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.
+ *
+ * Marlin is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glib.h>
+#include "marlin-window-columns.h"
+#include "marlin-global-preferences.h"
+#include "tests/mwc_tests.h"
+
+int main (int argc, char* argv[])
+{
+    g_type_init ();
+    g_thread_init (NULL);
+    gtk_test_init (&argc, &argv);
+
+    settings = g_settings_new ("org.gnome.marlin.preferences");
+    
+    /* FIXME: tags should be initialized. */
+    //tags = marlin_view_tags_new ();
+
+    g_test_add_func("/marlin/marlin_window_columns", marlin_window_columns_tests);
+    return g_test_run();
+}

=== added file 'src/tests/mwc_tests.c'
--- src/tests/mwc_tests.c	1970-01-01 00:00:00 +0000
+++ src/tests/mwc_tests.c	2011-04-17 09:37:23 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011, Lucas Baudin <[email protected]>
+ *
+ * Marlin 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.
+ *
+ * Marlin is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "tests/mwc_tests.h"
+
+static gboolean marlin_mwc_fatal_handler(const gchar* log_domain,
+                               GLogLevelFlags log_level,
+                               const gchar* message,
+                               gpointer user_data)
+{
+    return FALSE;
+}
+
+void marlin_window_columns_tests(void)
+{
+    MarlinViewWindow* win;
+    MarlinViewViewContainer* view_container;
+    MarlinWindowColumns* mwcols;
+    GFile* location;
+
+    /* Init the main windows (it shouldn't be required, FIXME)
+     * This code is used to enable warnings, it shouldn't be required either :( */
+    g_test_log_set_fatal_handler(marlin_mwc_fatal_handler, NULL);
+    win = marlin_view_window_new();
+    view_container = marlin_view_view_container_new(win, g_file_new_for_path("/usr/"));
+
+    g_assert(win != NULL);
+
+    mwcols = marlin_window_columns_new(g_file_new_for_path("/usr/"), view_container);
+    location = marlin_window_columns_get_location(mwcols);
+    g_assert_cmpstr(g_file_get_path(location), ==, "/usr");
+
+    marlin_window_columns_make_view(mwcols);
+
+    /* GOFWindowSlot */
+
+    GOFWindowSlot* gof = gof_window_slot_new(g_file_new_for_path("/home/"), NULL);
+
+    /* Check if the two functions returns the same result */
+    g_assert_cmpstr(gof_window_slot_get_location_uri(gof), ==, "file:///home");
+    g_assert_cmpstr(g_file_get_path(gof_window_slot_get_location(gof)), ==, "/home");
+
+    g_assert_cmpint(g_list_length(mwcols->slot), ==, 1);
+
+    /* Add new slots to the MWC */
+    marlin_window_columns_add_location(mwcols, g_file_new_for_path("/usr/share"));
+    g_assert_cmpstr(g_file_get_path(marlin_window_columns_get_location(mwcols)),
+                                    ==,
+                                    "/usr");
+ 
+    g_assert_cmpint(g_list_length(mwcols->slot), ==, 2);
+}

=== added file 'src/tests/mwc_tests.h'
--- src/tests/mwc_tests.h	1970-01-01 00:00:00 +0000
+++ src/tests/mwc_tests.h	2011-04-17 09:37:23 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011, Lucas Baudin <[email protected]>
+ *
+ * Marlin 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.
+ *
+ * Marlin is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef H_TESTS_MWC_TESTS
+#define H_TESTS_MWC_TESTS
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glib.h>
+#include "marlin-window-columns.h"
+#include "marlin-global-preferences.h"
+#include "marlin-vala.h"
+
+void marlin_window_columns_tests(void);
+
+#endif

_______________________________________________
Mailing list: https://launchpad.net/~elementaryweb
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~elementaryweb
More help   : https://help.launchpad.net/ListHelp

Reply via email to