static void gtk_combo_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkCombo *combo; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_COMBO (widget)); g_return_if_fail (allocation != NULL); GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); combo = GTK_COMBO (widget); if (combo->entry->allocation.height > combo->entry->requisition.height) { GtkAllocation button_allocation; button_allocation = combo->button->allocation; button_allocation.height = combo->entry->requisition.height; button_allocation.y = combo->entry->allocation.y + (combo->entry->allocation.height - combo->entry->requisition.height) / 2; gtk_widget_size_allocate (combo->button, &button_allocation); } }
void cl_set_corner_sharpness (const gchar *detail, GtkWidget *widget, CLRectangle *r) { if (widget->parent && GTK_IS_COMBO_BOX_ENTRY (widget->parent) || GTK_IS_COMBO (widget->parent)) { gboolean rtl = get_direction (widget->parent) == GTK_TEXT_DIR_RTL; int cl = rtl ? CL_CORNER_ROUND : CL_CORNER_NONE; int cr = rtl ? CL_CORNER_NONE : CL_CORNER_ROUND; cl_rectangle_set_corners (r, cl, cr, cl, cr); } else if (detail && !strcmp (detail, "spinbutton_up")) { gboolean rtl = get_direction (widget->parent) == GTK_TEXT_DIR_RTL; int tl = rtl ? CL_CORNER_ROUND : CL_CORNER_NONE; int tr = rtl ? CL_CORNER_NONE : CL_CORNER_ROUND; cl_rectangle_set_corners (r, tl, tr, CL_CORNER_NONE, CL_CORNER_NONE); } else if (detail && !strcmp (detail, "spinbutton_down")) { gboolean rtl = get_direction (widget->parent) == GTK_TEXT_DIR_RTL; int bl = rtl ? CL_CORNER_ROUND : CL_CORNER_NONE; int br = rtl ? CL_CORNER_NONE : CL_CORNER_ROUND; cl_rectangle_set_corners (r, CL_CORNER_NONE, CL_CORNER_NONE, bl, br); } else { cl_rectangle_set_corners (r, CL_CORNER_ROUND, CL_CORNER_ROUND, CL_CORNER_ROUND, CL_CORNER_ROUND); }; }
void combo_set_vals (GtkWidget *combo, GList *strlist, const char *str) { g_return_if_fail(GTK_IS_COMBO(combo)); if (!strlist) { gtk_list_clear_items (GTK_LIST (GTK_COMBO (combo)->list), 0, -1); } else { /* * gtk_combo_set_popdown_strings (actually gtk_list_insert_items) * automatically selects the first one and puts it into entry. * That should not happen. Drop selection mode for a moment * to prevent that. */ gtk_list_set_selection_mode (GTK_LIST (GTK_COMBO (combo)->list), GTK_SELECTION_SINGLE); gtk_combo_set_popdown_strings (GTK_COMBO (combo), strlist); gtk_list_set_selection_mode (GTK_LIST (GTK_COMBO (combo)->list), GTK_SELECTION_BROWSE); } if (str) { gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), str); gtk_entry_set_position (GTK_ENTRY (GTK_COMBO (combo)->entry), 0); } else { gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), ""); } }
void gtk_combo_set_item_string (GtkCombo * combo, GtkItem * item, const gchar * item_value) { gchar *val; gint connected = 0; g_return_if_fail (combo != NULL); g_return_if_fail (GTK_IS_COMBO (combo)); g_return_if_fail (item != NULL); val = gtk_object_get_data (GTK_OBJECT (item), gtk_combo_string_key); if (val) { g_free (val); connected = 1; } if (item_value) { val = g_strdup(item_value); gtk_object_set_data (GTK_OBJECT (item), gtk_combo_string_key, val); if (!connected) gtk_signal_connect (GTK_OBJECT (item), "destroy", (GtkSignalFunc) gtk_combo_item_destroy, val); } else { gtk_object_set_data (GTK_OBJECT (item), gtk_combo_string_key, NULL); if (connected) gtk_signal_disconnect_by_data(GTK_OBJECT (item), val); } }
void enable_widget_as (GtkWidget * check, gpointer widget) { gtk_widget_set_sensitive (GTK_WIDGET (widget), GTK_TOGGLE_BUTTON (check)->active > 0); if (GTK_IS_COMBO (widget)) gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (widget)->entry), ""); }
void gtk_combo_set_use_arrows (GtkCombo * combo, gint val) { g_return_if_fail (combo != NULL); g_return_if_fail (GTK_IS_COMBO (combo)); combo->use_arrows = val; }
void gtk_combo_set_case_sensitive (GtkCombo * combo, gint val) { g_return_if_fail (combo != NULL); g_return_if_fail (GTK_IS_COMBO (combo)); combo->case_sensitive = val; }
void gtk_combo_set_value_in_list (GtkCombo * combo, gint val, gint ok_if_empty) { g_return_if_fail (combo != NULL); g_return_if_fail (GTK_IS_COMBO (combo)); combo->value_in_list = val; combo->ok_if_empty = ok_if_empty; }
void gtk_combo_disable_activate (GtkCombo* combo) { g_return_if_fail (combo != NULL); g_return_if_fail (GTK_IS_COMBO (combo)); if ( combo->activate_id ) { gtk_signal_disconnect(GTK_OBJECT(combo->entry), combo->activate_id); combo->activate_id = 0; } }
/* * Get text of an Entry or a ComboBox */ static gchar *gtk_entry_get_text_1 (GtkWidget *widget) { if (GTK_IS_COMBO(widget)) { return gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(widget)->entry)); }else if (GTK_IS_ENTRY(widget)) { return gtk_entry_get_text(GTK_ENTRY(widget)); }else { return NULL; } }
void gtk_combo_set_popdown_strings (GtkCombo * combo, GList * strings) { GList *list; GtkWidget *li; g_return_if_fail (combo != NULL); g_return_if_fail (GTK_IS_COMBO (combo)); g_return_if_fail (strings != NULL); gtk_list_clear_items (GTK_LIST (combo->list), 0, -1); list = strings; while (list) { li = gtk_list_item_new_with_label ((gchar *) list->data); gtk_widget_show (li); gtk_container_add (GTK_CONTAINER (combo->list), li); list = list->next; } }
void last_combo_default (gchar *text) { GtkWidget *combo; gint i,j; gchar *p,*p1, st[BUFSIZ],first[BUFSIZ]; GList *list_of_combo=NULL; p1=NULL; *first='\0'; combo = (GtkWidget *)g_slist_last(widgets)->data; if (GTK_IS_COMBO(combo)) { for(j=i=0;text[i]!='\0';j++,i++) { if(text[i]!='\v') st[j]=text[i]; else { st[j]='\0'; p=(gchar *)malloc((strlen(st))+1); strcpy(p,st); if(p[strlen(p)-1]=='^') { p[strlen(p)-1]='\0'; p1=p; } list_of_combo=g_list_append(list_of_combo,p); if(*first=='\0') strcpy(first,st); j=-1; } } gtk_combo_set_popdown_strings(GTK_COMBO(combo),list_of_combo); if(p1){ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry),p1); } else { gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry),first); } gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry),FALSE); } else { fputs("ERROR: -r must be immediately preceeded by -b\n", stderr); quit(RETURN_ERROR_ARG); }; };
void cl_draw_combobox_button (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, gint width, gint height) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE(style); gboolean is_active = FALSE; gboolean draw_inset = FALSE; CLRectangle r; cl_rectangle_set_button (&r, style, state_type, GTK_WIDGET_HAS_DEFAULT (widget), GTK_WIDGET_HAS_FOCUS (widget), CL_CORNER_NONE, CL_CORNER_ROUND, CL_CORNER_NONE, CL_CORNER_ROUND); if (state_type == GTK_STATE_ACTIVE) is_active = TRUE; else r.fillgc = NULL; /* Seriously, why can't non-gtk-apps at least try to be decent citizens? Take this fscking OpenOffice.org 1.9 for example. The morons responsible for this utter piece of crap give the clip size wrong values! :'( */ if (area) { area->x = x; area->y = y; area->width = width; area->height = height; } x--; width++; /* Draw "sunken" look when border thickness is more than 2 pixels. */ if (GTK_IS_COMBO(widget->parent)) draw_inset = (widget->parent->style->xthickness > 2 && widget->parent->style->ythickness > 2); else draw_inset = (style->xthickness > 2 && style->ythickness > 2); if (draw_inset) { cl_draw_inset (style, window, widget, area, x, y, width, height, CL_CORNER_NONE, CL_CORNER_ROUND, CL_CORNER_NONE, CL_CORNER_ROUND); x++; y++; height-=2; width-=2; } else { x++; width--; } if (area) cl_rectangle_set_clip_rectangle (&r, area); cl_draw_rectangle (window, widget, style, x, y, width, height, &r); if (!is_active) { int tmp_height = (float)height*0.25; gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); draw_hgradient (window, style->bg_gc[state_type], style, x+2,y+2,width-4,tmp_height, &clearlooks_style->button_g1[state_type], &clearlooks_style->button_g2[state_type]); draw_hgradient (window, style->bg_gc[state_type], style, x+2, y+2+tmp_height, width-4, height-3-tmp_height*2, &clearlooks_style->button_g2[state_type], &clearlooks_style->button_g3[state_type]); draw_hgradient (window, style->bg_gc[state_type], style, x+2,y+height-tmp_height-1,width-4,tmp_height, &clearlooks_style->button_g3[state_type], &clearlooks_style->button_g4[state_type]); gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); } cl_draw_shadow (window, widget, style, x, y, width, height, &r); if (area) cl_rectangle_reset_clip_rectangle (&r); }
AtkRelationSet* gail_label_ref_relation_set (AtkObject *obj) { GtkWidget *widget; AtkRelationSet *relation_set; g_return_val_if_fail (GAIL_IS_LABEL (obj), NULL); widget = GTK_ACCESSIBLE (obj)->widget; if (widget == NULL) /* * State is defunct */ return NULL; relation_set = ATK_OBJECT_CLASS (parent_class)->ref_relation_set (obj); if (!atk_relation_set_contains (relation_set, ATK_RELATION_LABEL_FOR)) { /* * Get the mnemonic widget * * The relation set is not updated if the mnemonic widget is changed */ GtkWidget *mnemonic_widget = GTK_LABEL (widget)->mnemonic_widget; if (mnemonic_widget) { AtkObject *accessible_array[1]; AtkRelation* relation; if (!GTK_WIDGET_CAN_FOCUS (mnemonic_widget)) { /* * Handle the case where a GtkFileChooserButton is specified as the * mnemonic widget. use the combobox which is a child of the * GtkFileChooserButton as the mnemonic widget. See bug #359843. */ if (GTK_IS_BOX (mnemonic_widget)) { GList *list, *tmpl; list = gtk_container_get_children (GTK_CONTAINER (mnemonic_widget)); if (g_list_length (list) == 2) { tmpl = g_list_last (list); if (GTK_IS_COMBO_BOX(tmpl->data)) { mnemonic_widget = GTK_WIDGET(tmpl->data); } } g_list_free (list); } /* * Handle the case where a GnomeIconEntry is specified as the * mnemonic widget. use the button which is a grandchild of the * GnomeIconEntry as the mnemonic widget. See bug #133967. */ else if (GTK_IS_BOX (mnemonic_widget)) { GList *list; list = gtk_container_get_children (GTK_CONTAINER (mnemonic_widget)); if (g_list_length (list) == 1) { if (GTK_IS_ALIGNMENT (list->data)) { GtkWidget *temp_widget; temp_widget = GTK_BIN (list->data)->child; if (GTK_IS_BUTTON (temp_widget)) mnemonic_widget = temp_widget; } else if (GTK_IS_HBOX (list->data)) { GtkWidget *temp_widget; temp_widget = GTK_WIDGET (list->data); g_list_free (list); list = gtk_container_get_children (GTK_CONTAINER (temp_widget)); if (GTK_IS_COMBO (list->data)) { mnemonic_widget = GTK_WIDGET (list->data); } } } g_list_free (list); } } accessible_array[0] = gtk_widget_get_accessible (mnemonic_widget); relation = atk_relation_new (accessible_array, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (relation_set, relation); /* * Unref the relation so that it is not leaked. */ g_object_unref (relation); } } return relation_set; }
static AtkObject* gail_get_accessible_for_widget (GtkWidget *widget, gboolean *transient) { AtkObject *obj = NULL; GType gnome_canvas; gnome_canvas = g_type_from_name ("GnomeCanvas"); *transient = FALSE; if (!widget) return NULL; if (GTK_IS_ENTRY (widget)) { GtkWidget *other_widget = widget->parent; if (GTK_IS_COMBO (other_widget)) { gail_set_focus_widget (other_widget, widget); widget = other_widget; } } else if (GTK_IS_NOTEBOOK (widget)) { GtkNotebook *notebook; gint page_num = -1; notebook = GTK_NOTEBOOK (widget); /* * Report the currently focused tab rather than the currently selected tab */ if (notebook->focus_tab) { page_num = g_list_index (notebook->children, notebook->focus_tab->data); } if (page_num != -1) { obj = gtk_widget_get_accessible (widget); obj = atk_object_ref_accessible_child (obj, page_num); g_object_unref (obj); } } else if (GTK_CHECK_TYPE ((widget), gnome_canvas)) { GObject *focused_item; GValue value = {0, }; g_value_init (&value, G_TYPE_OBJECT); g_object_get_property (G_OBJECT (widget), "focused_item", &value); focused_item = g_value_get_object (&value); if (focused_item) { AtkObject *tmp; obj = atk_gobject_accessible_for_object (G_OBJECT (focused_item)); tmp = g_object_get_qdata (G_OBJECT (obj), quark_focus_object); if (tmp != NULL) obj = tmp; } } else if (GTK_IS_TOGGLE_BUTTON (widget)) { GtkWidget *other_widget = widget->parent; if (GTK_IS_COMBO_BOX (other_widget)) { gail_set_focus_widget (other_widget, widget); widget = other_widget; } } if (obj == NULL) { AtkObject *focus_object; obj = gtk_widget_get_accessible (widget); focus_object = g_object_get_qdata (G_OBJECT (obj), quark_focus_object); /* * We check whether the object for this focus_object has been deleted. * This can happen when navigating to an empty directory in nautilus. * See bug #141907. */ if (ATK_IS_GOBJECT_ACCESSIBLE (focus_object)) { if (!atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (focus_object))) focus_object = NULL; } if (focus_object) obj = focus_object; } return obj; }