From aa6696e05a7c2614eccde660bf06554735ace3e2 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 01:43:35 +0200 Subject: [horizontal-splitter] remove, and use a regular GtkPaned instead The feature it was bringing in (shrink when the paned handle is double-clicked) is even confusing. http://git.gnome.org/browse/nautilus/commit/?id=1620bd8a4e4ab1760c5c518dd954a4471645ce87 --- libcaja-private/Makefile.am | 2 - libcaja-private/caja-horizontal-splitter.c | 307 ----------------------------- libcaja-private/caja-horizontal-splitter.h | 76 ------- src/caja-navigation-window.c | 8 +- src/caja-spatial-window.c | 1 - src/caja-window.c | 1 - 6 files changed, 4 insertions(+), 391 deletions(-) delete mode 100644 libcaja-private/caja-horizontal-splitter.c delete mode 100644 libcaja-private/caja-horizontal-splitter.h diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am index cbf91983..55cadeee 100644 --- a/libcaja-private/Makefile.am +++ b/libcaja-private/Makefile.am @@ -105,8 +105,6 @@ libcaja_private_la_SOURCES = \ caja-file.h \ caja-global-preferences.c \ caja-global-preferences.h \ - caja-horizontal-splitter.c \ - caja-horizontal-splitter.h \ caja-icon-canvas-item.c \ caja-icon-canvas-item.h \ caja-icon-container.c \ diff --git a/libcaja-private/caja-horizontal-splitter.c b/libcaja-private/caja-horizontal-splitter.c deleted file mode 100644 index 0fbaa3c4..00000000 --- a/libcaja-private/caja-horizontal-splitter.c +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* caja-horizontal-splitter.c - A horizontal splitter with a semi gradient look - - Copyright (C) 1999, 2000 Eazel, Inc. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Ramiro Estrugo -*/ - -#include -#include "caja-horizontal-splitter.h" - -#include -#include - -struct CajaHorizontalSplitterDetails -{ - guint32 press_time; - int press_position; - int saved_size; -}; - -#define CLOSED_THRESHOLD 4 -#define NOMINAL_SIZE 148 -#define SPLITTER_CLICK_SLOP 4 -#define SPLITTER_CLICK_TIMEOUT 400 - -static void caja_horizontal_splitter_class_init (CajaHorizontalSplitterClass *horizontal_splitter_class); -static void caja_horizontal_splitter_init (CajaHorizontalSplitter *horizontal_splitter); - -EEL_CLASS_BOILERPLATE (CajaHorizontalSplitter, - caja_horizontal_splitter, - GTK_TYPE_HPANED) - -static void -caja_horizontal_splitter_init (CajaHorizontalSplitter *horizontal_splitter) -{ - horizontal_splitter->details = g_new0 (CajaHorizontalSplitterDetails, 1); -} - -static void -caja_horizontal_splitter_finalize (GObject *object) -{ - CajaHorizontalSplitter *horizontal_splitter; - - horizontal_splitter = CAJA_HORIZONTAL_SPLITTER (object); - - g_free (horizontal_splitter->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - -static void -splitter_expand (CajaHorizontalSplitter *splitter, int position) -{ - g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - if (position >= CLOSED_THRESHOLD) - { - return; - } - - position = splitter->details->saved_size; - if (position < CLOSED_THRESHOLD) - { - position = NOMINAL_SIZE; - } - - gtk_paned_set_position (GTK_PANED (splitter), position); -} - -static void -splitter_collapse (CajaHorizontalSplitter *splitter, int position) -{ - g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - splitter->details->saved_size = position; - gtk_paned_set_position (GTK_PANED (splitter), 0); -} - -static void -splitter_toggle (CajaHorizontalSplitter *splitter, int position) -{ - g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - if (gtk_paned_get_position (GTK_PANED (splitter)) >= CLOSED_THRESHOLD) - { - caja_horizontal_splitter_collapse (splitter); - } - else - { - caja_horizontal_splitter_expand (splitter); - } -} - -static void -splitter_hide (CajaHorizontalSplitter *splitter) -{ - GtkPaned *parent; - - parent = GTK_PANED (splitter); - - gtk_widget_hide (gtk_paned_get_child1 (parent)); -} - -static void -splitter_show (CajaHorizontalSplitter *splitter) -{ - GtkPaned *parent; - - parent = GTK_PANED (splitter); - - gtk_widget_show (gtk_paned_get_child1 (parent)); -} - -static gboolean -splitter_is_hidden (CajaHorizontalSplitter *splitter) -{ - GtkPaned *parent; - - parent = GTK_PANED (splitter); - - return gtk_widget_get_visible (gtk_paned_get_child1 (parent)); -} - -void -caja_horizontal_splitter_expand (CajaHorizontalSplitter *splitter) -{ - splitter_expand (splitter, gtk_paned_get_position (GTK_PANED (splitter))); -} - -void -caja_horizontal_splitter_hide (CajaHorizontalSplitter *splitter) -{ - splitter_hide (splitter); -} - -void -caja_horizontal_splitter_show (CajaHorizontalSplitter *splitter) -{ - splitter_show (splitter); -} - -gboolean -caja_horizontal_splitter_is_hidden (CajaHorizontalSplitter *splitter) -{ - return splitter_is_hidden (splitter); -} - -void -caja_horizontal_splitter_collapse (CajaHorizontalSplitter *splitter) -{ - splitter_collapse (splitter, gtk_paned_get_position (GTK_PANED (splitter))); -} - -/* routine to toggle the open/closed state of the splitter */ -void -caja_horizontal_splitter_toggle_position (CajaHorizontalSplitter *splitter) -{ - splitter_toggle (splitter, gtk_paned_get_position (GTK_PANED (splitter))); -} - -/* CajaHorizontalSplitter public methods */ -GtkWidget * -caja_horizontal_splitter_new (void) -{ - return gtk_widget_new (caja_horizontal_splitter_get_type (), NULL); -} - -/* handle mouse downs by remembering the position and the time */ -static gboolean -caja_horizontal_splitter_button_press (GtkWidget *widget, GdkEventButton *event) -{ - gboolean result; - CajaHorizontalSplitter *splitter; - int position; - - splitter = CAJA_HORIZONTAL_SPLITTER (widget); - - position = gtk_paned_get_position (GTK_PANED (widget)); - - result = EEL_CALL_PARENT_WITH_RETURN_VALUE - (GTK_WIDGET_CLASS, button_press_event, (widget, event)); - - if (result) - { - splitter->details->press_time = event->time; - splitter->details->press_position = position; - } - - return result; -} - -/* handle mouse ups by seeing if it was a tap and toggling the open state accordingly */ -static gboolean -caja_horizontal_splitter_button_release (GtkWidget *widget, GdkEventButton *event) -{ - gboolean result; - CajaHorizontalSplitter *splitter; - int position, delta, delta_time; - splitter = CAJA_HORIZONTAL_SPLITTER (widget); - - position = gtk_paned_get_position (GTK_PANED (widget)); - - result = EEL_CALL_PARENT_WITH_RETURN_VALUE - (GTK_WIDGET_CLASS, button_release_event, (widget, event)); - - if (result) - { - delta = abs (position - splitter->details->press_position); - delta_time = event->time - splitter->details->press_time; - if (delta < SPLITTER_CLICK_SLOP && delta_time < SPLITTER_CLICK_TIMEOUT) - { - caja_horizontal_splitter_toggle_position (splitter); - } - } - - return result; -} - -static void -caja_horizontal_splitter_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - gint border_width; - GtkPaned *paned; - GtkAllocation child_allocation; - GtkRequisition child_requisition; - - paned = GTK_PANED (widget); - border_width = gtk_container_get_border_width (GTK_CONTAINER (paned)); - - gtk_widget_set_allocation (widget, allocation); - - if (gtk_paned_get_child2 (paned) != NULL && gtk_widget_get_visible (gtk_paned_get_child2 (paned))) - { - EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, - (widget, allocation)); - } - else if (gtk_paned_get_child1 (paned) && gtk_widget_get_visible (gtk_paned_get_child1 (paned))) - { - - if (gtk_widget_get_realized (widget)) - { - gdk_window_hide (gtk_paned_get_handle_window (paned)); - } - - gtk_widget_get_child_requisition (gtk_paned_get_child1 (paned), - &child_requisition); - - child_allocation.x = allocation->x + border_width; - child_allocation.y = allocation->y + border_width; - child_allocation.width = MIN (child_requisition.width, - allocation->width - 2 * border_width); - child_allocation.height = MIN (child_requisition.height, - allocation->height - 2 * border_width); - - gtk_widget_size_allocate (gtk_paned_get_child1 (paned), &child_allocation); - } - else if (gtk_widget_get_realized (widget)) - { - gdk_window_hide (gtk_paned_get_handle_window (paned)); - } - -} - -static void -caja_horizontal_splitter_class_init (CajaHorizontalSplitterClass *class) -{ - GtkWidgetClass *widget_class; - - widget_class = GTK_WIDGET_CLASS (class); - - G_OBJECT_CLASS (class)->finalize = caja_horizontal_splitter_finalize; - - widget_class->size_allocate = caja_horizontal_splitter_size_allocate; - widget_class->button_press_event = caja_horizontal_splitter_button_press; - widget_class->button_release_event = caja_horizontal_splitter_button_release; -} - -void -caja_horizontal_splitter_pack2 (CajaHorizontalSplitter *splitter, - GtkWidget *child2) -{ - GtkPaned *paned; - - g_return_if_fail (GTK_IS_WIDGET (child2)); - g_return_if_fail (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - paned = GTK_PANED (splitter); - gtk_paned_pack2 (paned, child2, TRUE, FALSE); -} diff --git a/libcaja-private/caja-horizontal-splitter.h b/libcaja-private/caja-horizontal-splitter.h deleted file mode 100644 index b0fdcf4a..00000000 --- a/libcaja-private/caja-horizontal-splitter.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* caja-horizontal-splitter.h - A horizontal splitter with a semi gradient look - - Copyright (C) 1999, 2000 Eazel, Inc. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Ramiro Estrugo -*/ - -#ifndef CAJA_HORIZONTAL_SPLITTER_H -#define CAJA_HORIZONTAL_SPLITTER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define CAJA_TYPE_HORIZONTAL_SPLITTER caja_horizontal_splitter_get_type() -#define CAJA_HORIZONTAL_SPLITTER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitter)) -#define CAJA_HORIZONTAL_SPLITTER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitterClass)) -#define CAJA_IS_HORIZONTAL_SPLITTER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER)) -#define CAJA_IS_HORIZONTAL_SPLITTER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), CAJA_TYPE_HORIZONTAL_SPLITTER)) -#define CAJA_HORIZONTAL_SPLITTER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitterClass)) - - typedef struct CajaHorizontalSplitterDetails CajaHorizontalSplitterDetails; - - typedef struct - { - GtkHPaned parent_slot; - CajaHorizontalSplitterDetails *details; - } CajaHorizontalSplitter; - - typedef struct - { - GtkHPanedClass parent_slot; - } CajaHorizontalSplitterClass; - - /* CajaHorizontalSplitter public methods */ - GType caja_horizontal_splitter_get_type (void); - GtkWidget *caja_horizontal_splitter_new (void); - - gboolean caja_horizontal_splitter_is_hidden (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_collapse (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_hide (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_show (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_expand (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_toggle_position (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_pack2 (CajaHorizontalSplitter *splitter, - GtkWidget *child2); - -#ifdef __cplusplus -} -#endif - -#endif /* CAJA_HORIZONTAL_SPLITTER_H */ diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c index 3cddcb26..eba87c47 100644 --- a/src/caja-navigation-window.c +++ b/src/caja-navigation-window.c @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -141,7 +140,7 @@ 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 (); + window->details->content_paned = gtk_hpaned_new (); gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table), window->details->content_paned, /* X direction */ /* Y direction */ @@ -151,7 +150,8 @@ 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); hpaned = gtk_hpaned_new (); @@ -1036,7 +1036,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))); } /** diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index 524fbb9b..5dd3bbce 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include diff --git a/src/caja-window.c b/src/caja-window.c index 27e2852f..14c5d5c4 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.1