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

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> Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
   
* gtk/gtkstock.c: fix typo to make it compile * 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> Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
   
* gtk/gtkstock.c: fix typo to make it compile * 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> Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
   
* gtk/gtkstock.c: fix typo to make it compile * 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> Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
   
* gtk/gtkstock.c: fix typo to make it compile * 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> Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
   
* gtk/gtkstock.c: fix typo to make it compile * 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> Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
   
* gtk/gtkstock.c: fix typo to make it compile * 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> Wed Oct 31 15:31:13 2001 Manish Singh <yosh@gimp.org>
   
* gtk/gtkstock.c: fix typo to make it compile * gtk/gtkstock.c: fix typo to make it compile
......
...@@ -498,7 +498,7 @@ text_get_func (GtkClipboard *clipboard, ...@@ -498,7 +498,7 @@ text_get_func (GtkClipboard *clipboard,
guint info, guint info,
gpointer data) gpointer data)
{ {
gtk_selection_data_set_text (selection_data, data); gtk_selection_data_set_text (selection_data, data, -1);
} }
static void static void
......
...@@ -3172,7 +3172,7 @@ primary_get_cb (GtkClipboard *clipboard, ...@@ -3172,7 +3172,7 @@ primary_get_cb (GtkClipboard *clipboard,
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end)) if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
{ {
gchar *str = gtk_entry_get_public_chars (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); g_free (str);
} }
} }
...@@ -4025,7 +4025,7 @@ gtk_entry_drag_data_get (GtkWidget *widget, ...@@ -4025,7 +4025,7 @@ gtk_entry_drag_data_get (GtkWidget *widget,
{ {
gchar *str = gtk_editable_get_chars (editable, sel_start, sel_end); 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); g_free (str);
} }
......
...@@ -915,7 +915,7 @@ filenames_drag_get (GtkWidget *widget, ...@@ -915,7 +915,7 @@ filenames_drag_get (GtkWidget *widget,
else else
{ {
g_print ("Setting text: '%s'\n", file); 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, ...@@ -2406,7 +2406,6 @@ get_text_callback (GtkClipboard *clipboard,
gpointer user_data_or_owner) gpointer user_data_or_owner)
{ {
GtkLabel *label; GtkLabel *label;
gchar *str;
label = GTK_LABEL (user_data_or_owner); label = GTK_LABEL (user_data_or_owner);
...@@ -2430,13 +2429,9 @@ get_text_callback (GtkClipboard *clipboard, ...@@ -2430,13 +2429,9 @@ get_text_callback (GtkClipboard *clipboard,
if (start > len) if (start > len)
start = len; start = len;
str = g_strndup (label->text + start, gtk_selection_data_set_text (selection_data,
end - start); label->text + start,
end - start);
gtk_selection_data_set_text (selection_data,
str);
g_free (str);
} }
} }
......
...@@ -584,7 +584,7 @@ gtk_old_editable_selection_get (GtkWidget *widget, ...@@ -584,7 +584,7 @@ gtk_old_editable_selection_get (GtkWidget *widget,
if (str) if (str)
{ {
gtk_selection_data_set_text (selection_data, str); gtk_selection_data_set_text (selection_data, str, -1);
g_free (str); g_free (str);
} }
} }
......
...@@ -55,6 +55,14 @@ static GtkOptionMenuProps default_props = { ...@@ -55,6 +55,14 @@ static GtkOptionMenuProps default_props = {
static void gtk_option_menu_class_init (GtkOptionMenuClass *klass); static void gtk_option_menu_class_init (GtkOptionMenuClass *klass);
static void gtk_option_menu_init (GtkOptionMenu *option_menu); static void gtk_option_menu_init (GtkOptionMenu *option_menu);
static void gtk_option_menu_destroy (GtkObject *object); 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, static void gtk_option_menu_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_option_menu_size_allocate (GtkWidget *widget, static void gtk_option_menu_size_allocate (GtkWidget *widget,
...@@ -91,6 +99,13 @@ enum ...@@ -91,6 +99,13 @@ enum
LAST_SIGNAL LAST_SIGNAL
}; };
enum
{
PROP_0,
PROP_MENU,
LAST_PROP
};
static GtkButtonClass *parent_class = NULL; static GtkButtonClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 }; static guint signals[LAST_SIGNAL] = { 0 };
...@@ -123,11 +138,13 @@ gtk_option_menu_get_type (void) ...@@ -123,11 +138,13 @@ gtk_option_menu_get_type (void)
static void static void
gtk_option_menu_class_init (GtkOptionMenuClass *class) gtk_option_menu_class_init (GtkOptionMenuClass *class)
{ {
GObjectClass *gobject_class;
GtkObjectClass *object_class; GtkObjectClass *object_class;
GtkWidgetClass *widget_class; GtkWidgetClass *widget_class;
GtkButtonClass *button_class; GtkButtonClass *button_class;
GtkContainerClass *container_class; GtkContainerClass *container_class;
gobject_class = (GObjectClass*) class;
object_class = (GtkObjectClass*) class; object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class; widget_class = (GtkWidgetClass*) class;
button_class = (GtkButtonClass*) class; button_class = (GtkButtonClass*) class;
...@@ -143,7 +160,9 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class) ...@@ -143,7 +160,9 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
NULL, NULL, NULL, NULL,
gtk_marshal_VOID__VOID, gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0); 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; object_class->destroy = gtk_option_menu_destroy;
widget_class->size_request = gtk_option_menu_size_request; widget_class->size_request = gtk_option_menu_size_request;
...@@ -158,6 +177,14 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class) ...@@ -158,6 +177,14 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
container_class->child_type = gtk_option_menu_child_type; 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, gtk_widget_class_install_style_property (widget_class,
g_param_spec_boxed ("indicator_size", g_param_spec_boxed ("indicator_size",
_("Indicator Size"), _("Indicator Size"),
...@@ -220,6 +247,7 @@ gtk_option_menu_detacher (GtkWidget *widget, ...@@ -220,6 +247,7 @@ gtk_option_menu_detacher (GtkWidget *widget,
option_menu); option_menu);
option_menu->menu = NULL; option_menu->menu = NULL;
g_object_notify (G_OBJECT (option_menu), "menu");
} }
void void
...@@ -251,6 +279,8 @@ gtk_option_menu_set_menu (GtkOptionMenu *option_menu, ...@@ -251,6 +279,8 @@ gtk_option_menu_set_menu (GtkOptionMenu *option_menu,
gtk_widget_queue_resize (GTK_WIDGET (option_menu)); gtk_widget_queue_resize (GTK_WIDGET (option_menu));
gtk_option_menu_update_contents (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) ...@@ -311,6 +341,46 @@ gtk_option_menu_get_history (GtkOptionMenu *option_menu)
return -1; 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 static void
gtk_option_menu_destroy (GtkObject *object) gtk_option_menu_destroy (GtkObject *object)
{ {
......
...@@ -769,6 +769,7 @@ init_atoms (void) ...@@ -769,6 +769,7 @@ init_atoms (void)
* gtk_selection_data_set_text: * gtk_selection_data_set_text:
* @selection_data: a #GtkSelectionData * @selection_data: a #GtkSelectionData
* @str: a UTF-8 string * @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. * Sets the contents of the selection from a UTF-8 encoded string.
* The string is converted to the form determined by * The string is converted to the form determined by
...@@ -779,50 +780,62 @@ init_atoms (void) ...@@ -779,50 +780,62 @@ init_atoms (void)
**/ **/
gboolean gboolean
gtk_selection_data_set_text (GtkSelectionData *selection_data, 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 (); init_atoms ();
if (selection_data->target == utf8_atom) if (selection_data->target == utf8_atom)
{ {
gtk_selection_data_set (selection_data, gtk_selection_data_set (selection_data,
utf8_atom, utf8_atom,
8, (guchar *)str, strlen (str)); 8, (guchar *)str, len);
return TRUE; result = TRUE;
} }
else if (selection_data->target == GDK_TARGET_STRING) 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) if (latin1)
{ {
gtk_selection_data_set (selection_data, gtk_selection_data_set (selection_data,
GDK_SELECTION_TYPE_STRING, GDK_SELECTION_TYPE_STRING,
8, latin1, strlen (latin1)); 8, latin1, strlen (latin1));
g_free(latin1); g_free (latin1);
return TRUE; result = TRUE;
} }
} }
else if (selection_data->target == ctext_atom || else if (selection_data->target == ctext_atom ||
selection_data->target == text_atom) selection_data->target == text_atom)
{ {
gchar *tmp;
guchar *text; guchar *text;
GdkAtom encoding; GdkAtom encoding;
gint format; gint format;
gint new_length; 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); gtk_selection_data_set (selection_data, encoding, format, text, new_length);
gdk_free_compound_text (text); 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, ...@@ -126,7 +126,8 @@ void gtk_selection_data_set (GtkSelectionData *selection_data,
const guchar *data, const guchar *data,
gint length); gint length);
gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data, 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); guchar * gtk_selection_data_get_text (GtkSelectionData *selection_data);
gboolean gtk_selection_data_get_targets (GtkSelectionData *selection_data, gboolean gtk_selection_data_get_targets (GtkSelectionData *selection_data,
......
...@@ -2560,7 +2560,7 @@ clipboard_get_selection_cb (GtkClipboard *clipboard, ...@@ -2560,7 +2560,7 @@ clipboard_get_selection_cb (GtkClipboard *clipboard,
gchar *str; gchar *str;
str = gtk_text_iter_get_visible_text (&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); g_free (str);
} }
} }
...@@ -2679,7 +2679,7 @@ clipboard_get_contents_cb (GtkClipboard *clipboard, ...@@ -2679,7 +2679,7 @@ clipboard_get_contents_cb (GtkClipboard *clipboard,
gtk_text_buffer_get_bounds (contents, &start, &end); gtk_text_buffer_get_bounds (contents, &start, &end);
str = gtk_text_iter_get_visible_text (&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); g_free (str);
} }
} }
......
...@@ -4799,7 +4799,7 @@ gtk_text_view_drag_data_get (GtkWidget *widget, ...@@ -4799,7 +4799,7 @@ gtk_text_view_drag_data_get (GtkWidget *widget,
if (str) if (str)
{ {
gtk_selection_data_set_text (selection_data, str); gtk_selection_data_set_text (selection_data, str, -1);
g_free (str); 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