Commit d228c0e7 authored by William Jon McCann's avatar William Jon McCann

Fix display sizing of name column

https://bugzilla.gnome.org/show_bug.cgi?id=676898
parent 367f01a9
......@@ -61,8 +61,6 @@ libnautilus_private_la_LIBADD = \
libnautilus_private_la_SOURCES = \
nautilus-bookmark.c \
nautilus-bookmark.h \
nautilus-cell-renderer-text-ellipsized.c \
nautilus-cell-renderer-text-ellipsized.h \
nautilus-clipboard-monitor.c \
nautilus-clipboard-monitor.h \
nautilus-clipboard.c \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-cell-renderer-text-ellipsized.c: Cell renderer for text which
will use pango ellipsization but deactivate it temporarily for the size
calculation to get the size based on the actual text length.
Copyright (C) 2007 Martin Wehner
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Martin Wehner <martin.wehner@gmail.com>
*/
#include "config.h"
#include "nautilus-cell-renderer-text-ellipsized.h"
G_DEFINE_TYPE (NautilusCellRendererTextEllipsized, nautilus_cell_renderer_text_ellipsized,
GTK_TYPE_CELL_RENDERER_TEXT);
static void
nautilus_cell_renderer_text_ellipsized_init (NautilusCellRendererTextEllipsized *cell)
{
g_object_set (cell,
"ellipsize", PANGO_ELLIPSIZE_END,
"ellipsize-set", TRUE,
NULL);
}
static void
nautilus_cell_renderer_text_ellipsized_get_preferred_width (GtkCellRenderer *cell,
GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
g_object_set (cell,
"ellipsize", PANGO_ELLIPSIZE_NONE,
"ellipsize-set", FALSE,
NULL);
GTK_CELL_RENDERER_CLASS
(nautilus_cell_renderer_text_ellipsized_parent_class)->get_preferred_width (cell, widget,
minimum_size, natural_size);
g_object_set (cell,
"ellipsize", PANGO_ELLIPSIZE_END,
"ellipsize-set", TRUE,
NULL);
}
static void
nautilus_cell_renderer_text_ellipsized_class_init (NautilusCellRendererTextEllipsizedClass *klass)
{
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
cell_class->get_preferred_width = nautilus_cell_renderer_text_ellipsized_get_preferred_width;
}
GtkCellRenderer *
nautilus_cell_renderer_text_ellipsized_new (void)
{
return g_object_new (NAUTILUS_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NULL);
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-cell-renderer-text-ellipsized.c: Cell renderer for text which
will use pango ellipsization but deactivate it temporarily for the size
calculation to get the size based on the actual text length.
Copyright (C) 2007 Martin Wehner
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Martin Wehner <martin.wehner@gmail.com>
*/
#ifndef NAUTILUS_CELL_RENDERER_TEXT_ELLIPSIZED_H
#define NAUTILUS_CELL_RENDERER_TEXT_ELLIPSIZED_H
#include <gtk/gtk.h>
#define NAUTILUS_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED nautilus_cell_renderer_text_ellipsized_get_type()
#define NAUTILUS_CELL_RENDERER_TEXT_ELLIPSIZED(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NautilusCellRendererTextEllipsized))
#define NAUTILUS_CELL_RENDERER_TEXT_ELLIPSIZED_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NautilusCellRendererTextEllipsizedClass))
#define NAUTILUS_IS_CELL_RENDERER_TEXT_ELLIPSIZED(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED))
#define NAUTILUS_IS_CELL_RENDERER_TEXT_ELLIPSIZED_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED))
#define NAUTILUS_CELL_RENDERER_TEXT_ELLIPSIZED_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NautilusCellRendererTextEllipsizedClass))
typedef struct _NautilusCellRendererTextEllipsized NautilusCellRendererTextEllipsized;
typedef struct _NautilusCellRendererTextEllipsizedClass NautilusCellRendererTextEllipsizedClass;
struct _NautilusCellRendererTextEllipsized {
GtkCellRendererText parent;
};
struct _NautilusCellRendererTextEllipsizedClass {
GtkCellRendererTextClass parent_class;
};
GType nautilus_cell_renderer_text_ellipsized_get_type (void);
GtkCellRenderer *nautilus_cell_renderer_text_ellipsized_new (void);
#endif /* NAUTILUS_CELL_RENDERER_TEXT_ELLIPSIZED_H */
......@@ -57,7 +57,6 @@
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-tree-view-drag-dest.h>
#include <libnautilus-private/nautilus-clipboard.h>
#include <libnautilus-private/nautilus-cell-renderer-text-ellipsized.h>
#define DEBUG_FLAG NAUTILUS_DEBUG_LIST_VIEW
#include <libnautilus-private/nautilus-debug.h>
......@@ -1666,15 +1665,18 @@ create_and_set_up_tree_view (NautilusListView *view)
gtk_tree_view_column_set_sort_column_id (view->details->file_name_column, column_num);
gtk_tree_view_column_set_title (view->details->file_name_column, _("Name"));
gtk_tree_view_column_set_resizable (view->details->file_name_column, TRUE);
gtk_tree_view_column_set_expand (view->details->file_name_column, TRUE);
gtk_tree_view_column_pack_start (view->details->file_name_column, cell, FALSE);
gtk_tree_view_column_set_attributes (view->details->file_name_column,
cell,
"pixbuf", NAUTILUS_LIST_MODEL_SMALLEST_ICON_COLUMN,
NULL);
cell = nautilus_cell_renderer_text_ellipsized_new ();
cell = gtk_cell_renderer_text_new ();
view->details->file_name_cell = (GtkCellRendererText *)cell;
g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
g_signal_connect (cell, "edited", G_CALLBACK (cell_renderer_edited), view);
g_signal_connect (cell, "editing-canceled", G_CALLBACK (cell_renderer_editing_canceled), view);
g_signal_connect (cell, "editing-started", G_CALLBACK (cell_renderer_editing_started_cb), view);
......@@ -1683,7 +1685,7 @@ create_and_set_up_tree_view (NautilusListView *view)
gtk_tree_view_column_set_cell_data_func (view->details->file_name_column, cell,
(GtkTreeCellDataFunc) filename_cell_data_func,
view, NULL);
} else {
} else {
cell = gtk_cell_renderer_text_new ();
g_object_set (cell, "xalign", xalign, NULL);
view->details->cells = g_list_append (view->details->cells,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment