static GtkWidget * add_row (CcPrivacyPanel *self, const gchar *label, const gchar *dialog_id, GtkWidget *status) { GtkWidget *box, *row, *w; row = gtk_list_box_row_new (); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 50); gtk_container_add (GTK_CONTAINER (row), box); g_object_set_data (G_OBJECT (row), "dialog-id", (gpointer)dialog_id); gtk_widget_set_hexpand (box, TRUE); gtk_container_add (GTK_CONTAINER (self->priv->list_box), row); w = gtk_label_new (label); gtk_widget_set_halign (w, GTK_ALIGN_START); gtk_widget_set_margin_start (w, 20); gtk_widget_set_margin_end (w, 20); gtk_widget_set_margin_top (w, 12); gtk_widget_set_margin_bottom (w, 12); gtk_widget_set_halign (w, GTK_ALIGN_START); gtk_widget_set_valign (w, GTK_ALIGN_CENTER); gtk_widget_set_hexpand (w, TRUE); gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); gtk_widget_set_margin_start (status, 20); gtk_widget_set_margin_end (status, 20); gtk_widget_set_halign (status, GTK_ALIGN_END); gtk_widget_set_valign (status, GTK_ALIGN_CENTER); gtk_box_pack_end (GTK_BOX (box), status, FALSE, FALSE, 0); gtk_widget_show_all (row); return row; }
static void change_orientation (GtkWidget *button, GtkWidget *toolbar) { GtkWidget *grid; GtkOrientation orientation; grid = gtk_widget_get_parent (toolbar); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) orientation = GTK_ORIENTATION_VERTICAL; else orientation = GTK_ORIENTATION_HORIZONTAL; g_object_ref (toolbar); gtk_container_remove (GTK_CONTAINER (grid), toolbar); gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar), orientation); if (orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_widget_set_hexpand (toolbar, TRUE); gtk_widget_set_vexpand (toolbar, FALSE); gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 2, 1); } else { gtk_widget_set_hexpand (toolbar, FALSE); gtk_widget_set_vexpand (toolbar, TRUE); gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 5); } g_object_unref (toolbar); }
static void pnl_tab_update_edge (PnlTab *self) { g_assert (PNL_IS_TAB (self)); switch (self->edge) { case GTK_POS_TOP: gtk_label_set_angle (self->title, 0.0); gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE); gtk_widget_set_vexpand (GTK_WIDGET (self), FALSE); break; case GTK_POS_BOTTOM: gtk_label_set_angle (self->title, 0.0); gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE); gtk_widget_set_vexpand (GTK_WIDGET (self), FALSE); break; case GTK_POS_LEFT: gtk_label_set_angle (self->title, -90.0); gtk_widget_set_hexpand (GTK_WIDGET (self), FALSE); gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE); break; case GTK_POS_RIGHT: gtk_label_set_angle (self->title, 90.0); gtk_widget_set_hexpand (GTK_WIDGET (self), FALSE); gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE); break; default: g_assert_not_reached (); } }
static void populate_flowbox_images (GtkFlowBox *flowbox) { GtkWidget *widget, *image, *label; gint i; for (i = 0; i < N_ITEMS; i++) { gchar *text = g_strdup_printf ("Item %02d", i); widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_widget_set_hexpand (widget, TRUE); image = gtk_image_new_from_icon_name ("face-wink", GTK_ICON_SIZE_DIALOG); gtk_widget_set_hexpand (image, TRUE); gtk_image_set_pixel_size (GTK_IMAGE (image), 256); label = gtk_label_new (text); gtk_container_add (GTK_CONTAINER (widget), image); gtk_container_add (GTK_CONTAINER (widget), label); gtk_widget_show_all (widget); if (text_orientation == GTK_ORIENTATION_VERTICAL) gtk_label_set_angle (GTK_LABEL (widget), 90); g_object_set_data_full (G_OBJECT (widget), "id", (gpointer)g_strdup (text), g_free); gtk_container_add (GTK_CONTAINER (flowbox), widget); g_free (text); } }
static GtkWidget* pocketvox_setup_get_notification_grid(PocketvoxSetup *setup) { setup->priv = G_TYPE_INSTANCE_GET_PRIVATE (setup, TYPE_POCKETVOX_SETUP, PocketvoxSetupPrivate); PocketvoxSetupPrivate *priv = setup->priv; GtkWidget *grid = gtk_grid_new(); GtkWidget *label_visual = gtk_label_new(_("Allow visual notifications")); GtkWidget *label_sound = gtk_label_new(_("Allow sound notifications")); gtk_misc_set_alignment(GTK_MISC(label_visual), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(label_sound), 0.0, 0.5); gtk_widget_set_hexpand(label_visual, TRUE); gtk_widget_set_hexpand(label_sound, TRUE); GtkWidget* switch_sound = gtk_switch_new(); GtkWidget* switch_visual = gtk_switch_new(); gtk_widget_set_tooltip_text(switch_sound, _("Allow sound notifications")); gtk_widget_set_tooltip_text(switch_visual, _("Allow visual notifications")); g_settings_bind(priv->settings, "visual-notification", switch_visual, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind(priv->settings, "sound-notification", switch_sound, "active", G_SETTINGS_BIND_DEFAULT); gtk_grid_attach(GTK_GRID(grid), label_visual, 0, 2, 2, 1); gtk_grid_attach(GTK_GRID(grid), switch_visual, 2, 2, 1, 1); gtk_grid_attach(GTK_GRID(grid), label_sound, 0, 3, 2, 1); gtk_grid_attach(GTK_GRID(grid), switch_sound, 2, 3, 1, 1); gtk_widget_show_all(grid); return grid; }
static void cb_reply_indicator_init (CbReplyIndicator *self) { GtkWidget *box; GtkWidget *w; gtk_widget_set_has_surface (GTK_WIDGET (self), FALSE); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); w = gtk_image_new_from_icon_name ("go-up-symbolic"); gtk_widget_set_hexpand (w, TRUE); gtk_widget_set_halign (w, GTK_ALIGN_END); gtk_container_add (GTK_CONTAINER (box), w); gtk_container_add (GTK_CONTAINER (box), gtk_label_new (_("Show Conversation"))); w = gtk_image_new_from_icon_name ("go-up-symbolic"); gtk_widget_set_hexpand (w, TRUE); gtk_widget_set_halign (w, GTK_ALIGN_START); gtk_container_add (GTK_CONTAINER (box), w); gtk_style_context_add_class (gtk_widget_get_style_context (box), "dim-label"); self->button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (self->button), box); self->revealer = gtk_revealer_new (); gtk_container_add (GTK_CONTAINER (self->revealer), self->button); gtk_widget_set_parent (self->revealer, GTK_WIDGET (self)); g_signal_connect (self->button, "clicked", G_CALLBACK (button_clicked_cb), self); }
static void ekiga_window_init_dialpad (EkigaWindow *mw) { GtkWidget *dialpad = NULL; GtkWidget *grid = NULL; grid = gtk_grid_new (); gtk_grid_set_row_spacing (GTK_GRID (grid), 18); gtk_container_set_border_width (GTK_CONTAINER (grid), 18); dialpad = ekiga_dialpad_new (mw->priv->accel); gtk_widget_set_hexpand (dialpad, FALSE); gtk_widget_set_vexpand (dialpad, FALSE); gtk_widget_set_halign (dialpad, GTK_ALIGN_CENTER); gtk_widget_set_valign (dialpad, GTK_ALIGN_CENTER); gtk_grid_attach (GTK_GRID (grid), dialpad, 0, 0, 1, 1); g_signal_connect (dialpad, "button-clicked", G_CALLBACK (dialpad_button_clicked_cb), mw); mw->priv->entry = ekiga_window_uri_entry_new (mw); gtk_widget_set_hexpand (dialpad, TRUE); gtk_widget_set_vexpand (dialpad, TRUE); gtk_widget_set_halign (mw->priv->entry, GTK_ALIGN_FILL); gtk_widget_set_valign (mw->priv->entry, GTK_ALIGN_END); gtk_grid_attach_next_to (GTK_GRID (grid), mw->priv->entry, dialpad, GTK_POS_BOTTOM, 1, 1); gtk_stack_add_named (GTK_STACK (mw->priv->main_stack), grid, "dialpad"); gtk_container_child_set (GTK_CONTAINER (mw->priv->main_stack), grid, "icon-name", "input-dialpad-symbolic", NULL); g_signal_connect (mw, "key-press-event", G_CALLBACK (key_press_event_cb), mw); }
static void chat_conversations_list_add_row_avatar (GObject *source_object, GAsyncResult *res, gpointer user_data) { ChatConversationsList *self = CHAT_CONVERSATIONS_LIST (user_data); TpContact *contact = TP_CONTACT (source_object); GError *error; GtkWidget *grid; GtkWidget *image; GtkWidget *label; GtkWidget *row; TplEvent *event; const gchar *alias; const gchar *message; gchar *markup; event = TPL_EVENT (g_object_get_data (G_OBJECT (contact), "chat-conversations-list-last-event")); alias = tp_contact_get_alias (contact); error = NULL; image = GTK_WIDGET (chat_utils_get_contact_avatar_finish (contact, res, &error)); if (error != NULL) { image = GTK_WIDGET (chat_utils_get_contact_avatar_default ()); g_warning ("Unable to get avatar for %s: %s", alias, error->message); g_error_free (error); } row = gtk_list_box_row_new (); g_object_set_data_full (G_OBJECT (row), "chat-conversations-list-contact", g_object_ref (contact), g_object_unref); gtk_container_add (GTK_CONTAINER (self), row); grid = gtk_grid_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_HORIZONTAL); gtk_grid_set_column_spacing (GTK_GRID (grid), 6); gtk_container_add (GTK_CONTAINER (row), grid); gtk_widget_set_hexpand (image, FALSE); gtk_container_add (GTK_CONTAINER (grid), image); message = tpl_text_event_get_message (TPL_TEXT_EVENT (event)); markup = g_markup_printf_escaped ("<b>%s</b>\n%s", alias, message); label = gtk_label_new (NULL); gtk_widget_set_halign (label, GTK_ALIGN_START); gtk_widget_set_hexpand (label, TRUE); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_label_set_markup (GTK_LABEL (label), markup); gtk_container_add (GTK_CONTAINER (grid), label); g_free (markup); gtk_widget_show_all (row); g_object_set_data (G_OBJECT (contact), "chat-conversations-list-last-event", NULL); g_object_unref (self); }
int main(void) { GtkWidget *mainwin; GtkWidget *vbox; GtkWidget *e1, *e2; GtkWidget *da; GtkWidget *hbox; GtkWidget *b1, *b2; gtk_init(NULL, NULL); mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(mainwin, "destroy", G_CALLBACK(gtk_main_quit), NULL); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(mainwin), vbox); e1 = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(vbox), e1); e2 = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(vbox), e2); da = gtk_drawing_area_new(); gtk_widget_set_size_request(da, -1, 30); g_signal_connect(da, "draw", G_CALLBACK(drawMidline), NULL); gtk_widget_set_vexpand(da, TRUE); gtk_widget_set_valign(da, GTK_ALIGN_FILL); gtk_container_add(GTK_CONTAINER(vbox), da); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add(GTK_CONTAINER(vbox), hbox); b1 = gtk_button_new_with_label("Button 1"); gtk_widget_set_hexpand(b1, TRUE); gtk_widget_set_halign(b1, GTK_ALIGN_FILL); gtk_container_add(GTK_CONTAINER(hbox), b1); b2 = gtk_button_new_with_label("Button 2"); gtk_widget_set_hexpand(b2, TRUE); gtk_widget_set_halign(b2, GTK_ALIGN_FILL); gtk_container_add(GTK_CONTAINER(hbox), b2); b3 = gtk_button_new_with_label("3"); gtk_widget_set_hexpand(b3, FALSE); gtk_container_add(GTK_CONTAINER(hbox), b3); g_signal_connect(e1, "changed", G_CALLBACK(changed), b1); g_signal_connect(e2, "changed", G_CALLBACK(changed), b2); gtk_widget_show_all(mainwin); gtk_main(); return 0; }
int main(void) { GtkWidget *mainwin; GtkWidget *grid; gtk_init(NULL, NULL); mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(mainwin), "Foreground Colors with CSS"); gtk_container_set_border_width(GTK_CONTAINER(mainwin), 12); g_signal_connect(mainwin, "delete-event", G_CALLBACK(quit), NULL); grid = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(grid), 6); gtk_grid_set_column_spacing(GTK_GRID(grid), 12); gtk_container_add(GTK_CONTAINER(mainwin), grid); button = gtk_button_new_with_label("Color Me!"); gtk_widget_set_hexpand(button, TRUE); gtk_widget_set_halign(button, GTK_ALIGN_FILL); gtk_widget_set_vexpand(button, TRUE); gtk_widget_set_halign(button, GTK_ALIGN_FILL); gtk_grid_attach_next_to(GTK_GRID(grid), button, NULL, GTK_POS_BOTTOM, 1, 1); foreground = gtk_color_button_new(); g_signal_connect(foreground, "color-set", G_CALLBACK(changeColor), NULL); gtk_widget_set_hexpand(foreground, TRUE); gtk_widget_set_halign(foreground, GTK_ALIGN_FILL); gtk_grid_attach_next_to(GTK_GRID(grid), foreground, button, GTK_POS_BOTTOM, 1, 1); gtk_grid_attach_next_to(GTK_GRID(grid), gtk_label_new("Foreground"), foreground, GTK_POS_LEFT, 1, 1); background = gtk_color_button_new(); g_signal_connect(background, "color-set", G_CALLBACK(changeColor), NULL); gtk_widget_set_hexpand(background, TRUE); gtk_widget_set_halign(background, GTK_ALIGN_FILL); gtk_grid_attach_next_to(GTK_GRID(grid), background, foreground, GTK_POS_BOTTOM, 1, 1); gtk_grid_attach_next_to(GTK_GRID(grid), gtk_label_new("Background"), background, GTK_POS_LEFT, 1, 1); gtk_widget_show_all(mainwin); gtk_main(); return 0; }
static GtkWidget * go_color_palette_setup (GOColorPalette *pal, char const *no_color_label, int cols, int rows, GONamedColor const *color_names) { GtkWidget *w, *grid; int pos, row, col = 0; grid = gtk_grid_new (); if (no_color_label != NULL) { w = gtk_button_new_with_label (no_color_label); gtk_widget_set_hexpand (w, TRUE); gtk_grid_attach (GTK_GRID (grid), w, 0, 0, cols, 1); g_signal_connect (w, "button_release_event", G_CALLBACK (cb_default_release_event), pal); } for (row = 0; row < rows; row++) for (col = 0; col < cols; col++) { pos = row * cols + col; if (color_names [pos].name == NULL) goto custom_colors; go_color_palette_button_new ( pal, GTK_GRID (grid), &(color_names [pos]), col, row + 1); } custom_colors : if (col > 0) row++; for (col = 0; col < cols && col < GO_COLOR_GROUP_HISTORY_SIZE; col++) { GONamedColor color_name = { 0, N_("custom") }; color_name.color = pal->group->history [col]; pal->swatches [col] = go_color_palette_button_new (pal, GTK_GRID (grid), &color_name, col, row + 1); } w = go_gtk_button_build_with_stock (_("Custom color..."), GTK_STOCK_SELECT_COLOR); gtk_button_set_alignment (GTK_BUTTON (w), 0., .5); gtk_widget_set_hexpand (w, TRUE); gtk_grid_attach (GTK_GRID (grid), w, 0, row + 2, cols, 1); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_combo_custom_clicked), pal); return grid; }
static void cb_druid_add_property (NPWProperty* property, gpointer user_data) { GtkWidget* label; GtkWidget* entry; NPWDruidAddPropertyData* data = (NPWDruidAddPropertyData *)user_data; const gchar* description; entry = npw_property_create_widget (property); if (entry != NULL) { /* Not hidden property */ description = npw_property_get_description (property); /* Set description tooltip */ if (description && (*description != '\0')) { gtk_widget_set_tooltip_text (entry, description); } label = gtk_label_new (npw_property_get_label (property)); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_misc_set_padding (GTK_MISC (label), 6, 6); gtk_widget_set_hexpand (entry, TRUE); switch (npw_property_get_type (property)) { case NPW_PACKAGE_PROPERTY: gtk_widget_set_vexpand (entry, TRUE); gtk_grid_attach (data->table, label, 0, data->row, 1, 1); gtk_grid_attach (data->table, entry, 0, data->row + 1, 1, 1); data->row += 2; break; case NPW_BOOLEAN_PROPERTY: gtk_widget_set_hexpand (entry, FALSE); /* Fall through */ default: /* Add label and entry */ gtk_grid_attach (data->table, label, 0, data->row, 1, 1); gtk_grid_attach (data->table, entry, 1, data->row, 1, 1); data->row++; } /* Set first entry */ if (data->first_entry == NULL) data->first_entry = entry; } };
static void spanning_grid (void) { GtkWidget *window; GtkWidget *g; GtkWidget *c; /* inspired by bug 698660 * the row/column that are empty except for the spanning * child need to stay collapsed */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Spanning"); g = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window), g); c = test_widget ("0", "blue"); gtk_widget_set_hexpand (c, TRUE); gtk_grid_attach (GTK_GRID (g), c, 0, 4, 4, 1); c = test_widget ("1", "green"); gtk_widget_set_vexpand (c, TRUE); gtk_grid_attach (GTK_GRID (g), c, 4, 0, 1, 4); c = test_widget ("2", "red"); gtk_widget_set_hexpand (c, TRUE); gtk_widget_set_vexpand (c, TRUE); gtk_grid_attach (GTK_GRID (g), c, 3, 3, 1, 1); c = test_widget ("3", "yellow"); gtk_grid_attach (GTK_GRID (g), c, 0, 3, 2, 1); c = test_widget ("4", "orange"); gtk_grid_attach (GTK_GRID (g), c, 3, 0, 1, 2); c = test_widget ("5", "purple"); gtk_grid_attach (GTK_GRID (g), c, 1, 1, 1, 1); c = test_widget ("6", "white"); gtk_grid_attach (GTK_GRID (g), c, 0, 1, 1, 1); c = test_widget ("7", "cyan"); gtk_grid_attach (GTK_GRID (g), c, 1, 0, 1, 1); gtk_widget_show_all (window); }
/* * create_page: * @child: the #CheeseWidget to pack into the container * @button: the #GtkButton for taking a photo * * Create the widgets for the #CheeseAvatarWidget and pack them into a * container. * * Returns: a #GtkBox containing the individual #CheeseAvatarWidget widgets */ static GtkWidget * create_page (GtkWidget *child, GtkWidget *button) { GtkWidget *vgrid, *bar; GtkStyleContext *context; vgrid = gtk_grid_new (); gtk_grid_attach (GTK_GRID (vgrid), child, 0, 0, 1, 1); gtk_widget_set_hexpand (child, TRUE); gtk_widget_set_vexpand (child, TRUE); bar = gtk_header_bar_new (); context = gtk_widget_get_style_context (GTK_WIDGET (bar)); gtk_style_context_remove_class (context, "header-bar"); gtk_style_context_add_class (context, "inline-toolbar"); gtk_style_context_add_class (context, "toolbar"); gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL); g_object_set (G_OBJECT (button), "margin-top", 6, "margin-bottom", 6, NULL); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (bar), button); gtk_grid_attach (GTK_GRID (vgrid), bar, 0, 1, 1, 1); return vgrid; }
static void digital_clock_init(DigitalClock * dclock) { DigitalClockPriv *priv; GtkWidget *w = GTK_WIDGET(dclock); dclock->priv = DIGITAL_CLOCK_GET_PRIV(dclock); priv = dclock->priv; priv->x = priv->y = 0; priv->width = priv->height = -1; priv->fsiz = 0; priv->mode12 = TRUE; priv->time_val=g_slice_alloc0(LENTIMESTR); // g_signal_connect (G_OBJECT (dclock), "draw", G_CALLBACK (_draw), dclock); dclock->priv->timeoutid = g_timeout_add(TimeOutVal, (GSourceFunc) flushtime_cb, dclock); GtkStyleContext *stylecontext = gtk_widget_get_style_context(w); gtk_style_context_add_class(stylecontext, GTK_STYLE_CLASS_BUTTON); gtk_style_context_add_class(stylecontext, "suggested-action"); gtk_widget_set_hexpand(w,TRUE); gtk_widget_set_vexpand(w,TRUE); }
GtkWidget * create_clipping_page (void) { GtkWidget *vbox, *scrolled_win, *canvas; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); g_object_set (vbox, "margin", 4, NULL); gtk_widget_show (vbox); scrolled_win = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN); gtk_widget_show (scrolled_win); gtk_box_pack_start (GTK_BOX (vbox), scrolled_win); gtk_widget_set_halign (scrolled_win, GTK_ALIGN_FILL); gtk_widget_set_valign (scrolled_win, GTK_ALIGN_FILL); gtk_widget_set_hexpand (scrolled_win, TRUE); gtk_widget_set_vexpand (scrolled_win, TRUE); canvas = goo_canvas_new (); gtk_widget_set_size_request (canvas, 600, 450); goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000); gtk_widget_show (canvas); gtk_container_add (GTK_CONTAINER (scrolled_win), canvas); setup_canvas (GOO_CANVAS (canvas)); return vbox; }
static void add_entry (GtkWidget *grid1, GtkWidget *grid2, const gchar *text, GtkWidget **out_entry) { GtkStyleContext *context; GtkWidget *label; GtkWidget *entry; label = gtk_label_new_with_mnemonic (text); context = gtk_widget_get_style_context (label); gtk_style_context_add_class (context, GTK_STYLE_CLASS_DIM_LABEL); gtk_widget_set_vexpand (label, TRUE); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_container_add (GTK_CONTAINER (grid1), label); entry = gtk_entry_new (); gtk_widget_set_hexpand (entry, TRUE); gtk_widget_set_vexpand (entry, TRUE); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); gtk_entry_set_max_length (GTK_ENTRY (entry), 132); gtk_container_add (GTK_CONTAINER (grid2), entry); gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); if (out_entry != NULL) *out_entry = entry; }
/* {{{ append_sprite_pic(…) - append an image to a sprite */ static Sprite *append_sprite_pic(Sprite *s, GdkPixbuf *pic) { debug(">>> append_sprite_pic()"); /* FIXME animated images must be supported */ GtkWidget *w = gtk_image_new_from_pixbuf(pic); if (w == NULL) { warn("append_sprite_pic(): gtk_image_new_from_pixbuf()"); goto LBL_return; } gtk_widget_set_vexpand(w, TRUE); gtk_widget_set_hexpand(w, TRUE); gtk_widget_set_vexpand_set(w, TRUE); gtk_widget_set_hexpand_set(w, TRUE); /* shrink large images */ float width = (float)gdk_pixbuf_get_width(pic); float height = (float)gdk_pixbuf_get_height(pic); float ratio = (float)width / height; /* FIXME avoid magic numbers */ if ((ratio > 1) && (width > 128)) { width = 128; height = ratio * width; } else if ((ratio <= 1) && (height > 128)) { height = 128; width = height * ratio; } gtk_widget_set_size_request(w, (gint)width, (gint)height); append_sprite_widget(s, w); LBL_return: debug("<<< append_sprite_pic()"); return s; }
static void photos_error_box_constructed (GObject *object) { PhotosErrorBox *self = PHOTOS_ERROR_BOX (object); G_OBJECT_CLASS (photos_error_box_parent_class)->constructed (object); gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER); gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE); gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER); gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE); gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing (GTK_GRID (self), 12); self->image = gtk_image_new_from_icon_name ("dialog-error", GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (self->image), 128); gtk_widget_set_halign (self->image, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->image, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), self->image); self->primary_label = gtk_label_new (NULL); gtk_label_set_use_markup (GTK_LABEL (self->primary_label), TRUE); gtk_widget_set_halign (self->primary_label, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->primary_label, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), self->primary_label); self->secondary_label = gtk_label_new (NULL); gtk_label_set_use_markup (GTK_LABEL (self->secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (self->secondary_label), TRUE); gtk_widget_set_halign (self->secondary_label, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->secondary_label, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), self->secondary_label); gtk_widget_show_all (GTK_WIDGET (self)); }
int main (int argc, char *argv[]) { GtkWidget *window, *list, *sw, *row; GtkWidget *hbox, *vbox, *combo, *button; gint i; gchar *text; gtk_init (NULL, NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), -1, 300); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_add (GTK_CONTAINER (window), hbox); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); g_object_set (vbox, "margin", 12, NULL); gtk_container_add (GTK_CONTAINER (hbox), vbox); list = gtk_list_box_new (); gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE); g_signal_connect (list, "row-activated", G_CALLBACK (on_row_activated), NULL); g_signal_connect (list, "selected-rows-changed", G_CALLBACK (on_selected_children_changed), NULL); g_signal_connect (gtk_widget_get_accessible (list), "selection-changed", G_CALLBACK (a11y_selection_changed), NULL); sw = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_hexpand (sw, TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (hbox), sw); gtk_container_add (GTK_CONTAINER (sw), list); button = gtk_check_button_new_with_label ("Activate on single click"); g_object_bind_property (list, "activate-on-single-click", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); gtk_container_add (GTK_CONTAINER (vbox), button); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "None"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Single"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Browse"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Multiple"); g_signal_connect (combo, "changed", G_CALLBACK (selection_mode_changed), list); gtk_container_add (GTK_CONTAINER (vbox), combo); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), gtk_list_box_get_selection_mode (GTK_LIST_BOX (list))); for (i = 0; i < 20; i++) { text = g_strdup_printf ("Row %d", i); row = create_row (text); gtk_list_box_insert (GTK_LIST_BOX (list), row, -1); } gtk_widget_show_all (window); gtk_main (); return 0; }
static GladeEditorProperty * append_item (GladeEditorTable *table, GladePropertyClass *klass, gboolean from_query_dialog) { GladeEditorProperty *property; GtkWidget *label; if (!(property = glade_widget_adaptor_create_eprop (glade_property_class_get_adaptor (klass), klass, from_query_dialog == FALSE))) { g_critical ("Unable to create editor for property '%s' of class '%s'", glade_property_class_id (klass), glade_widget_adaptor_get_name (glade_property_class_get_adaptor (klass))); return NULL; } gtk_widget_show (GTK_WIDGET (property)); gtk_widget_show_all (glade_editor_property_get_item_label (property)); label = glade_editor_property_get_item_label (property); gtk_widget_set_hexpand (label, FALSE); glade_editor_table_attach (table, label, 0, table->priv->rows); glade_editor_table_attach (table, GTK_WIDGET (property), 1, table->priv->rows); table->priv->rows++; return property; }
static void gs_editor_refresh_choice (GsEditor *self) { GPtrArray *apps; GtkContainer *container; /* add all apps */ container = GTK_CONTAINER (gtk_builder_get_object (self->builder, "flowbox_main")); gs_container_remove_all (GTK_CONTAINER (container)); apps = as_store_get_apps (self->store); for (guint i = 0; i < apps->len; i++) { AsApp *item = g_ptr_array_index (apps, i); GtkWidget *tile = NULL; g_autoptr(GsApp) app = NULL; app = gs_editor_convert_app (self, item); tile = gs_summary_tile_new (app); g_signal_connect (tile, "clicked", G_CALLBACK (gs_editor_app_tile_clicked_cb), self); gtk_widget_set_visible (tile, TRUE); gtk_widget_set_vexpand (tile, FALSE); gtk_widget_set_hexpand (tile, FALSE); gtk_widget_set_size_request (tile, 300, 50); gtk_widget_set_valign (tile, GTK_ALIGN_START); gtk_container_add (GTK_CONTAINER (container), tile); } }
void hig_workarea_add_section_title_widget (GtkWidget * t, guint * row, GtkWidget * w) { gtk_widget_set_hexpand (w, TRUE); gtk_grid_attach (GTK_GRID (t), w, 0, *row, 2, 1); ++ * row; }
static void empty_line (void) { GtkWidget *window; GtkWidget *grid; GtkWidget *child; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Empty row"); grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window), grid); gtk_grid_set_row_spacing (GTK_GRID (grid), 10); gtk_grid_set_column_spacing (GTK_GRID (grid), 10); child = test_widget ("(0, 0)", "red"); gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1); gtk_widget_set_hexpand (child, TRUE); gtk_widget_set_vexpand (child, TRUE); gtk_grid_attach (GTK_GRID (grid), test_widget ("(0, 1)", "blue"), 0, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), test_widget ("(10, 0)", "green"), 10, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), test_widget ("(10, 1)", "magenta"), 10, 1, 1, 1); gtk_widget_show_all (window); }
static void add_new_filechooser_button (const gchar *mnemonic, const gchar *chooser_title, GtkFileChooserAction action, GtkWidget *group_box, GtkSizeGroup *label_group) { GtkWidget *hbox, *label, *chooser, *button; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (group_box), hbox); label = gtk_label_new_with_mnemonic (mnemonic); gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_box_pack_start (GTK_BOX (hbox), label); chooser = gtk_file_chooser_button_new (g_strconcat(chooser_title, " - testfilechooserbutton", NULL), action); gtk_widget_set_hexpand (chooser, TRUE); gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (chooser), gtk_src_dir, NULL); gtk_file_chooser_remove_shortcut_folder (GTK_FILE_CHOOSER (chooser), gtk_src_dir, NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser); g_signal_connect (chooser, "current-folder-changed", G_CALLBACK (chooser_current_folder_changed_cb), NULL); g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL); g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL); g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL); gtk_box_pack_start (GTK_BOX (hbox), chooser); button = gtk_button_new_with_label ("Tests"); g_signal_connect (button, "clicked", G_CALLBACK (tests_button_clicked_cb), chooser); gtk_box_pack_start (GTK_BOX (hbox), button); }
GtkWidget * do_foreigndrawing (GtkWidget *do_widget) { static GtkWidget *window = NULL; if (!window) { GtkWidget *box; GtkWidget *da; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Foreign drawing"); gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_container_add (GTK_CONTAINER (window), box); da = gtk_drawing_area_new (); gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400); gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400); gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_func, NULL, NULL); gtk_widget_set_hexpand (da, TRUE); gtk_widget_set_vexpand (da, TRUE); gtk_container_add (GTK_CONTAINER (box), da); } if (!gtk_widget_get_visible (window)) gtk_widget_show (window); else gtk_widget_destroy (window); return window; }
/** * gimp_grid_attach_aligned: * @grid: The #GtkGrid the widgets will be attached to. * @left: The column to start with. * @top: The row to attach the widgets. * @label_text: The text for the #GtkLabel which will be attached left of * the widget. * @xalign: The horizontal alignment of the #GtkLabel. * @yalign: The vertical alignment of the #GtkLabel. * @widget: The #GtkWidget to attach right of the label. * @columns: The number of columns the widget will use. * * Note that the @label_text can be %NULL and that the widget will be * attached starting at (@column + 1) in this case, too. * * Returns: The created #GtkLabel. **/ GtkWidget * gimp_grid_attach_aligned (GtkGrid *grid, gint left, gint top, const gchar *label_text, gfloat xalign, gfloat yalign, GtkWidget *widget, gint columns) { GtkWidget *label = NULL; if (label_text) { GtkWidget *mnemonic_widget; label = gtk_label_new_with_mnemonic (label_text); gtk_label_set_xalign (GTK_LABEL (label), xalign); gtk_label_set_yalign (GTK_LABEL (label), yalign); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_grid_attach (grid, label, left, top, 1, 1); gtk_widget_show (label); mnemonic_widget = find_mnemonic_widget (widget, 0); if (mnemonic_widget) gtk_label_set_mnemonic_widget (GTK_LABEL (label), mnemonic_widget); } gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (grid, widget, left + 1, top, columns, 1); gtk_widget_show (widget); return label; }
static void populate_action_arguments_grid (GtkWidget *grid, GList *arguments, GUPnPServiceActionArgDirection direction, GUPnPServiceIntrospection *introspection) { GList *arg_node; GtkWidget *last_aligner_grid = NULL; g_assert (introspection != NULL); prepare_action_arguments_grid (GTK_CONTAINER (grid), direction, arguments); gtk_widget_set_size_request (dialog, 0, 0); for (arg_node = arguments; arg_node; arg_node = arg_node->next) { GUPnPServiceActionArgInfo *arg_info; GtkWidget *aligner_grid; GtkWidget *label; GtkWidget *input_widget; arg_info = (GUPnPServiceActionArgInfo *) arg_node->data; /* First add the name */ /* GTK_ALIGN_START seems to have a bug in a size group: * use a container for alignment */ aligner_grid = gtk_grid_new (); gtk_grid_attach_next_to (GTK_GRID (grid), aligner_grid, last_aligner_grid, GTK_POS_BOTTOM, 1, 1); last_aligner_grid = aligner_grid; label = gtk_label_new (arg_info->name); gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_set_vexpand (label, TRUE); gtk_widget_set_halign (label, GTK_ALIGN_START); gtk_grid_attach (GTK_GRID (aligner_grid), label, 0, 0, 1, 1); gtk_size_group_add_widget (label_container_group, aligner_grid); gtk_widget_show_all (aligner_grid); /* Then the input widget */ input_widget = create_widget_for_argument (arg_info, introspection); gtk_widget_set_hexpand (input_widget, TRUE); gtk_grid_attach_next_to (GTK_GRID (grid), input_widget, aligner_grid, GTK_POS_RIGHT, 1,1); gtk_widget_show_all (input_widget); } }
void hig_workarea_add_wide_tall_control (GtkWidget * t, guint * row, GtkWidget * w) { gtk_widget_set_hexpand (w, TRUE); gtk_widget_set_vexpand (w, TRUE); hig_workarea_add_wide_control (t, row, w); }
GtkWidget * gnm_dao_new (WBCGtk *wbcg, gchar *inplace_str) { GnmDao *gdao = GNM_DAO (g_object_new (GNM_DAO_TYPE, NULL)); GtkGrid *grid; g_return_val_if_fail (wbcg != NULL, NULL); gdao->wbcg = wbcg; /* Create the output range expression entry */ grid = GTK_GRID (go_gtk_builder_get_widget (gdao->gui, "output-grid")); gdao->output_entry = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (gdao->output_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (gdao->output_entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (gdao->output_entry), 1, 3, 1, 1); go_atk_setup_label (gdao->output_range, GTK_WIDGET (gdao->output_entry)); gtk_widget_show (GTK_WIDGET (gdao->output_entry)); /* Finished creating the output range expression entry */ gnm_dao_set_inplace (gdao, inplace_str); gnm_dao_setup_signals (gdao); cb_set_sensitivity (NULL, gdao); return GTK_WIDGET (gdao); }