static VALUE rg_padding(VALUE self) { guint top, bottom, left, right; gtk_alignment_get_padding(RVAL2GTKALIGNMENT(self), &top, &bottom, &left, &right); return rb_ary_new3(4, UINT2NUM(top), UINT2NUM(bottom), UINT2NUM(left), UINT2NUM(right)); }
/* * Modify padding of the content area of the GtkDialog * so it is aligned with the action area. */ static void update_alignment_padding (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data) { PpOptionsDialog *dialog = (PpOptionsDialog*) user_data; GtkAllocation allocation1, allocation2; GtkWidget *action_area; GtkWidget *content_area; gint offset_left, offset_right; guint padding_left, padding_right, padding_top, padding_bottom; action_area = (GtkWidget*) gtk_builder_get_object (dialog->builder, "dialog-action-area1"); gtk_widget_get_allocation (action_area, &allocation2); content_area = (GtkWidget*) gtk_builder_get_object (dialog->builder, "content-alignment"); gtk_widget_get_allocation (content_area, &allocation1); offset_left = allocation2.x - allocation1.x; offset_right = (allocation1.x + allocation1.width) - (allocation2.x + allocation2.width); gtk_alignment_get_padding (GTK_ALIGNMENT (content_area), &padding_top, &padding_bottom, &padding_left, &padding_right); if (allocation1.x >= 0 && allocation2.x >= 0) { if (offset_left > 0 && offset_left != padding_left) gtk_alignment_set_padding (GTK_ALIGNMENT (content_area), padding_top, padding_bottom, offset_left, padding_right); gtk_alignment_get_padding (GTK_ALIGNMENT (content_area), &padding_top, &padding_bottom, &padding_left, &padding_right); if (offset_right > 0 && offset_right != padding_right) gtk_alignment_set_padding (GTK_ALIGNMENT (content_area), padding_top, padding_bottom, padding_left, offset_right); } }
/* Make the size of dialogs smaller by breaking GNOME HIG * http://library.gnome.org/devel/hig-book/stable/design-window.html.en * According to GNOME HIG, spacings are increased by the multiples of 6. * Change them to the multiples of 1 can greatly reduce the required size * while still keeping some degree of spacing. */ static void break_gnome_hig( GtkWidget* w, gpointer _factor ) { int factor = GPOINTER_TO_INT(_factor); /* g_debug( G_OBJECT_TYPE_NAME(w) ); */ if( GTK_IS_CONTAINER(w) ) { int val; val = gtk_container_get_border_width( (GtkContainer*)w ); /* border of dialog defaults to 12 under gnome */ if( GTK_IS_DIALOG(w) ) { if( val > 0 ) gtk_container_set_border_width( (GtkContainer*)w, val / factor ); } else { if( GTK_IS_BOX(w) ) /* boxes, spacing defaults to 6, 12, 18 under gnome */ { int spacing = gtk_box_get_spacing( (GtkBox*)w ); gtk_box_set_spacing( (GtkBox*)w, spacing / factor ); } else if( GTK_IS_TABLE(w) ) /* tables, spacing defaults to 6, 12, 18 under gnome */ { int spacing; int col, row; g_object_get( w, "n-columns", &col, "n-rows", &row, NULL ); if( col > 1 ) { --col; while( --col >= 0 ) { spacing = gtk_table_get_col_spacing( (GtkTable*)w, col ); if( spacing > 0 ) gtk_table_set_col_spacing( (GtkTable*)w, col, spacing / factor ); } } if( row > 1 ) { --row; while( --row >= 0 ) { spacing = gtk_table_get_row_spacing( (GtkTable*)w, row ); if( spacing > 0 ) gtk_table_set_row_spacing( (GtkTable*)w, row, spacing / factor ); } } /* FIXME: handle default spacings */ } else if( GTK_IS_ALIGNMENT(w) ) /* groups, has 12 px indent by default */ { int t, b, l, r; gtk_alignment_get_padding( (GtkAlignment*)w, &t, &b, &l, &r ); if( l > 0 ) { l /= (factor / 2); /* groups still need proper indent not to hurt usability */ gtk_alignment_set_padding( (GtkAlignment*)w, t, b, l, r ); } } if( val > 0 ) gtk_container_set_border_width( (GtkContainer*)w, val * 2 / factor ); } gtk_container_foreach( (GtkContainer*)w, break_gnome_hig, GINT_TO_POINTER(factor) ); } }