Commit 2145a4ef authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add a "menu" property and notify on it. (#62798, Padraig O'Briain)

Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
	Add a "menu" property and notify on it. (#62798,
	Padraig O'Briain)

	* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
	gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
	Fix set_text to take a gchar, not a guchar, and to have
	a len argument.
parent 7dccab8f
Wed Oct 31 18:23:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)
* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.
Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
* gtk/gtkstock.c: fix typo to make it compile
......
Wed Oct 31 18:23:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)
* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.
Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
* gtk/gtkstock.c: fix typo to make it compile
......
Wed Oct 31 18:23:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)
* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.
Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
* gtk/gtkstock.c: fix typo to make it compile
......
Wed Oct 31 18:23:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)
* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.
Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
* gtk/gtkstock.c: fix typo to make it compile
......
Wed Oct 31 18:23:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)
* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.
Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
* gtk/gtkstock.c: fix typo to make it compile
......
Wed Oct 31 18:23:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)
* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.
Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
* gtk/gtkstock.c: fix typo to make it compile
......
Wed Oct 31 18:23:47 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)
* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.
Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
* gtk/gtkstock.c: fix typo to make it compile
......
......@@ -498,7 +498,7 @@ text_get_func (GtkClipboard *clipboard,
guint info,
gpointer data)
{
gtk_selection_data_set_text (selection_data, data);
gtk_selection_data_set_text (selection_data, data, -1);
}
static void
......
......@@ -3172,7 +3172,7 @@ primary_get_cb (GtkClipboard *clipboard,
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
{
gchar *str = gtk_entry_get_public_chars (entry, start, end);
gtk_selection_data_set_text (selection_data, str);
gtk_selection_data_set_text (selection_data, str, -1);
g_free (str);
}
}
......@@ -4025,7 +4025,7 @@ gtk_entry_drag_data_get (GtkWidget *widget,
{
gchar *str = gtk_editable_get_chars (editable, sel_start, sel_end);
gtk_selection_data_set_text (selection_data, str);
gtk_selection_data_set_text (selection_data, str, -1);
g_free (str);
}
......
......@@ -915,7 +915,7 @@ filenames_drag_get (GtkWidget *widget,
else
{
g_print ("Setting text: '%s'\n", file);
gtk_selection_data_set_text (selection_data, file);
gtk_selection_data_set_text (selection_data, file, -1);
}
}
}
......
......@@ -2406,7 +2406,6 @@ get_text_callback (GtkClipboard *clipboard,
gpointer user_data_or_owner)
{
GtkLabel *label;
gchar *str;
label = GTK_LABEL (user_data_or_owner);
......@@ -2430,13 +2429,9 @@ get_text_callback (GtkClipboard *clipboard,
if (start > len)
start = len;
str = g_strndup (label->text + start,
end - start);
gtk_selection_data_set_text (selection_data,
str);
g_free (str);
gtk_selection_data_set_text (selection_data,
label->text + start,
end - start);
}
}
......
......@@ -584,7 +584,7 @@ gtk_old_editable_selection_get (GtkWidget *widget,
if (str)
{
gtk_selection_data_set_text (selection_data, str);
gtk_selection_data_set_text (selection_data, str, -1);
g_free (str);
}
}
......
......@@ -55,6 +55,14 @@ static GtkOptionMenuProps default_props = {
static void gtk_option_menu_class_init (GtkOptionMenuClass *klass);
static void gtk_option_menu_init (GtkOptionMenu *option_menu);
static void gtk_option_menu_destroy (GtkObject *object);
static void gtk_option_menu_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_option_menu_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_option_menu_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_option_menu_size_allocate (GtkWidget *widget,
......@@ -91,6 +99,13 @@ enum
LAST_SIGNAL
};
enum
{
PROP_0,
PROP_MENU,
LAST_PROP
};
static GtkButtonClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
......@@ -123,11 +138,13 @@ gtk_option_menu_get_type (void)
static void
gtk_option_menu_class_init (GtkOptionMenuClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkButtonClass *button_class;
GtkContainerClass *container_class;
gobject_class = (GObjectClass*) class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
button_class = (GtkButtonClass*) class;
......@@ -143,7 +160,9 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
NULL, NULL,
gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gobject_class->set_property = gtk_option_menu_set_property;
gobject_class->get_property = gtk_option_menu_get_property;
object_class->destroy = gtk_option_menu_destroy;
widget_class->size_request = gtk_option_menu_size_request;
......@@ -158,6 +177,14 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
container_class->child_type = gtk_option_menu_child_type;
g_object_class_install_property (gobject_class,
PROP_MENU,
g_param_spec_object ("menu",
_("Menu"),
_("The menu of options"),
GTK_TYPE_MENU,
G_PARAM_READABLE | G_PARAM_WRITABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boxed ("indicator_size",
_("Indicator Size"),
......@@ -220,6 +247,7 @@ gtk_option_menu_detacher (GtkWidget *widget,
option_menu);
option_menu->menu = NULL;
g_object_notify (G_OBJECT (option_menu), "menu");
}
void
......@@ -251,6 +279,8 @@ gtk_option_menu_set_menu (GtkOptionMenu *option_menu,
gtk_widget_queue_resize (GTK_WIDGET (option_menu));
gtk_option_menu_update_contents (option_menu);
g_object_notify (G_OBJECT (option_menu), "menu");
}
}
......@@ -311,6 +341,46 @@ gtk_option_menu_get_history (GtkOptionMenu *option_menu)
return -1;
}
static void
gtk_option_menu_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkOptionMenu *option_menu = GTK_OPTION_MENU (object);
switch (prop_id)
{
case PROP_MENU:
gtk_option_menu_set_menu (option_menu, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_option_menu_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkOptionMenu *option_menu = GTK_OPTION_MENU (object);
switch (prop_id)
{
case PROP_MENU:
g_value_set_object (value, option_menu->menu);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_option_menu_destroy (GtkObject *object)
{
......
......@@ -769,6 +769,7 @@ init_atoms (void)
* gtk_selection_data_set_text:
* @selection_data: a #GtkSelectionData
* @str: a UTF-8 string
* @len: the length of @str, or -1 if @str is nul-terminated.
*
* Sets the contents of the selection from a UTF-8 encoded string.
* The string is converted to the form determined by
......@@ -779,50 +780,62 @@ init_atoms (void)
**/
gboolean
gtk_selection_data_set_text (GtkSelectionData *selection_data,
const guchar *str)
const gchar *str,
gint len)
{
gboolean result = FALSE;
if (len < 0)
len = strlen (str);
init_atoms ();
if (selection_data->target == utf8_atom)
{
gtk_selection_data_set (selection_data,
utf8_atom,
8, (guchar *)str, strlen (str));
return TRUE;
8, (guchar *)str, len);
result = TRUE;
}
else if (selection_data->target == GDK_TARGET_STRING)
{
gchar *latin1 = gdk_utf8_to_string_target (str);
gchar *tmp = g_strndup (str, len);
gchar *latin1 = gdk_utf8_to_string_target (tmp);
g_free (tmp);
if (latin1)
{
gtk_selection_data_set (selection_data,
GDK_SELECTION_TYPE_STRING,
8, latin1, strlen (latin1));
g_free(latin1);
g_free (latin1);
return TRUE;
result = TRUE;
}
}
else if (selection_data->target == ctext_atom ||
selection_data->target == text_atom)
{
gchar *tmp;
guchar *text;
GdkAtom encoding;
gint format;
gint new_length;
if (gdk_utf8_to_compound_text (str, &encoding, &format, &text, &new_length))
tmp = g_strndup (str, len);
if (gdk_utf8_to_compound_text (tmp, &encoding, &format, &text, &new_length))
{
gtk_selection_data_set (selection_data, encoding, format, text, new_length);
gdk_free_compound_text (text);
return TRUE;
result = TRUE;
}
g_free (tmp);
}
return FALSE;
return result;
}
/**
......
......@@ -126,7 +126,8 @@ void gtk_selection_data_set (GtkSelectionData *selection_data,
const guchar *data,
gint length);
gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data,
const guchar *str);
const gchar *str,
gint len);
guchar * gtk_selection_data_get_text (GtkSelectionData *selection_data);
gboolean gtk_selection_data_get_targets (GtkSelectionData *selection_data,
......
......@@ -2560,7 +2560,7 @@ clipboard_get_selection_cb (GtkClipboard *clipboard,
gchar *str;
str = gtk_text_iter_get_visible_text (&start, &end);
gtk_selection_data_set_text (selection_data, str);
gtk_selection_data_set_text (selection_data, str, -1);
g_free (str);
}
}
......@@ -2679,7 +2679,7 @@ clipboard_get_contents_cb (GtkClipboard *clipboard,
gtk_text_buffer_get_bounds (contents, &start, &end);
str = gtk_text_iter_get_visible_text (&start, &end);
gtk_selection_data_set_text (selection_data, str);
gtk_selection_data_set_text (selection_data, str, -1);
g_free (str);
}
}
......
......@@ -4799,7 +4799,7 @@ gtk_text_view_drag_data_get (GtkWidget *widget,
if (str)
{
gtk_selection_data_set_text (selection_data, str);
gtk_selection_data_set_text (selection_data, str, -1);
g_free (str);
}
}
......
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