当前位置: 首页>>代码示例>>C++>>正文


C++ gtk_widget_set_halign函数代码示例

本文整理汇总了C++中gtk_widget_set_halign函数的典型用法代码示例。如果您正苦于以下问题:C++ gtk_widget_set_halign函数的具体用法?C++ gtk_widget_set_halign怎么用?C++ gtk_widget_set_halign使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gtk_widget_set_halign函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process_single_field

static void process_single_field(
        GtkWidget * container,
        int row_index,
        const char * label,
        const char * value,
        int is_password) {

    GtkWidget * label_widget = gtk_label_new(label);
    gtk_widget_set_halign(GTK_WIDGET(label_widget), GTK_ALIGN_END);
    gtk_widget_set_margin_end(GTK_WIDGET(label_widget), 5);
    GtkWidget * value_widget = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(value_widget), value);
    gtk_widget_set_hexpand(GTK_WIDGET(value_widget), TRUE);

    g_object_set(G_OBJECT(value_widget),
        "editable", FALSE,
        NULL
    );

    GtkWidget * copy_button = NULL, *reveal_button = NULL;

    if(is_password) {
        gtk_entry_set_visibility(GTK_ENTRY(value_widget), FALSE);
        copy_button = gtk_button_new_with_mnemonic("_Copy");
        g_signal_connect(G_OBJECT(copy_button), "clicked",
            G_CALLBACK(handle_copy_button), value_widget);
        reveal_button = gtk_button_new_with_mnemonic("_Reveal");
        g_signal_connect(G_OBJECT(reveal_button), "clicked",
            G_CALLBACK(handle_reveal_button), value_widget);
    }

    gtk_grid_attach(GTK_GRID(container), label_widget, 0, row_index, 1, 1);
    gtk_grid_attach(GTK_GRID(container), value_widget, 1, row_index, copy_button == NULL ? 3 : 1, 1);
    if(copy_button) {
        gtk_grid_attach(GTK_GRID(container), copy_button, 2, row_index, 1, 1);
        gtk_grid_attach(GTK_GRID(container), reveal_button, 3, row_index, 1, 1);
    }
}
开发者ID:mflopez79,项目名称:gonepass,代码行数:38,代码来源:item_builder.c

示例2: gui_init

void gui_init(dt_lib_module_t *self)
{
  self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_PIXEL_APPLY_DPI(5));
  self->data = calloc(1, sizeof(dt_lib_session_t));

  // Setup lib data
  dt_lib_session_t *lib = self->data;

  // Setup gui
  self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_PIXEL_APPLY_DPI(5));
  GtkBox *hbox, *vbox1, *vbox2;

  // Session settings
  hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_PIXEL_APPLY_DPI(5)));
  vbox1 = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_PIXEL_APPLY_DPI(5)));
  vbox2 = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_PIXEL_APPLY_DPI(5)));

  lib->gui.label1 = GTK_LABEL(gtk_label_new(_("jobcode")));
  gtk_widget_set_halign(GTK_WIDGET(lib->gui.label1), GTK_ALIGN_START);
  gtk_box_pack_start(vbox1, GTK_WIDGET(lib->gui.label1), TRUE, TRUE, 0);

  lib->gui.entry1 = GTK_ENTRY(gtk_entry_new());
  gtk_entry_set_width_chars(GTK_ENTRY(lib->gui.entry1), 0);
  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(lib->gui.entry1));
  gtk_box_pack_start(vbox2, GTK_WIDGET(lib->gui.entry1), TRUE, TRUE, 0);

  lib->gui.button1 = GTK_BUTTON(gtk_button_new_with_label(_("create")));
  gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox1), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox2), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(lib->gui.button1), TRUE, TRUE, 0);

  g_signal_connect(G_OBJECT(lib->gui.button1), "clicked", G_CALLBACK(create_callback), self);

  gchar *str = dt_conf_get_string("plugins/session/jobcode");
  gtk_entry_set_text(lib->gui.entry1, str);
  g_free(str);
}
开发者ID:CarVac,项目名称:darktable,代码行数:38,代码来源:session.c

