Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,

2004-10-25  James M. Cape  <jcape@ignore-your.tv>

	Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
	#154390, #154390, #156272.

	* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
	below GtkFileChooser.
	* docs/reference/gtk/gtk-sections.txt: Added
	gtk_file_chooser_button_get_width_chars(),
	gtk_file_chooser_button_set_width_chars(),
	gtk_label_set_width_chars(), gtk_label_get_width_chars().
	* docs/reference/gtk/gtk.types: Added
	gtk_cell_renderer_combo_get_type,
	gtk_cell_view_get_type,
	gtk_text_iter_get_type.
	* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
	"logo-icon-name" property.
	* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
	properties
	(b/c of get_type() inclusion above).
	* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
	* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
	property,
	getters/setters.
	* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
	* gtk/gtkentrycompletion.c:
	(_gtk_entry_completion_popdown): Don't show if the entry isn't
	mapped.
	* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
	rewritten, adds "width-chars" property, icons, working save
	modes, volume/Home/Desktop friendly-naming support.
	* gtk/gtklabel.[c,h]:
	(gtk_label_class_init), (gtk_label_init),
	(gtk_label_get_property), (gtk_label_set_property),
	(gtk_label_get_width_chars), (gtk_label_set_width_chars),
	(gtk_label_size_request): Add "width-chars" property.
	* tests/testfilechooserbutton.c: Update, use 4 different buttons
	for the different ACTIONs.
	* gtk/.cvsignore: Ignore gtk-update-icon-cache.
	* tests/.cvsignore: Ignore testimage.
This commit is contained in:
James M. Cape 2004-10-26 04:29:56 +00:00 committed by James M. Cape
parent 64facb3c4b
commit ede3c39918
20 changed files with 1237 additions and 305 deletions

View File

@ -1,3 +1,42 @@
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars" property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save modes,
volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons for
the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-25 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderercombo.c (find_text): Don't leak text. (#156325,

View File

@ -1,3 +1,42 @@
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars" property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save modes,
volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons for
the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-25 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderercombo.c (find_text): Don't leak text. (#156325,

View File

@ -1,3 +1,42 @@
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars" property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save modes,
volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons for
the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-25 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderercombo.c (find_text): Don't leak text. (#156325,

View File

@ -1,3 +1,42 @@
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars" property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save modes,
volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons for
the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-25 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcellrenderercombo.c (find_text): Don't leak text. (#156325,

View File

@ -444,8 +444,8 @@ that is, GUI components such as <link linkend="GtkButton">GtkButton</link> or
&GtkColorSelection;
&GtkColorSelectionDialog;
&GtkFileSelection;
&GtkFileChooserButton;
&GtkFileChooser;
&GtkFileChooserButton;
&GtkFileChooserDialog;
&GtkFileChooserWidget;
&GtkFileFilter;
@ -599,5 +599,3 @@ that is, GUI components such as <link linkend="GtkButton">GtkButton</link> or
</index>
</book>

View File

@ -1285,6 +1285,8 @@ gtk_file_chooser_button_get_title
gtk_file_chooser_button_set_title
gtk_file_chooser_button_get_active
gtk_file_chooser_button_set_active
gtk_file_chooser_button_get_width_chars
gtk_file_chooser_button_set_width_chars
<SUBSECTION Standard>
GTK_FILE_CHOOSER_BUTTON
GTK_IS_FILE_CHOOSER_BUTTON
@ -1903,6 +1905,7 @@ gtk_label_set_markup_with_mnemonic
gtk_label_set_pattern
gtk_label_set_justify
gtk_label_set_ellipsize
gtk_label_set_width_chars
gtk_label_get
gtk_label_parse_uline
gtk_label_set_line_wrap
@ -1919,6 +1922,7 @@ gtk_label_set_text_with_mnemonic
gtk_label_get_attributes
gtk_label_get_justify
gtk_label_get_ellipsize
gtk_label_get_width_chars
gtk_label_get_label
gtk_label_get_layout
gtk_label_get_line_wrap
@ -5532,4 +5536,3 @@ gtk_icon_factory_get_type
gtk_icon_set_get_type
gtk_icon_source_get_type
</SECTION>

View File

