Added cs to the list of languages
[midnight-commander.git] / gnome / gcliplabel.c
blob383e5b0f99dc956aeaa4312da001c54c7dba419e
1 /*
2 * (C) 1998 The Free Software Foundation
4 * Author: Miguel de Icaza (miguel@kernel.org)
6 * Clipped label: This label is differnt from the one on Gtk as it
7 * does requests no space, but uses all that is given to it.
8 *
9 * It does not queue an resize when changing the text.
10 * */
12 #include <string.h>
13 #include "gcliplabel.h"
14 #include <gtk/gtkcompat.h>
16 static void gtk_clip_label_class_init (GtkClipLabelClass *klass);
17 static void gtk_clip_label_size_request (GtkWidget *widget,
18 GtkRequisition *requisition);
19 static void gtk_clip_label_size_allocate (GtkWidget *widget,
20 GtkAllocation *allocation);
22 static GtkLabelClass *parent_class = NULL;
24 guint
25 gtk_clip_label_get_type ()
27 static guint label_type = 0;
29 if (!label_type)
31 GtkTypeInfo clip_label_info =
33 "GtkClipLabel",
34 sizeof (GtkClipLabel),
35 sizeof (GtkClipLabelClass),
36 (GtkClassInitFunc) gtk_clip_label_class_init,
37 (GtkObjectInitFunc) NULL,
38 (GtkArgSetFunc) NULL,
39 (GtkArgGetFunc) NULL
42 label_type = gtk_type_unique (gtk_label_get_type (), &clip_label_info);
45 return label_type;
48 static void
49 gtk_clip_label_class_init (GtkClipLabelClass *class)
51 GtkWidgetClass *widget_class;
53 parent_class = gtk_type_class (gtk_label_get_type ());
55 widget_class = (GtkWidgetClass*) class;
56 widget_class->size_request = gtk_clip_label_size_request;
57 widget_class->size_allocate = gtk_clip_label_size_allocate;
60 void
61 gtk_clip_label_set (GtkLabel *label,
62 const char *str)
64 gtk_label_set_text (label, str);
67 GtkWidget*
68 gtk_clip_label_new (const char *str)
70 GtkClipLabel *label;
72 g_return_val_if_fail (str != NULL, NULL);
74 label = gtk_type_new (gtk_clip_label_get_type ());
76 gtk_label_set_text (GTK_LABEL (label), str);
78 return GTK_WIDGET (label);
81 static void
82 gtk_clip_label_size_request (GtkWidget *widget,
83 GtkRequisition *requisition)
85 GtkClipLabel *label;
87 g_return_if_fail (widget != NULL);
88 g_return_if_fail (GTK_IS_CLIP_LABEL (widget));
89 g_return_if_fail (requisition != NULL);
91 label = GTK_CLIP_LABEL (widget);
93 ((GtkWidgetClass *)parent_class)->size_request (widget, requisition);
95 requisition->width = GTK_LABEL (label)->misc.xpad * 2;
98 static void
99 gtk_clip_label_size_allocate (GtkWidget *widget,
100 GtkAllocation *alloc)
102 ((GtkWidgetClass *)parent_class)->size_allocate (widget, alloc);
104 widget->requisition.width = alloc->width;