示例3: agreement_app_window_init

static void agreement_app_window_init(AgreementAppWindow *win)
{
    gtk_window_set_title(GTK_WINDOW(win), "Agreement");
    gtk_window_set_default_size(GTK_WINDOW(win), 800, 500);

    GtkWidget* grid;
    grid = gtk_grid_new();
    gtk_container_add(GTK_CONTAINER(win), grid);

    GtkWidget *view;
    view = gtk_text_view_new();
    gtk_widget_set_hexpand(view, true);
    gtk_widget_set_vexpand(view, true);
    gtk_grid_attach(GTK_GRID(grid), view, 0, 0, 1, 1);

    agreement_text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
    gtk_text_buffer_set_text(agreement_text_buffer, "No file loaded", -1);

    GtkWidget *flow_box;
    flow_box = gtk_flow_box_new();
    gtk_flow_box_set_min_children_per_line(GTK_FLOW_BOX(flow_box), 2);
    gtk_widget_set_halign(flow_box, GTK_ALIGN_CENTER);
    gtk_grid_attach(GTK_GRID(grid), flow_box, 0, 1, 1, 1);

    GtkWidget *no_button;
    no_button = gtk_button_new_from_icon_name("window-close", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_always_show_image(GTK_BUTTON(no_button), true);
    gtk_button_set_label(GTK_BUTTON(no_button), "No, I do not agree");
    gtk_container_add(GTK_CONTAINER(flow_box), no_button);

    GtkWidget *yes_button;
    yes_button = gtk_button_new_from_icon_name("go-next", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_always_show_image(GTK_BUTTON(yes_button), true);
    gtk_button_set_label(GTK_BUTTON(yes_button), "Yes, I agree");
    gtk_container_add(GTK_CONTAINER(flow_box), yes_button);

    gtk_widget_show_all(GTK_WIDGET(win));
}
开发者ID:btrzcinski,项目名称:agreement,代码行数:38,代码来源:agreementappwin.c

示例4: nimf_settings_page_build_label

static GtkWidget *
nimf_settings_page_build_label (NimfSettingsPage *page, const gchar *schema_id)
{
  GString   *string;
  gchar     *str;
  GtkWidget *tab_label;
  gchar     *p;

  str = g_settings_get_string (page->gsettings, "hidden-schema-name");
  string = g_string_new (str);

  for (p = (gchar *) schema_id; *p != 0; p++)
    if (*p == '.')
      g_string_prepend (string, "  ");

  tab_label = gtk_label_new (string->str);
  gtk_widget_set_halign (tab_label, GTK_ALIGN_START);

  g_free (str);
  g_string_free (string, TRUE);

  return tab_label;
}
开发者ID:inureyes,项目名称:nimf,代码行数:23,代码来源:nimf-settings.c

示例5: close_button_new

// Close button
GtkWidget* close_button_new()
{
  auto* self = GTK_WIDGET(g_object_new(close_button_get_type(), nullptr));
  gtk_button_set_relief(GTK_BUTTON(self), GTK_RELIEF_NONE);
  gtk_button_set_focus_on_click(GTK_BUTTON(self), FALSE);
  gtk_widget_set_can_focus(self, FALSE);
  gtk_widget_set_halign(self, GTK_ALIGN_START);

  auto const& file = decoration::Style::Get()->ThemedFilePath(CLOSE_BUTTON_INACTIVE_FILE, {PKGDATADIR"/"});
  auto* img = gtk_image_new_from_file(file.c_str());
  gtk_container_add(GTK_CONTAINER(self), img);
  CLOSE_BUTTON(self)->priv->img = GTK_IMAGE(img);

  glib::Object<GtkCssProvider> style(gtk_css_provider_new());
  gtk_css_provider_load_from_data(style, R"(
    * {padding: 0px 0px 0px 0px; border: 0px; }
  )", -1, nullptr);

  auto* style_ctx = gtk_widget_get_style_context(self);
  gtk_style_context_add_provider(style_ctx, glib::object_cast<GtkStyleProvider>(style), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

  return self;
}
开发者ID:jonjahren,项目名称:unity,代码行数:24,代码来源:DecorationsForceQuitDialog.cpp

示例6: menu_contents

static GtkWidget*
menu_contents (void)
{
  GtkWidget *vbox;
  GtkWidget *mi;
  int i;
  GtkWidget *frame;

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame),
                             GTK_SHADOW_OUT);

  vbox = gtk_vbox_new (FALSE, 0);

  i = 0;
  while (i < 10)
    {
      char *str = g_strdup_printf (_("Fake menu item %d\n"), i + 1);
      mi = gtk_label_new (str);
#if GTK_CHECK_VERSION (3, 0, 0)
      gtk_widget_set_halign (image, GTK_ALIGN_START);
      gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
#else
      gtk_misc_set_alignment (GTK_MISC (mi), 0.0, 0.5);
#endif
      g_free (str);
      gtk_box_pack_start (GTK_BOX (vbox), mi, FALSE, FALSE, 0);

      ++i;
    }

  gtk_container_add (GTK_CONTAINER (frame), vbox);

  gtk_widget_show_all (frame);

  return frame;
}
开发者ID:BrotherAl,项目名称:marco,代码行数:37,代码来源:theme-viewer.c

示例7: set_table_row

static void
set_table_row (GtkTable *table,
               GtkWidget *label, GtkWidget *widget,
               gpointer user_data)
{
	static guint row = 0;
	guint col = 0;

	g_return_if_fail (GTK_IS_TABLE (table));
	g_return_if_fail (GTK_IS_WIDGET (widget));

	if (label) {
		gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
		gtk_widget_set_halign (label, GTK_ALIGN_START);
		gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
		gtk_widget_show (label);

		gtk_table_attach (GTK_TABLE (table), label,
	                          0, ++col, row, row + 1,
		                  GTK_FILL, 0, 0, 0);
	}

	if (GTK_IS_EDITABLE (widget)) {
		g_signal_connect_swapped (widget, "changed",
		                          G_CALLBACK (verify_input), user_data);
		g_signal_connect_swapped (widget, "activate",
		                          G_CALLBACK (cycle_focus), user_data);
	}

	gtk_widget_show (widget);

	gtk_table_attach (GTK_TABLE (table), widget,
	                  col, 2, row, row + 1,
	                  GTK_EXPAND | GTK_FILL, 0, 0, 0);
	row++;
}
开发者ID:deejay1,项目名称:giggle,代码行数:36,代码来源:giggle-clone-dialog.c

示例8: gtk_event_box_new

static GtkWidget *_lib_viewswitcher_create_label(dt_view_t *v)
{
  GtkWidget *eb = gtk_event_box_new();
  GtkWidget *b = gtk_label_new(v->name(v));
  gtk_container_add(GTK_CONTAINER(eb), b);
  /*setup label*/
  gtk_widget_set_halign(b, GTK_ALIGN_START);
  g_object_set_data(G_OBJECT(b), "view-label", (gchar *)v->name(v));
  g_object_set_data(G_OBJECT(eb), "view-label", (gchar *)v->name(v));
  gtk_widget_set_name(b, "view_label");
  gtk_widget_set_state_flags(b, GTK_STATE_FLAG_NORMAL, TRUE);

  /* connect button press handler */
  g_signal_connect(G_OBJECT(eb), "button-press-event", G_CALLBACK(_lib_viewswitcher_button_press_callback),
                   GINT_TO_POINTER(v->view(v)));

  /* set enter/leave notify events and connect signals */
  gtk_widget_add_events(GTK_WIDGET(eb), GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);

  g_signal_connect(G_OBJECT(eb), "enter-notify-event", G_CALLBACK(_lib_viewswitcher_enter_notify_callback), b);
  g_signal_connect(G_OBJECT(eb), "leave-notify-event", G_CALLBACK(_lib_viewswitcher_leave_notify_callback), b);

  return eb;
}
开发者ID:AdamMajer,项目名称:darktable,代码行数:24,代码来源:viewswitcher.c

示例9: open_valigned_label_window

static void
open_valigned_label_window (void)
{
  GtkWidget *window, *box, *label, *frame;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  g_signal_connect (test_window, "delete-event",
                    G_CALLBACK (gtk_main_quit), test_window);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_widget_show (box);
  gtk_container_add (GTK_CONTAINER (window), box);

  label = gtk_label_new ("Both labels expand");
  gtk_widget_show (label);
  gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);

  label = gtk_label_new ("Some wrapping text with width-chars = 15 and max-width-chars = 35");
  gtk_label_set_line_wrap  (GTK_LABEL (label), TRUE);
  gtk_label_set_width_chars  (GTK_LABEL (label), 15);
  gtk_label_set_max_width_chars  (GTK_LABEL (label), 35);

  gtk_widget_show (label);

  frame  = gtk_frame_new (NULL);
  gtk_widget_show (frame);
  gtk_container_add (GTK_CONTAINER (frame), label);

  gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
  gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);

  gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 0);

  gtk_window_present (GTK_WINDOW (window));
}
开发者ID:RavikumarTulugu,项目名称:antkorp,代码行数:36,代码来源:testadjustsize.c