@ -18,10 +18,12 @@ gtk_button_get_type
gtk_calendar_get_type
gtk_cell_layout_get_type
gtk_cell_renderer_get_type
gtk_cell_renderer_combo_get_type
gtk_cell_renderer_pixbuf_get_type
gtk_cell_renderer_text_get_type
gtk_cell_renderer_toggle_get_type
gtk_cell_renderer_progress_get_type
gtk_cell_view_get_type
gtk_check_button_get_type
gtk_check_menu_item_get_type
gtk_clist_get_type
@ -118,6 +120,7 @@ gtk_tearoff_menu_item_get_type
gtk_text_buffer_get_type
gtk_text_child_anchor_get_type
gtk_text_get_type
gtk_text_iter_get_type
gtk_text_mark_get_type
gtk_text_tag_get_type
gtk_text_tag_table_get_type

View File

@ -67,6 +67,11 @@ only private fields and should not be directly accessed.
</para>
<!-- ##### ARG GtkAboutDialog:logo-icon-name ##### -->
<para>
</para>
<!-- ##### ARG GtkAboutDialog:name ##### -->
<para>

View File

@ -0,0 +1,45 @@
<!-- ##### SECTION Title ##### -->
GtkCellRendererCombo
<!-- ##### SECTION Short_Description ##### -->
<!-- ##### SECTION Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GtkCellRendererCombo ##### -->
<para>
</para>
<!-- ##### ARG GtkCellRendererCombo:has-entry ##### -->
<para>
</para>
<!-- ##### ARG GtkCellRendererCombo:model ##### -->
<para>
</para>
<!-- ##### ARG GtkCellRendererCombo:text-column ##### -->
<para>
</para>
<!-- ##### FUNCTION gtk_cell_renderer_combo_new ##### -->
<para>
</para>
@Returns:

View File

@ -19,7 +19,21 @@ A widget displaying a single row of a GtkTreeModel
</para>
@parent_instance:
<!-- ##### ARG GtkCellView:background ##### -->
<para>
</para>
<!-- ##### ARG GtkCellView:background-gdk ##### -->
<para>
</para>
<!-- ##### ARG GtkCellView:background-set ##### -->
<para>
</para>
<!-- ##### FUNCTION gtk_cell_view_new ##### -->
<para>

View File

@ -57,8 +57,9 @@ look like a #GtkButton.
<important>
<para>
The #GtkFileChooserButton will ellipsize the label while in Open mode,
and thus will thus request little horizontal space. To give the dialog
more space, you should call gtk_widget_size_request(), or pack it in
and thus will thus request little horizontal space. To give the button
more space, you should call gtk_widget_size_request(),
gtk_file_chooser_button_set_width_chars (), or pack the button in
such a way that other interface elements give space to the widget.
</para>
</important>
@ -91,6 +92,11 @@ Instance of the #GtkFileChooserDialog associated with the button.
Title to put on the #GtkFileChooserDialog associated with the button.
</para>
<!-- ##### ARG GtkFileChooserButton:width-chars ##### -->
<para>
The width of the entry and label inside the button, in characters.
</para>
<!-- ##### FUNCTION gtk_file_chooser_button_new ##### -->
<para>
@ -155,3 +161,21 @@ Title to put on the #GtkFileChooserDialog associated with the button.
@is_active:
<!-- ##### FUNCTION gtk_file_chooser_button_get_width_chars ##### -->
<para>
</para>
@button:
@Returns:
<!-- ##### FUNCTION gtk_file_chooser_button_set_width_chars ##### -->
<para>
</para>
@button:
@n_chars:

View File

@ -230,6 +230,11 @@ described below.
</para>
<!-- ##### ARG GtkLabel:width-chars ##### -->
<para>
</para>
<!-- ##### ARG GtkLabel:wrap ##### -->
<para>
@ -310,6 +315,15 @@ The pattern of underlines you want under the existing text within the
@mode:
<!-- ##### FUNCTION gtk_label_set_width_chars ##### -->
<para>
</para>
@label:
@n_chars:
<!-- ##### FUNCTION gtk_label_get ##### -->
<para>
Gets the current string of text within the #GtkLabel and writes it to
@ -462,6 +476,15 @@ Gtk+ 1.0.x.
@Returns:
<!-- ##### FUNCTION gtk_label_get_width_chars ##### -->
<para>
</para>
@label:
@Returns:
<!-- ##### FUNCTION gtk_label_get_label ##### -->
<para>

View File

@ -24,3 +24,4 @@ stamp-gtkmarshalers.h
gtk-query-immodules-2.0
.saved
gtkalias.h
gtk-update-icon-cache

View File

