Esempio n. 1
0
static void
panda_combo_build_children (GladeXML *xml, GtkWidget *w,
			    GladeWidgetInfo *info, const char *longname)
{
	GList *tmp;
	GladeWidgetInfo *cinfo = NULL;
	GtkEntry *entry;

	for (tmp = info->children; tmp; tmp = tmp->next) {
		GList *tmp2;
		gchar *child_name = NULL;
		cinfo = tmp->data;
		for (tmp2 = cinfo->attributes; tmp2; tmp2 = tmp2->next) {
			GladeAttribute *attr = tmp2->data;
			if (!strcmp(attr->name, "child_name")) {
				child_name = attr->value;
				break;
			}
		}
		if (child_name && !strcmp(child_name, "GtkPandaCombo:entry"))
			break;
	}
	if (!tmp)
		return;
#if 1
	entry = GTK_ENTRY(GTK_PANDA_COMBO(w)->entry);
	for (tmp = cinfo->attributes; tmp; tmp = tmp->next) {
		GladeAttribute *attr = tmp->data;
		if (!strcmp(attr->name, "editable")) {
			gtk_entry_set_editable(entry, attr->value[0] == 'T');
		} else if (!strcmp(attr->name, "text_visible")) {
			gtk_entry_set_visibility(entry, attr->value[0] == 'T');
		} else if (!strcmp(attr->name, "text_max_length")) {
			gtk_entry_set_max_length(entry, strtol(attr->value,NULL, 0));
		} else if (!strcmp(attr->name, "max_length")) {
			gtk_entry_set_max_length(entry, strtol(attr->value,NULL, 0));
		} else if (!strcmp(attr->name, "text")) {
			gtk_entry_set_text(entry, attr->value);
		}
	}
#endif
	glade_xml_set_common_params(xml, GTK_PANDA_COMBO(w)->entry, cinfo, longname);
}
static void
menushell_build_children (GladeXML *xml, GtkWidget *w, 
			  GladeWidgetInfo *info)
{
    int i, j;
    MateUIInfo infos[2] = {
	{ MATE_APP_UI_ITEM },
	MATEUIINFO_END
    };

    for (i = 0; i < info->n_children; i++) {
	GladeChildInfo *cinfo = &info->children[i];
	GladeWidgetInfo *cwinfo = cinfo->child;
	GtkWidget *child;
	gchar *stock_name = NULL;
	
	for (j = 0; j < cwinfo->n_properties; j++) {
	    if (!strcmp (cwinfo->properties[j].name, "stock_item")) {
		stock_name = cwinfo->properties[j].value;
		break;
	    }
	}
	if (!stock_name) {
	    /* this is a normal menu item */
	    child = glade_xml_build_widget (xml, cwinfo);
	    gtk_menu_shell_append (GTK_MENU_SHELL (w), child);
	    continue;
	}
	/* load the template MateUIInfo for this item */
	if (!get_stock_uiinfo (stock_name, &infos[0])) {
	    /* failure ... */
	    if (!strncmp (stock_name, "MATEUIINFO_", 12))
		stock_name += 12;
	    child = gtk_menu_item_new_with_label (stock_name);
	    glade_xml_set_common_params (xml, child, cwinfo);
	    gtk_menu_shell_append (GTK_MENU_SHELL(w), child);
	    continue;
	}
	/* we now have the template for this item.  Now fill it in */
	for (j = 0; j < cwinfo->n_properties; j++) {
	    const char *name  = cwinfo->properties[j].name;
	    const char *value = cwinfo->properties[j].value;
	    if (!strcmp (name, "label"))
		infos[0].label = _(value);
	    else if (!strcmp (name, "tooltip"))
		infos[0].hint = _(value);
	}
	mate_app_fill_menu (GTK_MENU_SHELL(w), infos,
			     glade_xml_ensure_accel(xml), TRUE,
			     i);
	child = infos[0].widget;
	gtk_menu_item_remove_submenu(GTK_MENU_ITEM(child));
	glade_xml_set_common_params(xml, child, cwinfo);
    }

#if 0
    if (uline)
	glade_xml_pop_uline_accel(xml);
#endif
#if 0
    if (strcmp(info->classname, "GtkMenuBar") != 0 &&
	mate_preferences_get_menus_have_tearoff()) {
	GtkWidget *tearoff = gtk_tearoff_menu_item_new();
	
	gtk_menu_prepend(GTK_MENU(w), tearoff);
	gtk_widget_show(tearoff);
    }
#endif
}