示例10: photos_empty_results_box_constructed

static void
photos_empty_results_box_constructed (GObject *object)
{
  PhotosEmptyResultsBox *self = PHOTOS_EMPTY_RESULTS_BOX (object);
  GtkStyleContext *context;
  g_autofree gchar *label = NULL;

  G_OBJECT_CLASS (photos_empty_results_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);
  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  gtk_style_context_add_class (context, "dim-label");

  photos_empty_results_box_add_image (self);
  photos_empty_results_box_add_primary_label (self);
  photos_empty_results_box_add_secondary_label (self);

  gtk_widget_show_all (GTK_WIDGET (self));
}
开发者ID:GNOME,项目名称:gnome-photos,代码行数:24,代码来源:photos-empty-results-box.c

示例11: gtk_button_new_with_label

GtkWidget *gtk_text_qr_new(void)
{
	GtkWidget *gtk_text_button_clear = gtk_button_new_with_label("Clear and reset");
	GtkWidget *gtk_text_label = gtk_label_new(NULL);
	gtk_text_entry = gtk_entry_new();
	GtkWidget *gtk_text_scrolled = gtk_scrolled_window_new(NULL, NULL);
	GtkWidget *gtk_text_vertical = gtk_box_new(GTK_ORIENTATION_VERTICAL, 15);
	GtkWidget *gtk_text_horizontal_buttons = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
	
	gtk_label_set_markup(GTK_LABEL(gtk_text_label), "<span size=\"xx-large\">Generate from text or URL</span>");
	gtk_widget_set_halign(gtk_text_label, GTK_ALIGN_START);
	gtk_entry_set_placeholder_text(GTK_ENTRY(gtk_text_entry), "Text or URL");
	gtk_container_set_border_width(GTK_CONTAINER(gtk_text_vertical), 15);
	
	gtk_box_pack_end(GTK_BOX(gtk_text_horizontal_buttons), gtk_text_button_clear, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(gtk_text_vertical), gtk_text_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(gtk_text_vertical), gtk_text_entry, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(gtk_text_vertical), gtk_text_horizontal_buttons, FALSE, FALSE, 0);
	gtk_container_add(GTK_CONTAINER(gtk_text_scrolled), gtk_text_vertical);
	
	g_signal_connect(G_OBJECT(gtk_text_button_clear), "clicked", G_CALLBACK(cb_clicked_text_clear), NULL);
	
	return gtk_text_scrolled;
}
开发者ID:NIPE-SYSTEMS,项目名称:qr-code-generator,代码行数:24,代码来源:gtk_text.c

