2000-05-19 02:24:39 +00:00
|
|
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
|
|
|
|
|
|
|
/* nautilus-keep-last-vertical-box.c: Subclass of GtkVBox that clips off
|
|
|
|
items that don't fit, except the last one.
|
|
|
|
|
|
|
|
Copyright (C) 2000 Eazel, Inc.
|
|
|
|
|
|
|
|
The Gnome 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 Gnome 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 Gnome Library; see the file COPYING.LIB. If not,
|
|
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Author: John Sullivan <sullivan@eazel.com>,
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "nautilus-keep-last-vertical-box.h"
|
|
|
|
|
2001-04-04 00:07:15 +00:00
|
|
|
#include <eel/eel-gtk-macros.h>
|
2000-05-19 02:24:39 +00:00
|
|
|
|
2001-10-28 20:21:52 +00:00
|
|
|
static void nautilus_keep_last_vertical_box_class_init (NautilusKeepLastVerticalBoxClass *class);
|
|
|
|
static void nautilus_keep_last_vertical_box_init (NautilusKeepLastVerticalBox *box);
|
2000-05-19 02:24:39 +00:00
|
|
|
static void nautilus_keep_last_vertical_box_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
|
2001-11-04 02:07:34 +00:00
|
|
|
EEL_CLASS_BOILERPLATE (NautilusKeepLastVerticalBox, nautilus_keep_last_vertical_box, GTK_TYPE_VBOX)
|
2000-05-19 02:24:39 +00:00
|
|
|
|
|
|
|
/* Standard class initialization function */
|
|
|
|
static void
|
2001-10-28 20:21:52 +00:00
|
|
|
nautilus_keep_last_vertical_box_class_init (NautilusKeepLastVerticalBoxClass *klass)
|
2000-05-19 02:24:39 +00:00
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
widget_class = (GtkWidgetClass *) klass;
|
|
|
|
|
|
|
|
widget_class->size_allocate = nautilus_keep_last_vertical_box_size_allocate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Standard object initialization function */
|
|
|
|
static void
|
2001-10-28 20:21:52 +00:00
|
|
|
nautilus_keep_last_vertical_box_init (NautilusKeepLastVerticalBox *box)
|
2000-05-19 02:24:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* nautilus_keep_last_vertical_box_new:
|
|
|
|
*
|
|
|
|
* Create a new vertical box that clips off items from the end that don't
|
|
|
|
* fit, except the last item, which is always kept. When packing this widget
|
|
|
|
* into another vbox, use TRUE for expand and TRUE for fill or this class's
|
|
|
|
* special clipping magic won't work because this widget's allocation might
|
|
|
|
* be larger than the available space.
|
|
|
|
*
|
|
|
|
* @spacing: Vertical space between items.
|
|
|
|
*
|
|
|
|
* Return value: A new NautilusKeepLastVerticalBox
|
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
nautilus_keep_last_vertical_box_new (gint spacing)
|
|
|
|
{
|
|
|
|
NautilusKeepLastVerticalBox *box;
|
|
|
|
|
Fixed bug bug 3264 (Tree view shows no branches for directories,
...HACK... nodes visible), bug 3290 (changing directory or
refreshing causes Gdk to assert), bug 2420 (Need to free original
key when removing model node), and other assorted problems.
* components/tree/nautilus-tree-view.c: (insert_hack_node),
(remove_hack_node), (nautilus_tree_view_insert_model_node):
Fix problem where the hash table key was neither g_strdup'd on the
way in, nor g_free'd on the way out. This caused all the problems
with bad nesting in the tree view.
* nautilus-installer/src/installer.c: (create_pixmap):
* src/file-manager/fm-list-view.c: (install_row_images):
* src/nautilus-theme-selector.c: (add_theme):
Added more checks for NULL before calling gdk_bitmap_unref.
* src/file-manager/fm-directory-view.c: (no_items_showing):
Fixed a NautilusDirectory ref. count leak.
* libnautilus-extensions/nautilus-font-factory.c:
(unref_global_font_factory), (nautilus_get_current_font_factory):
Unref the font factory on exit.
(nautilus_font_factory_initialize_class), (font_hash_node_free),
(free_one_hash_node), (destroy): Added code to actually destroy
the font factory.
(unref_fixed_font), (nautilus_font_factory_get_fallback_font):
Unref the fixed font on exit.
* libnautilus-extensions/nautilus-volume-monitor.c:
(unref_global_volume_monitor), (nautilus_volume_monitor_get):
Unref the volume monitor on exit.
* src/nautilus-signaller.c: (unref_global_signaller),
(nautilus_signaller_get_current): Unref the signaller on exit.
* src/nautilus-component-adapter-factory.c:
(nautilus_component_adapter_factory_initialize): Replaced some
strange FIXMEs with a simpler one.
(nautilus_component_adapter_factory_destroy): Fix a CORBA object
reference leak.
(nautilus_component_adapter_factory_get): Did a ref/sink.
* components/adapter/nautilus-adapter-control-embed-strategy.c:
(nautilus_adapter_control_embed_strategy_new):
* components/adapter/nautilus-adapter-embeddable-embed-strategy.c:
(nautilus_adapter_embeddable_embed_strategy_new):
* components/adapter/nautilus-adapter-file-load-strategy.c:
(nautilus_adapter_file_load_strategy_new):
* components/adapter/nautilus-adapter-progressive-load-strategy.c:
(nautilus_adapter_progressive_load_strategy_new):
* components/adapter/nautilus-adapter-stream-load-strategy.c:
(nautilus_adapter_stream_load_strategy_new):
* components/adapter/nautilus-adapter.c: (nautilus_adapter_new):
* components/rpmview/nautilus-rpm-verify-window.c:
(nautilus_rpm_verify_window_new):
* components/services/install/lib/eazel-install-object.c:
(eazel_install_new), (eazel_install_new_with_config):
* components/services/time/service/trilobite-eazel-time-service.c:
(trilobite_eazel_time_service_new):
* components/services/trilobite/libtrilobite/trilobite-service-pass
wordquery.c: (trilobite_passwordquery_new):
* components/services/trilobite/libtrilobite/trilobite-service.c:
(trilobite_service_new):
* components/tree/nautilus-tree-expansion-state.c:
(nautilus_tree_expansion_state_new):
* components/tree/nautilus-tree-model.c: (nautilus_tree_model_new):
* components/tree/nautilus-tree-node.c: (nautilus_tree_node_new):
* cut-n-paste-code/widgets/e-paned/e-hpaned.c: (e_hpaned_new):
* cut-n-paste-code/widgets/e-paned/e-vpaned.c: (e_vpaned_new):
* libnautilus-extensions/bonobo-stream-vfs.c:
(bonobo_stream_create):
* libnautilus-extensions/nautilus-any-width-bin.c:
(nautilus_any_width_bin_new):
* libnautilus-extensions/nautilus-background.c:
(nautilus_background_new):
* libnautilus-extensions/nautilus-bookmark.c:
(nautilus_bookmark_new_with_icon):
* libnautilus-extensions/nautilus-caption-table.c:
(nautilus_caption_table_new):
* libnautilus-extensions/nautilus-caption.c:
(nautilus_caption_new):
* libnautilus-extensions/nautilus-directory.c:
(nautilus_directory_new):
* libnautilus-extensions/nautilus-druid-page-eazel.c:
(nautilus_druid_page_eazel_new),
(nautilus_druid_page_eazel_new_with_vals):
* libnautilus-extensions/nautilus-druid.c: (nautilus_druid_new):
* libnautilus-extensions/nautilus-entry.c: (nautilus_entry_new):
* libnautilus-extensions/nautilus-file-operations-progress.c:
(nautilus_file_operations_progress_new):
* libnautilus-extensions/nautilus-file.c:
(nautilus_file_new_from_name), (nautilus_file_new_from_info):
* libnautilus-extensions/nautilus-font-picker.c:
(nautilus_font_picker_new):
* libnautilus-extensions/nautilus-horizontal-splitter.c:
(nautilus_horizontal_splitter_new):
* libnautilus-extensions/nautilus-icon-container.c:
(nautilus_icon_container_new):
* libnautilus-extensions/nautilus-icon-factory.c:
(get_icon_factory):
* libnautilus-extensions/nautilus-image.c: (nautilus_image_new):
* libnautilus-extensions/nautilus-keep-last-vertical-box.c:
(nautilus_keep_last_vertical_box_new):
* libnautilus-extensions/nautilus-label.c: (nautilus_label_new):
* libnautilus-extensions/nautilus-list-column-title.c:
(nautilus_list_column_title_new):
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_new_with_titles):
* libnautilus-extensions/nautilus-password-dialog.c:
(nautilus_password_dialog_new):
* libnautilus-extensions/nautilus-preference.c:
(nautilus_preference_new_from_type):
* libnautilus-extensions/nautilus-preferences-box.c:
(nautilus_preferences_box_new):
* libnautilus-extensions/nautilus-preferences-dialog.c:
(nautilus_preferences_dialog_new):
* libnautilus-extensions/nautilus-preferences-group.c:
(nautilus_preferences_group_new):
* libnautilus-extensions/nautilus-preferences-item.c:
(nautilus_preferences_item_new):
* libnautilus-extensions/nautilus-preferences-pane.c:
(nautilus_preferences_pane_new):
* libnautilus-extensions/nautilus-radio-button-group.c:
(nautilus_radio_button_group_new):
* libnautilus-extensions/nautilus-scalable-font.c:
(nautilus_scalable_font_new):
* libnautilus-extensions/nautilus-string-picker.c:
(nautilus_string_picker_new):
* libnautilus-extensions/nautilus-text-caption.c:
(nautilus_text_caption_new):
* libnautilus-extensions/nautilus-undo-context.c:
(nautilus_undo_context_new):
* libnautilus-extensions/nautilus-undo-manager.c:
(nautilus_undo_manager_new):
* libnautilus-extensions/nautilus-user-level-manager.c:
(user_level_manager_new):
* libnautilus/nautilus-undo-transaction.c:
(nautilus_undo_transaction_new):
* libnautilus/nautilus-view.c:
(nautilus_view_new_from_bonobo_control):
* src/file-manager/nautilus-trash-monitor.c:
(nautilus_trash_monitor_get):
* src/nautilus-desktop-window.c: (nautilus_desktop_window_new):
* src/nautilus-property-browser.c: (nautilus_property_browser_new):
* src/nautilus-shell.c: (nautilus_shell_new):
* src/nautilus-sidebar-tabs.c: (nautilus_sidebar_tabs_new):
* src/nautilus-sidebar-title.c: (nautilus_sidebar_title_new):
* src/nautilus-sidebar.c: (nautilus_sidebar_create_context_menu),
(nautilus_sidebar_new):
* src/nautilus-theme-selector.c: (nautilus_theme_selector_new):
* src/nautilus-throbber.c: (nautilus_throbber_new):
* src/nautilus-view-frame.c: (nautilus_view_frame_new):
* src/nautilus-zoom-control.c: (nautilus_zoom_control_new):
* src/nautilus-about.c: (nautilus_about_new):
* src/nautilus-application.c: (nautilus_application_new),
(nautilus_application_create_window):
* src/nautilus-bookmark-list.c: (nautilus_bookmark_list_new):
After Tim Janik explained that gtk_type_new is a low-level call to
be avoided, changed most uses of gtk_type_new to gtk_object_new or
gtk_widget_new. Also, after Owen and Havoc explained that you
can't just ignore the floating bit, added ref/sink calls to the
functions used to create objects where we don't use the floating
scheme.
* src/nautilus-zoom-control.c:
(nautilus_zoom_control_button_press_event): Take advantage of the
fact that the new menu is floating and don't bother with ref'ing.
* libnautilus-extensions/nautilus-ctree.c:
(nautilus_ctree_new_with_titles):
Added a cast.
* components/adapter/main.c: (adapter_factory_make_object):
* components/hardware/main.c: (hardware_view_make_object):
* components/services/install/lib/eazel-install-corba-callback.c:
(eazel_install_callback_get_type), (eazel_install_callback_new):
* libnautilus-extensions/nautilus-theme.c:
(nautilus_theme_get_theme), (nautilus_theme_set_theme),
(nautilus_theme_get_theme_data):
Whitespace tweaks.
2000-09-26 00:52:22 +00:00
|
|
|
box = NAUTILUS_KEEP_LAST_VERTICAL_BOX (gtk_widget_new (nautilus_keep_last_vertical_box_get_type (), NULL));
|
2000-05-19 02:24:39 +00:00
|
|
|
|
|
|
|
GTK_BOX (box)->spacing = spacing;
|
2000-05-19 17:24:57 +00:00
|
|
|
|
|
|
|
/* If homogeneous is TRUE and there are too many items to fit
|
|
|
|
* naturally, they will be squashed together to fit in the space.
|
|
|
|
* We want the ones that don't fit to be not shown at all, so
|
|
|
|
* we set homogeneous to FALSE.
|
|
|
|
*/
|
2000-05-19 02:24:39 +00:00
|
|
|
GTK_BOX (box)->homogeneous = FALSE;
|
|
|
|
|
|
|
|
return GTK_WIDGET (box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nautilus_keep_last_vertical_box_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
GtkBox *box;
|
|
|
|
GtkBoxChild *last_child, *child;
|
|
|
|
GList *children;
|
|
|
|
GtkAllocation last_child_allocation, child_allocation, tiny_allocation;
|
|
|
|
|
|
|
|
g_return_if_fail (NAUTILUS_IS_KEEP_LAST_VERTICAL_BOX (widget));
|
|
|
|
g_return_if_fail (allocation != NULL);
|
|
|
|
|
2001-04-04 00:07:15 +00:00
|
|
|
EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
|
2000-05-19 02:24:39 +00:00
|
|
|
|
|
|
|
box = GTK_BOX (widget);
|
|
|
|
children = g_list_last (box->children);
|
|
|
|
|
|
|
|
if (children != NULL) {
|
|
|
|
last_child = children->data;
|
|
|
|
children = children->prev;
|
|
|
|
|
|
|
|
last_child_allocation = last_child->widget->allocation;
|
|
|
|
|
|
|
|
/* If last child doesn't fit vertically, prune items from the end of the
|
|
|
|
* list one at a time until it does.
|
|
|
|
*/
|
|
|
|
if (last_child_allocation.y + last_child_allocation.height >
|
|
|
|
allocation->y + allocation->height) {
|
|
|
|
|
|
|
|
while (children != NULL) {
|
|
|
|
child = children->data;
|
|
|
|
children = children->prev;
|
|
|
|
|
|
|
|
child_allocation = child->widget->allocation;
|
|
|
|
|
2000-05-19 17:24:57 +00:00
|
|
|
/* Reallocate this child's position so that it does not appear.
|
2000-05-19 02:24:39 +00:00
|
|
|
* Setting the width & height to 0 is not enough, as
|
|
|
|
* one pixel is still drawn. Must also move it outside
|
2000-05-19 17:24:57 +00:00
|
|
|
* visible range. For the cases I've seen, -1, -1 works fine.
|
|
|
|
* This might not work in all future cases. Alternatively, the
|
|
|
|
* items that don't fit could be hidden, but that would interfere
|
|
|
|
* with having other hidden children.
|
|
|
|
*
|
|
|
|
* Note that these children are having their size allocated twice,
|
|
|
|
* once by gtk_vbox_size_allocate and then again here. I don't
|
|
|
|
* know of any problems with this, but holler if you do.
|
2000-05-19 02:24:39 +00:00
|
|
|
*/
|
|
|
|
tiny_allocation.x = tiny_allocation.y = -1;
|
|
|
|
tiny_allocation.height = tiny_allocation.width = 0;
|
|
|
|
gtk_widget_size_allocate (child->widget, &tiny_allocation);
|
|
|
|
|
|
|
|
/* We're done if the special last item fits now. */
|
|
|
|
if (child_allocation.y + last_child_allocation.height <=
|
|
|
|
allocation->y + allocation->height) {
|
|
|
|
last_child_allocation.y = child_allocation.y;
|
|
|
|
gtk_widget_size_allocate (last_child->widget, &last_child_allocation);
|
|
|
|
break;
|
|
|
|
}
|
2000-05-19 17:24:57 +00:00
|
|
|
|
|
|
|
/* If the special last item still doesn't fit, but we've
|
|
|
|
* run out of earlier items, then the special last item is
|
|
|
|
* just too darn tall. Let's squash it down to fit in the box's
|
|
|
|
* allocation.
|
|
|
|
*/
|
|
|
|
if (children == NULL) {
|
|
|
|
last_child_allocation.y = allocation->y;
|
|
|
|
last_child_allocation.height = allocation->height;
|
|
|
|
gtk_widget_size_allocate (last_child->widget, &last_child_allocation);
|
|
|
|
}
|
2000-05-19 02:24:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|