3 #include "general-support.h"
4 #include "widget-information.h"
8 /* Widget Type Lookups/Macros
10 Based on/modified from functions in
14 ge_object_is_a (const GObject
* object
, const gchar
* type_name
)
16 gboolean result
= FALSE
;
20 GType tmp
= g_type_from_name (type_name
);
23 result
= g_type_check_instance_is_a ((GTypeInstance
*) object
, tmp
);
30 ge_is_combo_box_entry (GtkWidget
* widget
)
32 gboolean result
= FALSE
;
34 if ((widget
) && (widget
->parent
))
36 if (GE_IS_COMBO_BOX_ENTRY (widget
->parent
))
39 result
= ge_is_combo_box_entry (widget
->parent
);
45 ge_combo_box_is_using_list (GtkWidget
* widget
)
47 gboolean result
= FALSE
;
49 if (GE_IS_COMBO_BOX (widget
))
53 gtk_widget_style_get (widget
, "appears-as-list", &result
, NULL
);
63 ge_is_combo_box (GtkWidget
* widget
, gboolean as_list
)
65 gboolean result
= FALSE
;
67 if ((widget
) && (widget
->parent
))
69 if (GE_IS_COMBO_BOX (widget
->parent
))
72 result
= (ge_combo_box_is_using_list(widget
->parent
));
74 result
= (!ge_combo_box_is_using_list(widget
->parent
));
77 result
= ge_is_combo_box (widget
->parent
, as_list
);
83 ge_is_combo (GtkWidget
* widget
)
85 gboolean result
= FALSE
;
87 if ((widget
) && (widget
->parent
))
89 if (GE_IS_COMBO (widget
->parent
))
92 result
= ge_is_combo (widget
->parent
);
98 ge_is_in_combo_box (GtkWidget
* widget
)
100 return ((ge_is_combo (widget
) || ge_is_combo_box (widget
, TRUE
) || ge_is_combo_box_entry (widget
)));
104 ge_is_toolbar_item (GtkWidget
* widget
)
106 gboolean result
= FALSE
;
108 if ((widget
) && (widget
->parent
)) {
109 if ((GE_IS_BONOBO_TOOLBAR (widget
->parent
))
110 || (GE_IS_BONOBO_DOCK_ITEM (widget
->parent
))
111 || (GE_IS_EGG_TOOLBAR (widget
->parent
))
112 || (GE_IS_TOOLBAR (widget
->parent
))
113 || (GE_IS_HANDLE_BOX (widget
->parent
)))
116 result
= ge_is_toolbar_item (widget
->parent
);
122 ge_is_panel_widget_item (GtkWidget
* widget
)
124 gboolean result
= FALSE
;
126 if ((widget
) && (widget
->parent
))
128 if (GE_IS_PANEL_WIDGET (widget
->parent
))
131 result
= ge_is_panel_widget_item (widget
->parent
);
137 ge_is_bonobo_dock_item (GtkWidget
* widget
)
139 gboolean result
= FALSE
;
143 if (GE_IS_BONOBO_DOCK_ITEM(widget
) || GE_IS_BONOBO_DOCK_ITEM (widget
->parent
))
145 else if (GE_IS_BOX(widget
) || GE_IS_BOX(widget
->parent
))
147 GtkContainer
*box
= GE_IS_BOX(widget
)?GTK_CONTAINER(widget
):GTK_CONTAINER(widget
->parent
);
148 GList
*children
= NULL
, *child
= NULL
;
150 children
= gtk_container_get_children(box
);
152 for (child
= g_list_first(children
); child
; child
= g_list_next(child
))
154 if (GE_IS_BONOBO_DOCK_ITEM_GRIP(child
->data
))
162 g_list_free(children
);
169 ge_find_combo_box_entry_widget (GtkWidget
* widget
)
171 GtkWidget
*result
= NULL
;
175 if (GE_IS_COMBO_BOX_ENTRY (widget
))
178 result
= ge_find_combo_box_entry_widget (widget
->parent
);
185 ge_find_combo_box_widget (GtkWidget
* widget
, gboolean as_list
)
187 GtkWidget
*result
= NULL
;
191 if (GE_IS_COMBO_BOX (widget
))
194 result
= (ge_combo_box_is_using_list(widget
))?widget
:NULL
;
196 result
= (!ge_combo_box_is_using_list(widget
))?widget
:NULL
;
199 result
= ge_find_combo_box_widget (widget
->parent
, as_list
);
205 ge_find_combo_widget (GtkWidget
* widget
)
207 GtkWidget
*result
= NULL
;
211 if (GE_IS_COMBO (widget
))
214 result
= ge_find_combo_widget(widget
->parent
);
220 ge_find_combo_box_widget_parent (GtkWidget
* widget
)
222 GtkWidget
*result
= NULL
;
225 result
= ge_find_combo_widget(widget
);
228 result
= ge_find_combo_box_widget(widget
, TRUE
);
231 result
= ge_find_combo_box_entry_widget(widget
);
236 /***********************************************
237 * option_menu_get_props -
239 * Find Option Menu Size and Spacing
242 ***********************************************/
244 ge_option_menu_get_props (GtkWidget
* widget
,
245 GtkRequisition
* indicator_size
,
246 GtkBorder
* indicator_spacing
)
248 GtkRequisition default_size
= { 9, 5 };
249 GtkBorder default_spacing
= { 7, 5, 2, 2 };
250 GtkRequisition
*tmp_size
= NULL
;
251 GtkBorder
*tmp_spacing
= NULL
;
253 if ((widget
) && GE_IS_OPTION_MENU(widget
))
254 gtk_widget_style_get (widget
,
255 "indicator_size", &tmp_size
,
256 "indicator_spacing", &tmp_spacing
, NULL
);
260 *indicator_size
= *tmp_size
;
261 gtk_requisition_free (tmp_size
);
264 *indicator_size
= default_size
;
268 *indicator_spacing
= *tmp_spacing
;
269 gtk_border_free (tmp_spacing
);
272 *indicator_spacing
= default_spacing
;
276 ge_button_get_default_border (GtkWidget
*widget
,
279 GtkBorder default_border
= {1, 1, 1, 1};
280 GtkBorder
*tmp_border
= NULL
;
282 if (widget
&& GE_IS_BUTTON (widget
))
283 gtk_widget_style_get (widget
, "default-border", &tmp_border
, NULL
);
287 *border
= *tmp_border
;
288 gtk_border_free (tmp_border
);
292 *border
= default_border
;
298 ge_widget_is_ltr (GtkWidget
*widget
)
300 GtkTextDirection dir
= GTK_TEXT_DIR_NONE
;
302 if (GE_IS_WIDGET (widget
))
303 dir
= gtk_widget_get_direction (widget
);
305 if (dir
== GTK_TEXT_DIR_NONE
)
306 dir
= gtk_widget_get_default_direction ();
308 if (dir
== GTK_TEXT_DIR_RTL
)