@ -1258,7 +1258,10 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
GtkTreePath *path;
gboolean above;
gint width;
if (!completion->priv->entry->window)
return FALSE;
gdk_window_get_origin (completion->priv->entry->window, &x, &y);
_gtk_entry_get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border);
@ -1343,6 +1346,9 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
if (GTK_WIDGET_MAPPED (completion->priv->popup_window))
return;
if (!GTK_WIDGET_MAPPED (completion->priv->entry))
return;
completion->priv->ignore_enter = TRUE;
column = gtk_tree_view_get_column (GTK_TREE_VIEW (completion->priv->action_view), 0);
@ -1358,7 +1364,7 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
_gtk_entry_completion_resize_popup (completion);
gtk_widget_show (completion->priv->popup_window);
gtk_grab_add (completion->priv->popup_window);
gdk_pointer_grab (completion->priv->popup_window->window, TRUE,
GDK_BUTTON_PRESS_MASK |

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,9 @@ void gtk_file_chooser_button_set_title (GtkFileChooserBu
gboolean gtk_file_chooser_button_get_active (GtkFileChooserButton *button);
void gtk_file_chooser_button_set_active (GtkFileChooserButton *button,
gboolean is_active);
gint gtk_file_chooser_button_get_width_chars (GtkFileChooserButton *button);
void gtk_file_chooser_button_set_width_chars (GtkFileChooserButton *button,
gint n_chars);
G_END_DECLS

View File

@ -42,6 +42,14 @@
#include "gtkstock.h"
#include "gtkbindings.h"
#define GTK_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_LABEL, GtkLabelPrivate))
typedef struct
{
gint width_chars;
}
GtkLabelPrivate;
struct _GtkLabelSelectionInfo
{
GdkWindow *window;
@ -71,7 +79,8 @@ enum {
PROP_MNEMONIC_WIDGET,
PROP_CURSOR_POSITION,
PROP_SELECTION_BOUND,
PROP_ELLIPSIZE
PROP_ELLIPSIZE,
PROP_WIDTH_CHARS
};
static guint signals[LAST_SIGNAL] = { 0 };
@ -391,10 +400,10 @@ gtk_label_class_init (GtkLabelClass *class)
*
* Note that setting this property to a value other than %PANGO_ELLIPSIZE_NONE
* has the side-effect that the label requests only enough space to display the
* ellipsis "...". Ellipsizing labels must be packed in a container which
* ensures that the label gets a reasonable size allocated. In particular,
* this means that ellipsizing labels don't work well in notebook tabs, unless
* the tab's ::tab-expand property is set to %TRUE.
* ellipsis "...". In particular, this means that ellipsizing labels don't
* work well in notebook tabs, unless the tab's ::tab-expand property is set
* to %TRUE. Other means to set a label's width are
* gtk_widget_set_size_request() and gtk_label_set_width_chars().
*
* Since: 2.6
*/
@ -406,6 +415,25 @@ gtk_label_class_init (GtkLabelClass *class)
PANGO_TYPE_ELLIPSIZE_MODE,
PANGO_ELLIPSIZE_NONE,
G_PARAM_READWRITE));
/**
* GtkLabel:width-chars:
*
* The desired width of the label, in characters. If this property is set to
* %-1, the width will be calculated automatically, otherwise the label will
* request either 3 characters or the property value, whichever is greater.
*
* Since: 2.6
**/
g_object_class_install_property (gobject_class,
PROP_WIDTH_CHARS,
g_param_spec_int ("width_chars",
P_("Width In Chararacters"),
P_("The desired width of the label, in characters"),
-1,
G_MAXINT,
-1,
G_PARAM_READWRITE));
/*
* Key bindings
@ -483,6 +511,8 @@ gtk_label_class_init (GtkLabelClass *class)
/* copy */
gtk_binding_entry_add_signal (binding_set, GDK_c, GDK_CONTROL_MASK,
"copy_clipboard", 0);
g_type_class_add_private (class, sizeof (GtkLabelPrivate));
}
static void
@ -527,6 +557,9 @@ gtk_label_set_property (GObject *object,
case PROP_ELLIPSIZE:
gtk_label_set_ellipsize (label, g_value_get_enum (value));
break;
case PROP_WIDTH_CHARS:
gtk_label_set_width_chars (label, g_value_get_int (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -595,6 +628,9 @@ gtk_label_get_property (GObject *object,
case PROP_ELLIPSIZE:
g_value_set_enum (value, label->ellipsize);
break;
case PROP_WIDTH_CHARS:
g_value_set_enum (value, gtk_label_get_width_chars (label));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -605,8 +641,13 @@ gtk_label_get_property (GObject *object,
static void
gtk_label_init (GtkLabel *label)
{
GtkLabelPrivate *priv;
GTK_WIDGET_SET_FLAGS (label, GTK_NO_WINDOW);
priv = GTK_LABEL_GET_PRIVATE (label);
priv->width_chars = -1;
label->label = NULL;
label->jtype = GTK_JUSTIFY_LEFT;
@ -1355,6 +1396,52 @@ gtk_label_get_ellipsize (GtkLabel *label)
return label->ellipsize;
}
/**
* gtk_label_set_width_chars:
* @label: a #GtkLabel
* @n_chars: the new desired width, in characters.
*
* Sets the desired width in characters of @label to @n_chars.
*
* Since: 2.6
**/
void
gtk_label_set_width_chars (GtkLabel *label,
gint n_chars)
{
GtkLabelPrivate *priv;
g_return_if_fail (GTK_IS_LABEL (label));
priv = GTK_LABEL_GET_PRIVATE (label);
if (priv->width_chars != n_chars)
{
priv->width_chars = n_chars;
g_object_notify (G_OBJECT (label), "width-chars");
gtk_widget_queue_resize (GTK_WIDGET (label));
}
}
/**
* gtk_label_get_width_chars:
* @label: a #GtkLabel
*
* Retrieves the desired width of @label, in characters. See
* gtk_label_set_width_chars().
*
* Return value: the width of a label in characters.
*
* Since: 2.6
**/
gint
gtk_label_get_width_chars (GtkLabel *label)
{
g_return_val_if_fail (GTK_IS_LABEL (label), -1);
return GTK_LABEL_GET_PRIVATE (label)->width_chars;
}
/**
* gtk_label_set_line_wrap:
* @label: a #GtkLabel
@ -1624,6 +1711,7 @@ gtk_label_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkLabel *label;
GtkLabelPrivate *priv;
gint width, height;
PangoRectangle logical_rect;
GtkWidgetAuxInfo *aux_info;
@ -1632,6 +1720,7 @@ gtk_label_size_request (GtkWidget *widget,
g_return_if_fail (requisition != NULL);
label = GTK_LABEL (widget);
priv = GTK_LABEL_GET_PRIVATE (widget);
/*
* If word wrapping is on, then the height requisition can depend
@ -1657,7 +1746,7 @@ gtk_label_size_request (GtkWidget *widget,
pango_layout_get_extents (label->layout, NULL, &logical_rect);
aux_info = _gtk_widget_get_aux_info (widget, FALSE);
if (label->ellipsize)
if (label->ellipsize || priv->width_chars > 0)
{
PangoContext *context;
PangoFontMetrics *metrics;
@ -1670,7 +1759,7 @@ gtk_label_size_request (GtkWidget *widget,
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
width += (PANGO_PIXELS (char_width) * 3);
width += (PANGO_PIXELS (char_width) * MAX (priv->width_chars, 3));
}
else
{

View File

@ -132,6 +132,9 @@ GtkJustification gtk_label_get_justify (GtkLabel *label);
void gtk_label_set_ellipsize (GtkLabel *label,
PangoEllipsizeMode mode);
PangoEllipsizeMode gtk_label_get_ellipsize (GtkLabel *label);
void gtk_label_set_width_chars (GtkLabel *label,
gint n_chars);
gint gtk_label_get_width_chars (GtkLabel *label);
void gtk_label_set_pattern (GtkLabel *label,
const gchar *pattern);
void gtk_label_set_line_wrap (GtkLabel *label,

View File

@ -24,6 +24,7 @@ testfilechooserbutton
testgtk
testicontheme
testiconview
testimage
testinput
testmenus
testmerge

View File

@ -56,7 +56,7 @@ chooser_current_folder_changed_cb (GtkFileChooser *chooser, gpointer user_data)
folder = gtk_file_chooser_get_current_folder (chooser);
filename = gtk_file_chooser_get_filename (chooser);
g_message ("%s:%s:\n`%s`\n\tFolder: `%s'\n\tFilename: `%s'", G_STRFUNC, G_STRLOC,
g_message ("%s::current-folder-changed\n\tFolder: `%s'\n\tFilename: `%s'\nDone.\n",
G_OBJECT_TYPE_NAME (chooser), folder, filename);
g_free (folder);
g_free (filename);
@ -66,16 +66,12 @@ chooser_current_folder_changed_cb (GtkFileChooser *chooser, gpointer user_data)
static void
chooser_selection_changed_cb (GtkFileChooser *chooser, gpointer user_data)
{
GSList *selection;
gchar *filename;
g_message ("%s:%s:\n`%s` Selection:", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser));
for (selection = gtk_file_chooser_get_filenames (chooser); selection != NULL;
selection = g_slist_remove_link (selection, selection))
{
g_print ("`%s'\n", (const gchar *) selection->data);
g_free (selection->data);
}
g_print ("Done.\n");
filename = gtk_file_chooser_get_filename (chooser);
g_message ("%s::selection-changed\n\tSelection:`%s'\nDone.\n",
G_OBJECT_TYPE_NAME (chooser), filename);
g_free (filename);
}
@ -86,7 +82,8 @@ chooser_file_activated_cb (GtkFileChooser *chooser, gpointer user_data)
folder = gtk_file_chooser_get_current_folder (chooser);
filename = gtk_file_chooser_get_filename (chooser);
g_message ("%s:%s:\n`%s`\nFolder: `%s'\nFilename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), folder, filename);
g_message ("%s::file-activated\n\tFolder: `%s'\n\tFilename: `%s'\nDone.\n",
G_OBJECT_TYPE_NAME (chooser), folder, filename);
g_free (folder);
g_free (filename);
}
@ -98,17 +95,17 @@ chooser_update_preview_cb (GtkFileChooser *chooser, gpointer user_data)
gchar *filename;
filename = gtk_file_chooser_get_preview_filename (chooser);
g_message ("%s:%s:\n`%s`\nPreview Filename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), filename);
g_message ("%s::update-preview\n\tPreview Filename: `%s'\nDone.\n",
G_OBJECT_TYPE_NAME (chooser), filename);
g_free (filename);
}
int
main (int argc, char *argv[])
{
GtkWidget *win, *vbox, *frame, *alignment, *group_box, *hbox, *label, *chooser, *button;
GtkWidget *win, *vbox, *frame, *alignment, *group_box;
GtkWidget *hbox, *label, *chooser, *button;
GtkSizeGroup *label_group;
gtk_init (&argc, &argv);
/* to test rtl layout, set RTL=1 in the environment */
@ -138,15 +135,80 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (alignment), group_box);
hbox = gtk_hbox_new (FALSE, 12);
gtk_container_add (GTK_CONTAINER (group_box), hbox);
gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic ("_Open:");
gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
chooser = gtk_file_chooser_button_new_with_backend ("Select A File - testfilechooserbutton",
"gtk+");
chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
g_signal_connect (chooser, "current-folder-changed",
G_CALLBACK (chooser_current_folder_changed_cb), NULL);
g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL);
g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL);
gtk_container_add (GTK_CONTAINER (hbox), chooser);
button = gtk_button_new_with_label ("Properties...");
g_signal_connect (button, "clicked", G_CALLBACK (properties_button_clicked_cb), chooser);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic ("Select _Folder:");
gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
gtk_file_chooser_set_action (GTK_FILE_CHOOSER (chooser), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
g_signal_connect (chooser, "current-folder-changed",
G_CALLBACK (chooser_current_folder_changed_cb), NULL);
g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL);
g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL);
gtk_container_add (GTK_CONTAINER (hbox), chooser);
button = gtk_button_new_with_label ("Properties...");
g_signal_connect (button, "clicked", G_CALLBACK (properties_button_clicked_cb), chooser);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic ("_Save:");
gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
gtk_file_chooser_set_action (GTK_FILE_CHOOSER (chooser), GTK_FILE_CHOOSER_ACTION_SAVE);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
g_signal_connect (chooser, "current-folder-changed",
G_CALLBACK (chooser_current_folder_changed_cb), NULL);
g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL);
g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL);
gtk_container_add (GTK_CONTAINER (hbox), chooser);
button = gtk_button_new_with_label ("Properties...");
g_signal_connect (button, "clicked", G_CALLBACK (properties_button_clicked_cb), chooser);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic ("_Create Folder:");
gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
gtk_file_chooser_set_action (GTK_FILE_CHOOSER (chooser), GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
g_signal_connect (chooser, "current-folder-changed",
G_CALLBACK (chooser_current_folder_changed_cb), NULL);