示例12: create_menu_button

static WidgetInfo *
create_menu_button (void)
{
  GtkWidget *widget;
  GtkWidget *image;
  GtkWidget *menu;
  GtkWidget *vbox;

  widget = gtk_menu_button_new ();
  image = gtk_image_new ();
  gtk_image_set_from_icon_name (GTK_IMAGE (image), "emblem-system-symbolic");
  gtk_container_add (GTK_CONTAINER (widget), image);
  menu = gtk_menu_new ();
  gtk_menu_button_set_popup (GTK_MENU_BUTTON (widget), menu);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
  gtk_container_add (GTK_CONTAINER (vbox), widget);
  gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);

  gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Menu Button"));

  return new_widget_info ("menu-button", vbox, SMALL);
}
开发者ID:GNOME,项目名称:gtk,代码行数:24,代码来源:widgets.c

示例13: vice_gtk3_grid_new_spaced

/** \brief  Create HVSC STIL widget
 *
 * \return  GtkGrid
 */
GtkWidget *hvsc_stil_widget_create(void)
{
    GtkWidget *grid;
    GtkWidget *label;
    GtkWidget *scroll;


    grid = vice_gtk3_grid_new_spaced(VICE_GTK3_DEFAULT, VICE_GTK3_DEFAULT);

    /* add title label */
    label = gtk_label_new(NULL);
    gtk_widget_set_halign(label, GTK_ALIGN_START);
    gtk_label_set_markup(GTK_LABEL(label), "<b>STIL entry:</b>");
    g_object_set(G_OBJECT(label), "margin-bottom", 16, NULL);

    gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);

    /* add view */
    stil_view = create_view();


    hvsc_stil_widget_create_tags();

    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_set_vexpand(scroll, TRUE);
    gtk_widget_set_size_request(scroll, 400, 500);
    gtk_widget_set_hexpand(scroll, TRUE);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
            GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(scroll), stil_view);
    gtk_grid_attach(GTK_GRID(grid), scroll, 0, 1, 1, 1);

    gtk_widget_set_vexpand(grid, TRUE);
    gtk_widget_show_all(grid);
    return grid;
}
开发者ID:OpenEmu,项目名称:VICE-Core,代码行数:40,代码来源:hvscstilwidget.c

