/* Outputs source to add a child widget to a hbox/vbox. */ void gb_box_write_add_child_source (GtkWidget * parent, const gchar *parent_name, GtkWidget *child, GbWidgetWriteSourceData * data) { gboolean expand, fill; guint padding; GtkPackType pack_type; gtk_box_query_child_packing (GTK_BOX (parent), child, &expand, &fill, &padding, &pack_type); if (pack_type == GTK_PACK_START) { source_add (data, " gtk_box_pack_start (GTK_BOX (%s), %s, %s, %s, %i);\n", parent_name, data->wname, expand ? "TRUE" : "FALSE", fill ? "TRUE" : "FALSE", padding); } else { source_add (data, " gtk_box_pack_end (GTK_BOX (%s), %s, %s, %s, %i);\n", parent_name, data->wname, expand ? "TRUE" : "FALSE", fill ? "TRUE" : "FALSE", padding); } }
static void gb_box_insert_after (GtkWidget * menuitem, GtkWidget * child) { GtkWidget *box, *newchild; guint pos; gboolean expand, fill; guint padding; GtkPackType pack_type; box = child->parent; pos = glade_util_get_box_pos (GTK_BOX (box), child); g_return_if_fail (pos != -1); newchild = editor_new_placeholder (); gtk_box_query_child_packing (GTK_BOX (box), child, &expand, &fill, &padding, &pack_type); if (pack_type == GTK_PACK_START) { gtk_box_pack_start (GTK_BOX (box), newchild, TRUE, TRUE, 0); gtk_box_reorder_child (GTK_BOX (box), newchild, pos + 1); } else { gtk_box_pack_end (GTK_BOX (box), newchild, TRUE, TRUE, 0); gtk_box_reorder_child (GTK_BOX (box), newchild, pos); } }
/* Applies or loads the child properties of a child of a hbox/vbox. */ void gb_box_set_child_properties (GtkWidget *widget, GtkWidget *child, GbWidgetSetArgData *data) { gint position, padding; guint old_padding; gboolean expand, fill, pack, set_child_packing = FALSE; gboolean old_expand, old_fill; GtkPackType old_pack_type; position = gb_widget_input_int (data, GbPosition); if (data->apply) { gtk_box_reorder_child (GTK_BOX (widget), child, position); } gtk_box_query_child_packing (GTK_BOX (widget), child, &old_expand, &old_fill, &old_padding, &old_pack_type); padding = gb_widget_input_int (data, GbPadding); if (data->apply) set_child_packing = TRUE; else padding = old_padding; expand = gb_widget_input_bool (data, GbExpand); if (data->apply) set_child_packing = TRUE; else expand = old_expand; fill = gb_widget_input_bool (data, GbFill); if (data->apply) set_child_packing = TRUE; else fill = old_fill; if (data->action == GB_APPLYING) { pack = gb_widget_input_bool (data, GbPack); } else { gchar *pack_symbol = gb_widget_input_string (data, GbPack); pack = pack_symbol && !strcmp (pack_symbol, "GTK_PACK_START"); } if (data->apply) set_child_packing = TRUE; else pack = (old_pack_type == GTK_PACK_START) ? TRUE : FALSE; if (set_child_packing) gtk_box_set_child_packing (GTK_BOX (widget), child, expand, fill, padding, pack ? GTK_PACK_START : GTK_PACK_END); }
void set_panarea_padding(GtkWidget *child, gpointer data) { void set_child_padding(GtkWidget *child, gpointer user_data) { GtkBox *box = GTK_BOX(user_data); gboolean expand, fill; guint pad; GtkPackType pack; gtk_box_query_child_packing(box, child, &expand, &fill, &pad, &pack); gtk_box_set_child_packing(box, child, expand, fill, 0, pack); }
static void brasero_file_chooser_find_pane (GtkWidget *child, gpointer footer) { if (GTK_IS_PANED (child)) { GList *children_vbox; GList *iter_vbox; GtkWidget *vbox; vbox = gtk_paned_get_child2 (GTK_PANED (child)); children_vbox = gtk_container_get_children (GTK_CONTAINER (vbox)); for (iter_vbox = children_vbox; iter_vbox; iter_vbox = iter_vbox->next) { if (GTK_IS_BOX (iter_vbox->data) && gtk_orientable_get_orientation (GTK_ORIENTABLE (iter_vbox->data)) == GTK_ORIENTATION_HORIZONTAL) { GtkPackType packing; gtk_box_query_child_packing (GTK_BOX (vbox), GTK_WIDGET (iter_vbox->data), NULL, NULL, NULL, &packing); if (packing == GTK_PACK_START) { GtkRequisition total_request, footer_request; gtk_widget_get_preferred_size (GTK_WIDGET (vbox), &total_request, NULL); gtk_widget_get_preferred_size (GTK_WIDGET (iter_vbox->data), &footer_request, NULL); *((gint *) footer) = total_request.height - footer_request.height; break; } } } g_list_free (children_vbox); } else if (GTK_IS_CONTAINER (child)) { gtk_container_foreach (GTK_CONTAINER (child), brasero_file_chooser_find_pane, footer); } }
void go_gtk_widget_replace (GtkWidget *victim, GtkWidget *replacement) { GtkContainer *parent = GTK_CONTAINER (gtk_widget_get_parent (victim)); if (GTK_IS_GRID (parent)) { int col, row, width, height; gtk_container_child_get (parent, victim, "left-attach", &col, "top-attach", &row, "width", &width, "height", &height, NULL); gtk_container_remove (parent, victim); gtk_grid_attach (GTK_GRID (parent), replacement, col, row, width, height); } else if (GTK_IS_BOX (parent)) { GtkBox *box = GTK_BOX (parent); gboolean expand, fill; guint padding; GtkPackType pack_type; int pos; gtk_box_query_child_packing (box, victim, &expand, &fill, &padding, &pack_type); gtk_container_child_get (parent, victim, "position", &pos, NULL); gtk_container_remove (parent, victim); gtk_container_add (parent, replacement); gtk_box_set_child_packing (box, replacement, expand, fill, padding, pack_type); gtk_box_reorder_child (box, replacement, pos); } else { g_error ("Unsupported container: %s", g_type_name_from_instance ((gpointer)parent)); } }
void gb_box_get_child_properties (GtkWidget *widget, GtkWidget *child, GbWidgetGetArgData *data) { gboolean expand, fill; gint position; guint padding; GtkPackType pack_type; if (data->action == GB_SAVING) save_start_tag (data, "packing"); if (data->action == GB_SHOWING) { position = glade_util_get_box_pos (GTK_BOX (widget), child); gb_widget_output_int (data, GbPosition, position); } gtk_box_query_child_packing (GTK_BOX (widget), child, &expand, &fill, &padding, &pack_type); gb_widget_output_int (data, GbPadding, padding); gb_widget_output_bool (data, GbExpand, expand); gb_widget_output_bool (data, GbFill, fill); if (data->action == GB_SAVING) { /* Save pack type as an enum symbol rather than a bool */ if (pack_type == GTK_PACK_END) { gb_widget_output_string (data, GbPack, "GTK_PACK_END"); } } else { gb_widget_output_bool (data, GbPack, pack_type == GTK_PACK_START); } if (data->action == GB_SAVING) save_end_tag (data, "packing"); }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkBox_gtk_1box_1query_1child_1packing ( JNIEnv* env, jclass cls, jlong _self, jlong _child, jbooleanArray _expand, jbooleanArray _fill, jintArray _padding, jintArray _packType ) { GtkBox* self; GtkWidget* child; gboolean* expand; gboolean* fill; guint* padding; GtkPackType* packType; // convert parameter self self = (GtkBox*) _self; // convert parameter child child = (GtkWidget*) _child; // convert parameter expand expand = (gboolean*) (*env)->GetBooleanArrayElements(env, _expand, NULL); if (expand == NULL) { return; // Java Exception already thrown } // convert parameter fill fill = (gboolean*) (*env)->GetBooleanArrayElements(env, _fill, NULL); if (fill == NULL) { return; // Java Exception already thrown } // convert parameter padding padding = (guint*) (*env)->GetIntArrayElements(env, _padding, NULL); if (padding == NULL) { return; // Java Exception already thrown } // convert parameter packType packType = (GtkPackType*) (*env)->GetIntArrayElements(env, _packType, NULL); if (packType == NULL) { return; // Java Exception already thrown } // call function gtk_box_query_child_packing(self, child, expand, fill, padding, packType); // cleanup parameter self // cleanup parameter child // cleanup parameter expand (*env)->ReleaseBooleanArrayElements(env, _expand, (jboolean*)expand, 0); // cleanup parameter fill (*env)->ReleaseBooleanArrayElements(env, _fill, (jboolean*)fill, 0); // cleanup parameter padding (*env)->ReleaseIntArrayElements(env, _padding, (jint*)padding, 0); // cleanup parameter packType (*env)->ReleaseIntArrayElements(env, _packType, (jint*)packType, 0); }