static void check_buttonbox_child_position (GtkWidget *child, ThemeMatchData *match_data) { GList *children = NULL; GList *l; GtkWidget *bbox; gboolean secondary; g_assert (GTK_IS_BUTTON_BOX (child->parent)); bbox = child->parent; secondary = gtk_button_box_get_child_secondary (GTK_BUTTON_BOX (bbox), child); for (l = GTK_BOX (bbox)->children; l != NULL; l = l->next) { GtkBoxChild *child_info = l->data; GtkWidget *widget = child_info->widget; if (child_info->is_secondary == secondary && gtk_widget_is_drawable (widget)) children = g_list_prepend (children, widget); } check_child_position (child, children, match_data); g_list_free (children); }
void go_gtk_help_button_init (GtkWidget *w, char const *data_dir, char const *app, char const *link) { CBHelpPaths *paths = g_new (CBHelpPaths, 1); GtkWidget *parent = gtk_widget_get_parent (w); if (GTK_IS_BUTTON_BOX (parent)) gtk_button_box_set_child_secondary ( GTK_BUTTON_BOX (parent), w, TRUE); paths->data_dir = data_dir; paths->app = app; paths->link = link; g_signal_connect_data (G_OBJECT (w), "clicked", G_CALLBACK (cb_help), (gpointer) paths, (GClosureNotify)g_free, G_CONNECT_SWAPPED); }
static gboolean draw_simple_image (GtkStyle *style, GdkWindow *window, GdkRectangle *area, GtkWidget *widget, ThemeMatchData *match_data, gboolean draw_center, gint x, gint y, gint width, gint height) { gboolean maemo_position_theming; ThemeImage *image; if ((width == -1) && (height == -1)) gdk_drawable_get_size (window, &width, &height); else if (width == -1) gdk_drawable_get_size (window, &width, NULL); else if (height == -1) gdk_drawable_get_size (window, NULL, &height); if (!(match_data->flags & THEME_MATCH_ORIENTATION)) { match_data->flags |= THEME_MATCH_ORIENTATION; if (height > width) match_data->orientation = GTK_ORIENTATION_VERTICAL; else match_data->orientation = GTK_ORIENTATION_HORIZONTAL; } /* Check for maemo-position-theming to update the position data */ if (widget && widget->parent && gtk_widget_class_find_style_property (GTK_WIDGET_GET_CLASS (widget->parent), "maemo-position-theming")) { gtk_widget_style_get (widget->parent, "maemo-position-theming", &maemo_position_theming, NULL); if (maemo_position_theming) { if (GTK_IS_BUTTON_BOX (widget->parent)) check_buttonbox_child_position (widget, match_data); else { /* Generic code for other kinds of containers */ GList *children; children = gtk_container_get_children (GTK_CONTAINER (widget->parent)); check_child_position (widget, children, match_data); g_list_free (children); } } } image = match_theme_image (style, match_data); if (image) { if (image->background) { GdkWindow *maskwin; GdkBitmap *mask = NULL; gboolean valid; maskwin = get_window_for_shape (image, window, widget, x, y, width, height); if (maskwin) mask = gdk_pixmap_new (maskwin, width, height, 1); valid = theme_pixbuf_render (image->background, G_OBJECT_TYPE (widget), window, mask, area, draw_center ? COMPONENT_ALL : COMPONENT_ALL | COMPONENT_CENTER, FALSE, x, y, width, height); if (mask) { if (valid) gdk_window_shape_combine_mask (maskwin, mask, 0, 0); g_object_unref (mask); } } if (image->overlay && draw_center) theme_pixbuf_render (image->overlay, G_OBJECT_TYPE (widget), window, NULL, area, COMPONENT_ALL, TRUE, x, y, width, height); return TRUE; } else return FALSE; }
static void asgtk_image_view_make_parts (ASGtkImageView * iv, Bool horizontal) { iv->frame = gtk_aspect_frame_new (NULL, 0.5, 0.5, 1.0, TRUE); gtk_frame_set_shadow_type (GTK_FRAME (iv->frame), GTK_SHADOW_NONE); gtk_widget_show (iv->frame); colorize_gtk_widget (iv->frame, get_colorschemed_style_normal ()); iv->scrolled_window = ASGTK_SCROLLED_WINDOW (GTK_POLICY_NEVER, GTK_POLICY_NEVER, GTK_SHADOW_NONE); ASGTK_CONTAINER_ADD (iv->frame, iv->scrolled_window); if (!get_flags (iv->flags, ASGTK_IMAGE_VIEW_SCALE_TO_VIEW | ASGTK_IMAGE_VIEW_TILE_TO_VIEW)) { gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (iv->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); } colorize_gtk_widget (GTK_WIDGET (iv->scrolled_window), get_colorschemed_style_normal ()); iv->view = gtk_image_new_from_pixbuf (NULL); gtk_widget_show (GTK_WIDGET (iv->view)); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (iv->scrolled_window), GTK_WIDGET (iv->view)); colorize_gtk_widget (GTK_WIDGET (iv->view), get_colorschemed_style_normal ()); g_signal_connect ((gpointer) iv->scrolled_window, "size-allocate", G_CALLBACK (asgtk_imview_view_size_alloc), iv); iv->details_label = gtk_label_new (NO_IMAGE_TEXT); gtk_widget_show (iv->details_label); iv->details_frame = gtk_frame_new (NULL); gtk_widget_show (iv->details_frame); gtk_container_set_border_width (GTK_CONTAINER (iv->details_frame), 1); gtk_frame_set_shadow_type (GTK_FRAME (iv->details_frame), GTK_SHADOW_IN); colorize_gtk_widget (iv->details_frame, get_colorschemed_style_normal ()); iv->tools_hbox = horizontal ? gtk_vbox_new (FALSE, 0) : gtk_hbutton_box_new (); gtk_container_set_border_width (GTK_CONTAINER (iv->tools_hbox), 0); if (GTK_IS_BUTTON_BOX (iv->tools_hbox)) gtk_button_box_set_layout (GTK_BUTTON_BOX (iv->tools_hbox), GTK_BUTTONBOX_END /*SPREAD*/); gtk_widget_show (iv->tools_hbox); iv->details_hbox = horizontal ? gtk_vbutton_box_new () : gtk_hbutton_box_new (); gtk_container_set_border_width (GTK_CONTAINER (iv->details_hbox), 0); gtk_button_box_set_layout (GTK_BUTTON_BOX (iv->details_hbox), GTK_BUTTONBOX_EDGE); gtk_widget_show (iv->details_hbox); gtk_container_add (GTK_CONTAINER (iv->details_frame), iv->details_hbox); gtk_box_pack_end (GTK_BOX (iv->details_hbox), iv->details_label, TRUE, TRUE, 0); }
/* This updates the box size to the given value, adding placeholders or deleting widgets as necessary. */ void gb_box_set_size (GtkWidget * widget, gint size) { GtkWidget *new_child; gint current_size = g_list_length (GTK_BOX (widget)->children); gint i; if (current_size < size) { /* This avoids any problems with redrawing the selection. */ editor_clear_selection (NULL); for (i = 0; i < size - current_size; i++) { if (GTK_IS_BUTTON_BOX (widget)) { new_child = gb_widget_new ("GtkButton", widget); GTK_WIDGET_SET_FLAGS (new_child, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (widget), new_child, TRUE, TRUE, 0); tree_add_widget (new_child); } else { new_child = editor_new_placeholder (); gtk_box_pack_start (GTK_BOX (widget), new_child, TRUE, TRUE, 0); } } } else if (current_size > size) { GList *children, *elem; GtkWidget *child; gchar *error = NULL; /* Get a list of children in the order they appear in the box, start at the end and move backwards until we find a widget that can be destroyed. If we can't find any, show a message box. */ children = gtk_container_get_children (GTK_CONTAINER (widget)); elem = g_list_last (children); while (elem) { child = elem->data; error = editor_can_delete_widget (child); if (!error) { gtk_container_remove (GTK_CONTAINER (widget), child); current_size--; if (current_size == size) break; } elem = elem->prev; } g_list_free (children); if (current_size > size) { glade_util_show_message_box (error ? error : _("Can't delete any children."), widget); } } }