示例14: do_images

GtkWidget *
do_images (GtkWidget *do_widget)
{
  GtkWidget *video;
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *base_vbox;
  GtkWidget *image;
  GtkWidget *picture;
  GtkWidget *label;
  GtkWidget *button;
  GdkPaintable *paintable;
  GIcon *gicon;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_display (GTK_WINDOW (window),
                              gtk_widget_get_display (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Images");

      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);
      g_signal_connect (window, "destroy",
                        G_CALLBACK (cleanup_callback), NULL);

      base_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      g_object_set (base_vbox, "margin", 16, NULL);
      gtk_container_add (GTK_CONTAINER (window), base_vbox);

      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 16);
      gtk_container_add (GTK_CONTAINER (base_vbox), hbox);

      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_add (GTK_CONTAINER (hbox), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Image loaded from a file</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
      gtk_container_add (GTK_CONTAINER (vbox), frame);

      image = gtk_image_new_from_icon_name ("gtk3-demo");
      gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);

      gtk_container_add (GTK_CONTAINER (frame), image);


      /* Animation */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Animation loaded from a file</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
      gtk_container_add (GTK_CONTAINER (vbox), frame);

      picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");

      gtk_container_add (GTK_CONTAINER (frame), picture);

      /* Symbolic icon */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Symbolic themed icon</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
      gtk_container_add (GTK_CONTAINER (vbox), frame);

      gicon = g_themed_icon_new_with_default_fallbacks ("battery-caution-charging-symbolic");
      image = gtk_image_new_from_gicon (gicon);
      gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);

      gtk_container_add (GTK_CONTAINER (frame), image);


      /* Progressive */
      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_add (GTK_CONTAINER (hbox), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Progressive image loading</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

//.........这里部分代码省略.........
开发者ID:GNOME,项目名称:gtk,代码行数:101,代码来源:images.c

示例15: gui_attach_gtk3_v4l2ctrls

/*
 * attach v4l2 controls tab widget
 * args:
 *   parent - tab parent widget
 *
 * asserts:
 *   parent is not null
 *
 * returns: error code (0 -OK)
 */
int gui_attach_gtk3_v4l2ctrls(GtkWidget *parent)
{
	/*assertions*/
	assert(parent != NULL);

	if(debug_level > 1)
		printf("GUVCVIEW: attaching v4l2 controls\n");

	GtkWidget *img_controls_grid = gtk_grid_new();
	gtk_widget_show (img_controls_grid);

	gtk_grid_set_column_homogeneous (GTK_GRID(img_controls_grid), FALSE);
	gtk_widget_set_hexpand (img_controls_grid, TRUE);
	gtk_widget_set_halign (img_controls_grid, GTK_ALIGN_FILL);

	gtk_grid_set_row_spacing (GTK_GRID(img_controls_grid), 4);
	gtk_grid_set_column_spacing (GTK_GRID (img_controls_grid), 4);
	gtk_container_set_border_width (GTK_CONTAINER (img_controls_grid), 2);

	int i = 0;
	int n = 0;
	v4l2_ctrl_t *current = v4l2core_get_control_list();

    for(; current != NULL; current = current->next, ++n)
    {
		if(current == NULL)
		{
			fprintf(stderr, "GUVCVIEW: ERROR (attach gtk3 controls) empty control in list\n");
			break;
		}

		if(!is_control_panel &&
		   (current->control.id == V4L2_CID_FOCUS_LOGITECH ||
		    current->control.id == V4L2_CID_FOCUS_ABSOLUTE))
		{
			++n; /*add a virtual software autofocus control*/
		}

		widget_list_size = n + 1;

		control_widgets_list = realloc(control_widgets_list, sizeof(control_widgets_t) * widget_list_size);
		if(control_widgets_list == NULL)
		{
			fprintf(stderr,"GUVCVIEW: FATAL memory allocation failure (gui_attach_gtk3_v4l2ctrls): %s\n", strerror(errno));
			exit(-1);
		}
		/*label*/
		char *tmp;
        tmp = g_strdup_printf ("%s:", current->name);
        control_widgets_list[widget_list_size - 1].label = gtk_label_new (tmp);
        g_free(tmp);
        gtk_widget_show (control_widgets_list[widget_list_size - 1].label);
#if GTK_VER_AT_LEAST(3,15)
				gtk_label_set_xalign(GTK_LABEL(control_widgets_list[widget_list_size - 1].label), 1);
				gtk_label_set_yalign(GTK_LABEL(control_widgets_list[widget_list_size - 1].label), 0.5);
#else
				gtk_misc_set_alignment (GTK_MISC (control_widgets_list[widget_list_size - 1].label), 1, 0.5);
#endif
        

		control_widgets_list[widget_list_size - 1].id = current->control.id;
        control_widgets_list[widget_list_size - 1].widget = NULL;
        control_widgets_list[widget_list_size - 1].widget2 = NULL; /*usually a spin button*/

		switch (current->control.type)
		{
			case V4L2_CTRL_TYPE_INTEGER:

				switch (current->control.id)
				{
					//special cases
					case V4L2_CID_PAN_RELATIVE:
					case V4L2_CID_TILT_RELATIVE:
					{
						control_widgets_list[n].widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);

						GtkWidget *PanTilt1 = NULL;
						GtkWidget *PanTilt2 = NULL;
						if(current->control.id == V4L2_CID_PAN_RELATIVE)
						{
							PanTilt1 = gtk_button_new_with_label(_("Left"));
							PanTilt2 = gtk_button_new_with_label(_("Right"));
						}
						else
						{
							PanTilt1 = gtk_button_new_with_label(_("Down"));
							PanTilt2 = gtk_button_new_with_label(_("Up"));
						}

						gtk_widget_show (PanTilt1);
//.........这里部分代码省略.........
开发者ID:ChanceLuo,项目名称:rubbish,代码行数:101,代码来源:gui_gtk3_v4l2ctrls.c


注:本文中的gtk_widget_set_halign函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。