Ejemplo n.º 1
0
static GtkWidget *
ppd_option_add (ppd_option_t  option,
                const gchar  *printer_name,
                GtkWidget    *grid,
                gboolean      sensitive)
{
  GtkStyleContext *context;
  GtkWidget       *widget;
  GtkWidget       *label;
  gint             position;

  widget = (GtkWidget *) pp_ppd_option_widget_new (&option, printer_name);
  if (widget)
    {
      gtk_widget_set_sensitive (widget, sensitive);
      position = grid_get_height (grid);

      label = gtk_label_new (ppd_option_name_translate (&option));
      context = gtk_widget_get_style_context (label);
      gtk_style_context_add_class (context, "dim-label");
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
      gtk_widget_set_margin_left (label, 10);
      gtk_grid_attach (GTK_GRID (grid), label, 0, position, 1, 1);

      gtk_widget_set_margin_left (widget, 20);
      gtk_grid_attach (GTK_GRID (grid), widget, 1, position, 1, 1);
    }

  return widget;
}
Ejemplo n.º 2
0
static void
create_properties_widget ()
{
	pwidget = gtk_vbox_new (FALSE, 10);

	GtkWidget *finish_label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL(finish_label), "<b>When Finished:</b>");

	GtkWidget *buttonbox = gtk_hbutton_box_new ();
	open   = gtk_check_button_new_with_label ("Open File");
	notify = gtk_check_button_new_with_label ("Show Notification");
	open_location = gtk_check_button_new_with_label ("Open Location");

	gtk_box_pack_start (GTK_BOX(buttonbox), notify, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(buttonbox), open, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(buttonbox), open_location, FALSE, FALSE, 0);

	GtkWidget *comment_label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL(comment_label), "<b>Comment:</b>");

	GtkWidget *text_view  = gtk_text_view_new ();
	comment = gtk_text_view_get_buffer (GTK_TEXT_VIEW(text_view));
	gtk_widget_set_size_request (text_view, -1, 60);
	gtk_text_view_set_left_margin (GTK_TEXT_VIEW(text_view), 10);
	gtk_text_view_set_right_margin (GTK_TEXT_VIEW(text_view), 10);

	gtk_box_pack_start (GTK_BOX(pwidget), finish_label, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(pwidget), buttonbox, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(pwidget), comment_label, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(pwidget), text_view, FALSE, FALSE, 0);
	gtk_button_box_set_layout (GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_START);

	gtk_misc_set_alignment (GTK_MISC(finish_label), 0.0, 0.5);
	gtk_misc_set_alignment (GTK_MISC(comment_label), 0.0, 0.5);

	gtk_widget_set_margin_left (pwidget, 15);
	gtk_widget_set_margin_left (buttonbox, 15);
	gtk_widget_set_margin_left  (text_view, 15);
	gtk_widget_set_margin_right (text_view, 20);
	gtk_widget_set_margin_top  (pwidget, 15);

	g_signal_connect (notify, "toggled", G_CALLBACK (on_toggle),
					  GINT_TO_POINTER (G_DOWNLOADABLE_FINISH_ACTION_NOTIFY));
	g_signal_connect (open, "toggled", G_CALLBACK (on_toggle),
					  GINT_TO_POINTER (G_DOWNLOADABLE_FINISH_ACTION_OPEN));
	g_signal_connect (open_location, "toggled", G_CALLBACK (on_toggle),
					  GINT_TO_POINTER (G_DOWNLOADABLE_FINISH_ACTION_OPEN_LOCATION));
	g_signal_connect (text_view, "focus-out-event", G_CALLBACK (on_comment_save), NULL);

	gtk_widget_show_all (pwidget);
}
Ejemplo n.º 3
0
static void
add_dns_row (CEPageIP6   *page,
             const gchar *address)
{
        GtkWidget *row;
        GtkWidget *row_box;
        GtkWidget *label;
        GtkWidget *widget;
        GtkWidget *delete_button;
        GtkWidget *image;

        row = gtk_list_box_row_new ();
        gtk_widget_set_can_focus (row, FALSE);

        row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
        label = gtk_label_new (_("Server"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_box_pack_start (GTK_BOX (row_box), label, FALSE, FALSE, 0);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "address", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), address);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_box_pack_start (GTK_BOX (row_box), widget, TRUE, TRUE, 0);

        delete_button = gtk_button_new ();
        gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
        g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page);
        image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
        atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete DNS Server"));
        gtk_button_set_image (GTK_BUTTON (delete_button), image);
        gtk_box_pack_start (GTK_BOX (row_box), delete_button, FALSE, FALSE, 0);
        g_object_set_data (G_OBJECT (row), "delete-button", delete_button);

        gtk_widget_set_margin_left (row_box, 10);
        gtk_widget_set_margin_right (row_box, 10);
        gtk_widget_set_margin_top (row_box, 10);
        gtk_widget_set_margin_bottom (row_box, 10);
        gtk_widget_set_halign (row_box, GTK_ALIGN_FILL);

        gtk_container_add (GTK_CONTAINER (row), row_box);
        gtk_widget_show_all (row);
        gtk_container_add (GTK_CONTAINER (page->dns_list), row);

        update_row_sensitivity (page, page->dns_list);
}
Ejemplo n.º 4
0
static void
ido_source_menu_item_constructed (GObject *object)
{
  IdoSourceMenuItem *item = IDO_SOURCE_MENU_ITEM (object);
  GtkWidget *grid;
  gint icon_width;

  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_width, NULL);

  item->icon = g_object_ref (gtk_image_new ());
  gtk_widget_set_margin_left (item->icon, icon_width);
  gtk_widget_set_margin_right (item->icon, 6);

  item->label = g_object_ref (gtk_label_new (""));
  gtk_label_set_max_width_chars (GTK_LABEL (item->label), 40);
  gtk_label_set_ellipsize (GTK_LABEL (item->label), PANGO_ELLIPSIZE_END);
  gtk_misc_set_alignment (GTK_MISC (item->label), 0.0, 0.5);

  item->detail = g_object_ref (ido_detail_label_new (""));
  gtk_widget_set_halign (item->detail, GTK_ALIGN_END);
  gtk_widget_set_hexpand (item->detail, TRUE);
  gtk_style_context_add_class (gtk_widget_get_style_context (item->detail), "accelerator");

  grid = gtk_grid_new ();
  gtk_grid_attach (GTK_GRID (grid), item->icon, 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), item->label, 1, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), item->detail, 2, 0, 1, 1);

  gtk_container_add (GTK_CONTAINER (object), grid);
  gtk_widget_show_all (grid);

  G_OBJECT_CLASS (ido_source_menu_item_parent_class)->constructed (object);
}
static void
nautilus_floating_bar_constructed (GObject *obj)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
	GtkWidget *w, *box;

	G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);

	box = GTK_WIDGET (obj);

	w = gtk_spinner_new ();
	gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
	gtk_widget_set_visible (w, self->priv->show_spinner);
	self->priv->spinner = w;

	gtk_widget_set_size_request (w, 16, 16);
	gtk_widget_set_margin_left (w, 8);

	w = gtk_label_new (NULL);
	gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
	gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
	g_object_set (w,
		      "margin-top", 2,
		      "margin-bottom", 2,
		      "margin-left", 12,
		      "margin-right", 12,
		      "max-width-chars", 60,
		      NULL);
	self->priv->label_widget = w;
	gtk_widget_show (w);
}
Ejemplo n.º 6
0
Archivo: hig.c Proyecto: AllardJ/Tomato
void
hig_workarea_add_wide_control (GtkWidget * t, guint * row, GtkWidget * w)
{
    gtk_widget_set_hexpand (w, TRUE);
    gtk_widget_set_margin_left (w, 18);
    gtk_grid_attach (GTK_GRID (t), w, 0, *row, 2, 1);
    ++ * row;
}
static void
set_row_widget_margins (GtkWidget *widget)
{
  gtk_widget_set_margin_left (widget, 20);
  gtk_widget_set_margin_right (widget, 20);
  gtk_widget_set_margin_top (widget, 6);
  gtk_widget_set_margin_bottom (widget, 6);
}
static void gtk_technology_init(GtkTechnology *technology)
{
	GtkTechnologyPrivate *priv;

	priv =  G_TYPE_INSTANCE_GET_PRIVATE(technology,
						GTK_TYPE_TECHNOLOGY,
						GtkTechnologyPrivate);
	technology->priv = priv;

	priv->box = (GtkBox *) gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	priv->enabler = (GtkSwitch *) gtk_switch_new();
	priv->name = (GtkLabel *) gtk_label_new(NULL);


	gtk_widget_set_margin_left((GtkWidget *)priv->enabler, 0);
	gtk_widget_set_margin_right((GtkWidget *)priv->enabler, 0);
	gtk_widget_set_margin_top((GtkWidget *)priv->enabler, 0);
	gtk_widget_set_margin_bottom((GtkWidget *)priv->enabler, 0);

	gtk_widget_set_margin_left((GtkWidget *)priv->name, 0);
	gtk_widget_set_margin_right((GtkWidget *)priv->name, 0);
	gtk_widget_set_margin_top((GtkWidget *)priv->name, 0);
	gtk_widget_set_margin_bottom((GtkWidget *)priv->name, 0);

	gtk_box_set_spacing(priv->box, 0);
	gtk_box_set_homogeneous(priv->box, TRUE);

	//gtk_widget_set_halign((GtkWidget *)priv->box, GTK_ALIGN_START);
	gtk_widget_set_halign((GtkWidget *)priv->name, GTK_ALIGN_START);
	//gtk_widget_set_halign((GtkWidget *)technology, GTK_ALIGN_START);

	gtk_box_pack_start(priv->box,
			(GtkWidget *)priv->enabler, FALSE, FALSE, 0);
	gtk_box_pack_start(priv->box,
			(GtkWidget *)priv->name, FALSE, FALSE, 0);

	gtk_widget_set_visible((GtkWidget *)priv->box, TRUE);
	gtk_widget_set_visible((GtkWidget *)priv->enabler, TRUE);
	gtk_widget_set_visible((GtkWidget *)priv->name, TRUE);

	gtk_container_add(GTK_CONTAINER(technology), (GtkWidget *)priv->box);

	gtk_widget_set_can_focus((GtkWidget *)priv->box, TRUE);
	gtk_widget_set_can_focus((GtkWidget *)priv->enabler, TRUE);
}
Ejemplo n.º 9
0
Archivo: hig.c Proyecto: AllardJ/Tomato
void
hig_workarea_add_label_w (GtkWidget * t, guint row, GtkWidget * w)
{
    gtk_widget_set_margin_left (w, 18);
    if (GTK_IS_MISC (w))
        gtk_misc_set_alignment (GTK_MISC (w), 0.0f, 0.5f);
    if (GTK_IS_LABEL (w))
        gtk_label_set_use_markup (GTK_LABEL (w), TRUE);
    gtk_grid_attach (GTK_GRID (t), w, 0, row, 1, 1);
}
Ejemplo n.º 10
0
void style_set_margin_end(GtkWidget *widget, gint margin)
{
#if (GTK_MAJOR_VERSION > 3) || (GTK_MINOR_VERSION >= 12)
	gtk_widget_set_margin_end(widget, margin);
#else
	if(gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
		gtk_widget_set_margin_left(widget, margin);
	else
		gtk_widget_set_margin_right(widget, margin);
#endif
}
Ejemplo n.º 11
0
static void
eog_statusbar_init (EogStatusbar *statusbar)
{
	EogStatusbarPrivate *priv;
	GtkWidget *vbox;

	statusbar->priv = EOG_STATUSBAR_GET_PRIVATE (statusbar);
	priv = statusbar->priv;

	priv->img_num_label = gtk_label_new (NULL);
	gtk_widget_set_size_request (priv->img_num_label, 100, 10);
	gtk_widget_show (priv->img_num_label);

	gtk_box_pack_end (GTK_BOX (statusbar),
			  priv->img_num_label,
			  FALSE,
			  TRUE,
			  0);

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

	gtk_box_pack_end (GTK_BOX (statusbar),
			  vbox,
			  FALSE,
			  FALSE,
			  2);

	statusbar->priv->progressbar = gtk_progress_bar_new ();

	gtk_box_pack_end (GTK_BOX (vbox),
			  priv->progressbar,
			  TRUE,
			  TRUE,
			  0);

	/* Set margins by hand to avoid causing redraws due to the statusbar
	 * becoming too small for the progressbar */
	gtk_widget_set_margin_left (priv->progressbar, 2);
	gtk_widget_set_margin_right (priv->progressbar, 2);
	gtk_widget_set_margin_top (priv->progressbar, 1);
	gtk_widget_set_margin_bottom (priv->progressbar, 1);

	gtk_widget_set_size_request (priv->progressbar, -1, 10);

	gtk_widget_show (vbox);

	gtk_widget_hide (statusbar->priv->progressbar);

}
static GtkWidget *
padded_label_new (char *text, gboolean narrow)
{
        GtkWidget *widget;

        widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
        gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
        gtk_widget_set_margin_top (widget, 10);
        gtk_widget_set_margin_bottom (widget, 10);
        gtk_widget_set_margin_left (widget, narrow ? 10 : 80);
        gtk_widget_set_margin_right (widget, narrow ? 10 : 80);
        gtk_box_pack_start (GTK_BOX (widget), gtk_label_new (text), FALSE, FALSE, 0);

        return widget;
}
Ejemplo n.º 13
0
static GtkWidget *
ipp_option_add (IPPAttribute *attr_supported,
                IPPAttribute *attr_default,
                const gchar  *option_name,
                const gchar  *option_display_name,
                const gchar  *printer_name,
                GtkWidget    *grid,
                gboolean      sensitive)
{
  GtkStyleContext *context;
  GtkWidget       *widget;
  GtkWidget       *label;
  gint             position;

  widget = (GtkWidget *) pp_ipp_option_widget_new (attr_supported,
                                                   attr_default,
                                                   option_name,
                                                   printer_name);
  if (widget)
    {
      gtk_widget_set_sensitive (widget, sensitive);
      position = grid_get_height (grid);

      label = gtk_label_new (option_display_name);
      context = gtk_widget_get_style_context (label);
      gtk_style_context_add_class (context, "dim-label");
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
      gtk_widget_set_margin_left (label, 10);
      gtk_grid_attach (GTK_GRID (grid), label, 0, position, 1, 1);

      gtk_widget_set_margin_left (widget, 20);
      gtk_grid_attach (GTK_GRID (grid), widget, 1, position, 1, 1);
    }

  return widget;
}
static void
add_application (CcNotificationsPanel *panel,
                 Application          *app)
{
  GtkWidget *box, *w;
  GIcon *icon;

  icon = g_app_info_get_icon (app->app_info);
  if (icon == NULL)
    icon = g_themed_icon_new ("application-x-executable");
  else
    g_object_ref (icon);

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  g_object_set_qdata_full (G_OBJECT (box), application_quark (),
                           app, (GDestroyNotify) application_free);

  gtk_container_add (GTK_CONTAINER (panel->list_box), box);

  w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  gtk_widget_set_margin_left (w, 12);
  gtk_container_add (GTK_CONTAINER (box), w);
  g_object_unref (icon);

  w = gtk_label_new (g_app_info_get_name (app->app_info));
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_label_new ("");
  g_settings_bind_with_mapping (app->settings, "enable",
                                w, "label",
                                G_SETTINGS_BIND_GET |
                                G_SETTINGS_BIND_NO_SENSITIVITY,
                                on_off_label_mapping_get,
                                NULL,
                                NULL,
                                NULL);
  gtk_widget_set_margin_right (w, 12);
  gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);

  gtk_widget_show_all (box);

  g_hash_table_add (panel->known_applications, g_strdup (app->canonical_app_id));
}
static void
setup_model (GnomeControlCenter *shell)
{
  GnomeControlCenterPrivate *priv = shell->priv;

  gtk_widget_set_margin_top (shell->priv->main_vbox, 8);
  gtk_widget_set_margin_bottom (shell->priv->main_vbox, 8);
  gtk_widget_set_margin_left (shell->priv->main_vbox, 12);
  gtk_widget_set_margin_right (shell->priv->main_vbox, 12);
  gtk_container_set_focus_vadjustment (GTK_CONTAINER (shell->priv->main_vbox),
                                       gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (shell->priv->scrolled_window)));

  priv->store = (GtkListStore *) cc_shell_model_new ();
  priv->category_views = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
  priv->menu_tree = gmenu_tree_new_for_path (MENUDIR "/gnomecc.menu", 0);

  reload_menu (shell);

  g_signal_connect (priv->menu_tree, "changed", G_CALLBACK (on_menu_changed), shell);
}
Ejemplo n.º 16
0
static void
nautilus_floating_bar_constructed (GObject *obj)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
	GtkWidget *w, *box, *labels_box;

	G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);

	box = GTK_WIDGET (obj);

	w = gtk_spinner_new ();
	gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
	gtk_widget_set_visible (w, self->priv->show_spinner);
	self->priv->spinner = w;

	gtk_widget_set_size_request (w, 16, 16);
	gtk_widget_set_margin_left (w, 8);

	labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
	g_object_set (labels_box,
		      "margin-top", 2,
		      "margin-bottom", 2,
		      "margin-left", 12,
		      "margin-right", 12,
		      NULL);
	gtk_widget_show (labels_box);

	w = gtk_label_new (NULL);
	gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
	gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
	gtk_container_add (GTK_CONTAINER (labels_box), w);
	self->priv->primary_label_widget = w;
	gtk_widget_show (w);

	w = gtk_label_new (NULL);
	gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
	gtk_container_add (GTK_CONTAINER (labels_box), w);
	self->priv->details_label_widget = w;
	gtk_widget_show (w);
}
Ejemplo n.º 17
0
static void main_window_real_size_allocate (GtkWidget* base, GtkAllocation* allocation) {
	MainWindow * self;
	GtkAllocation _tmp0_;
	GtkBox* _tmp1_;
	self = (MainWindow*) base;
	g_return_if_fail (allocation != NULL);
	_tmp0_ = *allocation;
	GTK_WIDGET_CLASS (main_window_parent_class)->size_allocate ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, GTK_TYPE_WINDOW, GtkWindow), &_tmp0_);
	_tmp1_ = self->priv->hbox;
	if (_tmp1_ != NULL) {
		GtkBox* _tmp2_;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		GtkBox* _tmp5_;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		GtkBox* _tmp8_;
		gint _tmp9_ = 0;
		gint _tmp10_ = 0;
		GtkBox* _tmp11_;
		gint _tmp12_ = 0;
		gint _tmp13_ = 0;
		_tmp2_ = self->priv->hbox;
		_tmp3_ = gtk_widget_get_allocated_width ((GtkWidget*) self);
		_tmp4_ = get_grid_offset (_tmp3_);
		gtk_widget_set_margin_left ((GtkWidget*) _tmp2_, _tmp4_ + grid_size);
		_tmp5_ = self->priv->hbox;
		_tmp6_ = gtk_widget_get_allocated_width ((GtkWidget*) self);
		_tmp7_ = get_grid_offset (_tmp6_);
		gtk_widget_set_margin_right ((GtkWidget*) _tmp5_, _tmp7_);
		_tmp8_ = self->priv->hbox;
		_tmp9_ = gtk_widget_get_allocated_height ((GtkWidget*) self);
		_tmp10_ = get_grid_offset (_tmp9_);
		gtk_widget_set_margin_top ((GtkWidget*) _tmp8_, _tmp10_);
		_tmp11_ = self->priv->hbox;
		_tmp12_ = gtk_widget_get_allocated_height ((GtkWidget*) self);
		_tmp13_ = get_grid_offset (_tmp12_);
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp11_, _tmp13_);
	}
}
Ejemplo n.º 18
0
Archivo: gtk.c Proyecto: Chuongv/uTox
static void update_image_preview(void *filechooser, void *image) {
#define MAX_PREVIEW_SIZE 256
    char *filename = gtk_file_chooser_get_preview_filename(filechooser);
    if (!filename)
        return;

    // load preview
    void *pixbuf = gdk_pixbuf_new_from_file(filename, NULL);

    if (!pixbuf) {
        g_free_utox(filename);
        gtk_file_chooser_set_preview_widget_active(filechooser, false);
        return;
    }

    // if preview too big load smaller
    if (gdk_pixbuf_get_width(pixbuf) > MAX_PREVIEW_SIZE || gdk_pixbuf_get_height(pixbuf) > MAX_PREVIEW_SIZE) {
        g_object_unref(pixbuf);
        pixbuf = gdk_pixbuf_new_from_file_at_size(filename, MAX_PREVIEW_SIZE, MAX_PREVIEW_SIZE, NULL);
    }

    g_free_utox(filename);

    if (!pixbuf) {
        gtk_file_chooser_set_preview_widget_active(filechooser, false);
        return;
    }

    // pad to MAX_PREVIEW_SIZE + 3px margins
    int margin = (MAX_PREVIEW_SIZE + 6 - gdk_pixbuf_get_width(pixbuf)) / 2;
    gtk_widget_set_margin_left(image, margin);
    gtk_widget_set_margin_right(image, margin);

    // set preview
    gtk_image_set_from_pixbuf(image, pixbuf);
    g_object_unref(pixbuf);
    gtk_file_chooser_set_preview_widget_active(filechooser, true);
}
Ejemplo n.º 19
0
static void
gnc_period_select_set_date_common (GncPeriodSelect *period, const GDate *date)
{
    GncPeriodSelectPrivate *priv;

    priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
    if (date)
    {
        if (priv->date_base)
            g_date_free(priv->date_base);
        priv->date_base = g_date_new_dmy(g_date_get_day(date),
                                         g_date_get_month(date),
                                         g_date_get_year(date));
        if (priv->date_label == NULL)
        {
            priv->date_label = gtk_label_new("");
#if GTK_CHECK_VERSION(3,12,0)
            gtk_widget_set_margin_start (GTK_WIDGET(priv->date_label), 6);
#else
            gtk_widget_set_margin_left (GTK_WIDGET(priv->date_label), 6);
#endif
            gtk_box_pack_start(GTK_BOX(period), priv->date_label, TRUE, TRUE, 0);
            gtk_widget_show_all(priv->date_label);
        }
        gnc_period_sample_update_date_label(period);
        return;
    }

    if (priv->date_base)
    {
        g_date_free(priv->date_base);
        priv->date_base = NULL;
        gtk_widget_destroy(priv->date_label);
        priv->date_label = NULL;
    }
}
static void
add_row (NetDeviceEthernet *device, NMConnection *connection)
{
        GtkWidget *row;
        GtkWidget *widget;
        GtkWidget *box;
        GtkWidget *details;
        NMDevice *nmdev;
        NMActiveConnection *aconn;
        gboolean active;
        GtkWidget *image;

        active = FALSE;

        nmdev = net_device_get_nm_device (NET_DEVICE (device));
        aconn = nm_device_get_active_connection (nmdev);
        if (aconn) {
                const gchar *path1, *path2;
                path1 = nm_active_connection_get_connection (aconn);
                path2 = nm_connection_get_path (connection);
                active = g_strcmp0 (path1, path2) == 0;
        }

        row = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
        gtk_box_pack_start (GTK_BOX (row), box, FALSE, TRUE, 0);
        widget = gtk_label_new (nm_connection_get_id (connection));
        gtk_widget_set_margin_left (widget, 12);
        gtk_widget_set_margin_right (widget, 12);
        gtk_widget_set_margin_top (widget, 12);
        gtk_widget_set_margin_bottom (widget, 12);
        gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);

        if (active) {
                widget = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);
                gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
                gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
                gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);

                details = gtk_grid_new ();
                gtk_grid_set_row_spacing (GTK_GRID (details), 10);
                gtk_grid_set_column_spacing (GTK_GRID (details), 10);

                gtk_box_pack_start (GTK_BOX (row), details, FALSE, TRUE, 0);

                add_details (details, nmdev, connection);
        }

        /* filler */
        widget = gtk_label_new ("");
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_box_pack_start (GTK_BOX (box), widget, TRUE, TRUE, 0);

        image = gtk_image_new_from_icon_name ("emblem-system-symbolic", GTK_ICON_SIZE_MENU);
        gtk_widget_show (image);
        widget = gtk_button_new ();
        gtk_style_context_add_class (gtk_widget_get_style_context (widget), "image-button");
        gtk_widget_set_margin_left (widget, 12);
        gtk_widget_set_margin_right (widget, 12);
        gtk_widget_set_margin_top (widget, 12);
        gtk_widget_set_margin_bottom (widget, 12);
        gtk_widget_show (widget);
        gtk_container_add (GTK_CONTAINER (widget), image);
        gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
        gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
        atk_object_set_name (gtk_widget_get_accessible (widget), _("Options…"));
        gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);
        g_object_set_data (G_OBJECT (row), "edit", widget);
        g_object_set_data (G_OBJECT (widget), "row", row);
        g_signal_connect (widget, "clicked",
                          G_CALLBACK (show_details_for_row), device);

        gtk_widget_show_all (row);

        g_object_set_data (G_OBJECT (row), "connection", connection);

        gtk_container_add (GTK_CONTAINER (device->list), row);
}
Ejemplo n.º 21
0
/**************************************************************************
  Creates a new dialog. It will be a tab or a window depending on the
  current user setting of 'gui_gtk3_enable_tabs'.
  Sets pdlg to point to the dialog once it is create, Zeroes pdlg on
  dialog destruction.
  user_data will be passed through response function
  check_top indicates if the layout deision should depend on the parent.
**************************************************************************/
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook,
                    gpointer user_data, bool check_top)
{
  struct gui_dialog *dlg;
  GtkWidget *vbox, *action_area;
  static int dialog_id_counter;

  dlg = fc_malloc(sizeof(*dlg));
  dialog_list = g_list_prepend(dialog_list, dlg);

  dlg->source = pdlg;
  *pdlg = dlg;
  dlg->user_data = user_data;
  dlg->title = NULL;
  
  dlg->default_width = 200;
  dlg->default_height = 300;

  if (gui_gtk3_enable_tabs) {
    dlg->type = GUI_DIALOG_TAB;
  } else {
    dlg->type = GUI_DIALOG_WINDOW;
  }

  if (!gui_action) {
    gui_action = gtk_size_group_new(GTK_SIZE_GROUP_VERTICAL);
  }
  dlg->gui_button = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);

  vbox = gtk_grid_new();
  action_area = gtk_grid_new();
  gtk_grid_set_row_spacing(GTK_GRID(action_area), 4);
  gtk_grid_set_column_spacing(GTK_GRID(action_area), 4);
  if (gui_gtk3_enable_tabs &&
      (check_top && notebook != GTK_NOTEBOOK(top_notebook))
      && !gui_gtk3_small_display_layout) {
    /* We expect this to be short (as opposed to tall); maximise usable
     * height by putting buttons down the right hand side */
    gtk_orientable_set_orientation(GTK_ORIENTABLE(action_area),
                                   GTK_ORIENTATION_VERTICAL);
  } else {
    /* We expect this to be reasonably tall; maximise usable width by
     * putting buttons along the bottom */
    gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
                                   GTK_ORIENTATION_VERTICAL);
  }

  gtk_widget_show(vbox);
  gtk_container_add(GTK_CONTAINER(vbox), action_area);
  gtk_widget_show(action_area);

  gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
  gtk_container_set_border_width(GTK_CONTAINER(action_area), 2);

  switch (dlg->type) {
  case GUI_DIALOG_WINDOW:
    {
      GtkWidget *window;

      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
      gtk_widget_set_name(window, "Freeciv");
      gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
      setup_dialog(window, toplevel);

      gtk_container_add(GTK_CONTAINER(window), vbox);
      dlg->v.window = window;
      g_signal_connect(window, "delete_event",
        G_CALLBACK(gui_dialog_delete_handler), dlg);
      
    }
    break;
  case GUI_DIALOG_TAB:
    {
      GtkWidget *hbox, *label, *image, *button, *event_box;
      gint w, h;
      gchar *buf;

      gtk_icon_size_lookup_for_settings(
        gtk_settings_get_for_screen(gtk_widget_get_screen(vbox)),
        GTK_ICON_SIZE_MENU, &w, &h);

      hbox = gtk_grid_new();

      label = gtk_label_new(NULL);
      gtk_widget_set_halign(label, GTK_ALIGN_START);
      gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
      gtk_widget_set_margin_left(label, 4);
      gtk_widget_set_margin_right(label, 4);
      gtk_widget_set_margin_top(label, 0);
      gtk_widget_set_margin_bottom(label, 0);
      gtk_container_add(GTK_CONTAINER(hbox), label);

      button = gtk_button_new();
      gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
      g_signal_connect_swapped(button, "clicked",
	  G_CALLBACK(gui_dialog_delete_tab_handler), dlg);

      buf = g_strdup_printf(_("Close Tab:\n%s"), _("Ctrl+W"));
      gtk_widget_set_tooltip_text(button, buf);
      g_free(buf);

      image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
      gtk_widget_set_margin_left(image, 0);
      gtk_widget_set_margin_right(image, 0);
      gtk_widget_set_margin_top(image, 0);
      gtk_widget_set_margin_bottom(image, 0);
      gtk_button_set_image(GTK_BUTTON(button), image);

      gtk_container_add(GTK_CONTAINER(hbox), button);

      gtk_widget_show_all(hbox);

      event_box = gtk_event_box_new();
      gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box), FALSE);
      gtk_container_add(GTK_CONTAINER(event_box), hbox);

      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, event_box);
      dlg->v.tab.handler_id =
	g_signal_connect(notebook, "switch-page",
	    G_CALLBACK(gui_dialog_switch_page_handler), dlg);
      dlg->v.tab.child = vbox;

      dlg->v.tab.label = label;
      dlg->v.tab.notebook = GTK_WIDGET(notebook);
      
      gtk_widget_add_events(event_box, GDK_BUTTON2_MOTION_MASK);
      g_signal_connect(event_box, "button-press-event",
                       G_CALLBACK(click_on_tab_callback), dlg);
    }
    break;
  }

  dlg->vbox = vbox;
  dlg->action_area = action_area;

  dlg->response_callback = gui_dialog_destroyed;
  
  dlg->id = dialog_id_counter;
  dialog_id_counter++;
  dlg->return_dialog_id = -1;

  g_signal_connect(vbox, "destroy",
      G_CALLBACK(gui_dialog_destroy_handler), dlg);
  g_signal_connect(vbox, "key_press_event",
      G_CALLBACK(gui_dialog_key_press_handler), dlg);

  g_object_set_data(G_OBJECT(vbox), "gui-dialog-data", dlg);
}
static void
fcitx_wizard_candidate_widget_setup_ui(FcitxWizardCandidateWidget *self)
{
    int row = 0;
    GtkWidget *cvbox = GTK_WIDGET(self);
    GtkWidget *hbox;

    GtkWidget *grid = gtk_grid_new();
    gtk_widget_set_margin_left(grid, 0);
    gtk_widget_set_margin_top(grid, 6);
    gtk_grid_set_row_spacing(GTK_GRID(grid), 12);
    gtk_grid_set_column_spacing(GTK_GRID(grid), 6);

    GtkWidget* label = gtk_label_new(("Candidate Word Number"));
    g_object_set(label, "xalign", 0.0f, NULL);
    self->candidate_word_number_spin_button = gtk_spin_button_new_with_range(
            1, 10, 1.0);
    g_object_set(self->candidate_word_number_spin_button, "hexpand", TRUE, NULL);

    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), self->candidate_word_number_spin_button, 1, 
        row, 1, 1);

    row ++;
    label = gtk_label_new(("Font Size"));
    g_object_set(label, "xalign", 0.0f, NULL);
    self->font_size_spin_button = gtk_spin_button_new_with_range(
            0, 72, 1.0);
    g_object_set(self->font_size_spin_button, "hexpand", TRUE, NULL);

    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), self->font_size_spin_button, 1, 
        row, 1, 1);

    row ++;
    label = gtk_label_new(("Font"));
    g_object_set(label, "xalign", 0.0f, NULL);
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    self->font_button = gtk_font_button_new();
    GtkWidget *button = gtk_button_new_with_label(_("Clear font setting"));
    gtk_box_pack_start(GTK_BOX(hbox), self->font_button, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
    gtk_font_button_set_use_size(GTK_FONT_BUTTON(self->font_button), FALSE);
    gtk_font_button_set_show_size(GTK_FONT_BUTTON(self->font_button), FALSE);
    g_signal_connect(G_OBJECT(button), "clicked", (GCallback) set_none_font_clicked, 
        self->font_button);
    
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), hbox, 1, row, 1, 1);    

    row ++;
    label = gtk_label_new(("Vertical Candidate Word List"));
    g_object_set(label, "xalign", 0.0f, NULL);
    self->vertical_candidate_button = gtk_check_button_new();
    g_object_set(self->vertical_candidate_button, "hexpand", TRUE, NULL);
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), self->vertical_candidate_button, 1, row, 1, 1);
    
 
    gtk_box_pack_start(GTK_BOX(cvbox), grid, TRUE, TRUE, 0);

    fcitx_wizard_candidate_widget_load_conf(self);

    g_signal_connect(G_OBJECT(self->candidate_word_number_spin_button), "value-changed",
                 G_CALLBACK(candidate_word_number_value_changed), self);
    g_signal_connect(G_OBJECT(self->font_size_spin_button), "value-changed",
                 G_CALLBACK(font_size_value_changed), self);
    g_signal_connect(G_OBJECT(self->font_button), "font-set",
                 G_CALLBACK(font_button_font_set), self);
    g_signal_connect(G_OBJECT(self->vertical_candidate_button), "toggled",
                 G_CALLBACK(vertical_candidate_button_toggled), self);

}
Ejemplo n.º 23
0
MidiogreApp *midiogre_app_init(void)
{
    MidiogreApp *app;

    GtkWidget *header;
    GtkWidget *separator;
    GtkWidget *scrolled;
    GtkWidget *label,*frame;
    GtkWidget *button;
    GtkBox *box;

    gint i;
    GError *err;

    /* Allocate app */
    app = calloc(1, sizeof(MidiogreApp));


    /* Setup window */
    app->window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
    gtk_window_set_default_size(GTK_WINDOW(app->window), 600, 400);
    g_signal_connect(app->window, "destroy", G_CALLBACK(gtk_widget_destroyed), NULL);
    g_signal_connect(app->window, "key-release-event", G_CALLBACK(key_event), NULL);
    gtk_window_set_icon(app->window,gdk_pixbuf_new_from_resource("/org/prozum/midiogre/midiogre_logo.png",&err));


    /* Setup header bar */
    header = gtk_header_bar_new();
    gtk_header_bar_set_title (GTK_HEADER_BAR(header), "Midiogre");
    gtk_window_set_titlebar(app->window, header);

    /* Setup close button */
    button = gtk_button_new();
    gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/window-close-symbolic.symbolic.png"));
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button);
    g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_main_quit), app->window);


    /* Add seperator */
    separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), separator);


    /* Setup folder button */
    button = gtk_button_new();
    gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/document-open-symbolic.symbolic.png"));
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button);
    g_signal_connect_swapped(button, "clicked", G_CALLBACK(folder_chooser), app->window);

    /* Global horizontal box */
    app->win_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(app->window), GTK_WIDGET(app->win_box));


    /* Scroll container for sidepanel */
    scrolled = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(app->win_box, scrolled, FALSE, FALSE, 0);


    /* Sidepanel box */
    app->panel_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
    gtk_container_add(GTK_CONTAINER (scrolled), GTK_WIDGET(app->panel_box));
    gtk_container_set_border_width(GTK_CONTAINER(app->panel_box), 10);


    /* Frame with favorit info */
    frame = gtk_frame_new("Favorite");
    gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0);
    app->fav_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->fav_box));


    /* Current favorite */
    app->fav_title_label = GTK_LABEL(gtk_label_new(""));
    gtk_label_set_max_width_chars(app->fav_title_label, 20);
    gtk_label_set_width_chars(app->fav_title_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_title_label), FALSE, FALSE, 0);
    app->fav_artist_label = GTK_LABEL(gtk_label_new("No favorite selected!"));
    gtk_label_set_max_width_chars(app->fav_artist_label, 20);
    gtk_label_set_width_chars(app->fav_artist_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_artist_label), FALSE, FALSE, 0);
    app->fav_album_label = GTK_LABEL(gtk_label_new(""));
    gtk_label_set_max_width_chars(app->fav_album_label, 20);
    gtk_label_set_width_chars(app->fav_album_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_album_label), FALSE, FALSE, 0);


    /* Frame with search criteria widgets */
    frame = gtk_frame_new("Search");
    gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0);

    app->search_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 10));
    gtk_container_set_border_width(GTK_CONTAINER(app->search_box), 10);

    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->search_box));


    /* Title entry */
    frame = gtk_frame_new("Title");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->title_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->title_entry), TRUE, FALSE, 0);


    /* Artist entry */
    frame = gtk_frame_new("Artist");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->artist_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->artist_entry), TRUE, FALSE, 0);


    /* Album entry */
    frame = gtk_frame_new("Album");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->album_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->album_entry), TRUE, FALSE, 0);


    /* Instrument class buttons */
    frame = gtk_frame_new("Instrument Classes");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    app->instr_grid = GTK_GRID(gtk_grid_new());

#if GTK_MINOR_VERSION >= 12
    gtk_widget_set_margin_start(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_end(GTK_WIDGET(app->instr_grid), 10);
#else
    gtk_widget_set_margin_left(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_right(GTK_WIDGET(app->instr_grid), 10);
#endif
    gtk_widget_set_margin_bottom(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_top(GTK_WIDGET(app->instr_grid), 10);
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->instr_grid));


    for (i = 0; i < INSTR_CLASSES; i++) {

        label = gtk_label_new(instrument_classes[i]);
        gtk_widget_set_halign(GTK_WIDGET(label), GTK_ALIGN_START);
        gtk_grid_attach(app->instr_grid, label, 1, i + 1, 1, 1);

        app->instr_buttons[i] = GTK_CHECK_BUTTON(gtk_check_button_new());
        gtk_widget_set_halign(GTK_WIDGET(app->instr_buttons[i]), GTK_ALIGN_END);
        gtk_grid_attach(app->instr_grid, GTK_WIDGET(app->instr_buttons[i]), 2, i + 1, 1, 1);
    }


    /* Result spinbutton */
    frame = gtk_frame_new("Max result");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->result_spinbutton = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(1, 100, 1));
    gtk_spin_button_set_value(app->result_spinbutton, 25);

    gtk_box_pack_start(box, GTK_WIDGET(app->result_spinbutton), TRUE, TRUE, 0);

    /* Search button */
    app->search_button = GTK_BUTTON(gtk_button_new_with_label("Search"));
    gtk_box_pack_start(app->search_box, GTK_WIDGET(app->search_button), FALSE, FALSE, 0);
    g_signal_connect_swapped(app->search_button, "clicked", G_CALLBACK(search_event), app);


    /* Songboxes notebook (Tabsview) */
    app->song_notebook = GTK_NOTEBOOK(gtk_notebook_new());
    gtk_widget_set_hexpand(GTK_WIDGET(app->song_notebook), TRUE);
    gtk_box_pack_start(app->win_box, GTK_WIDGET(app->song_notebook), TRUE, TRUE, 0);


    /* Add song boxes */
    app->songboxes[SONGBOX_ALPHA] = songbox_new(app->song_notebook, "Alphabetical");
    app->songboxes[SONGBOX_FPRNT] = songbox_new(app->song_notebook, "Fingerprint");
    app->songboxes[SONGBOX_BEST]  = songbox_new(app->song_notebook, "Best Match");
    app->songboxes[SONGBOX_POP]   = songbox_new(app->song_notebook, "Popularity");
    app->songboxes[SONGBOX_NEW]   = songbox_new(app->song_notebook, "Newest");


    /* Show all widgets */
    gtk_widget_show_all(GTK_WIDGET(app->window));


    /* Allocate song queue */
    app->songs[SONGBOX_ALPHA]   = g_queue_new();
    app->songs[SONGBOX_FPRNT]   = g_queue_new();
    app->songs[SONGBOX_BEST]    = g_queue_new();
    app->songs[SONGBOX_POP]     = g_queue_new();
    app->songs[SONGBOX_NEW]     = g_queue_new();


    return app;
}
Ejemplo n.º 24
0
static void
nemo_toolbar_constructed (GObject *obj)
{
	NemoToolbar *self = NEMO_TOOLBAR (obj);
	GtkWidget *toolbar;
    GtkWidget *hbox;
    GtkToolItem *tool_box;
    GtkWidget *box;
	GtkStyleContext *context;

	G_OBJECT_CLASS (nemo_toolbar_parent_class)->constructed (obj);

	gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)),
					      GTK_JUNCTION_BOTTOM);

    self->priv->show_location_entry = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_LOCATION_ENTRY);

	/* add the UI */
	self->priv->ui_manager = gtk_ui_manager_new ();
	gtk_ui_manager_insert_action_group (self->priv->ui_manager, self->priv->action_group, 0);

	toolbar = gtk_toolbar_new ();
	self->priv->toolbar = toolbar;
    gtk_box_pack_start (GTK_BOX (self), self->priv->toolbar, TRUE, TRUE, 0);
	
	context = gtk_widget_get_style_context (GTK_WIDGET(toolbar));
	gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	
    /* Back/Forward/Up */
    self->priv->navigation_box = gtk_tool_item_new ();
    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    self->priv->previous_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_BACK);
    gtk_container_add (GTK_CONTAINER (box), self->priv->previous_button);

    self->priv->next_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_FORWARD);
    gtk_container_add (GTK_CONTAINER (box), self->priv->next_button);

    self->priv->up_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_UP);
    gtk_container_add (GTK_CONTAINER (box), self->priv->up_button);

    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED);
    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED);

    gtk_container_add (GTK_CONTAINER (self->priv->navigation_box), GTK_WIDGET (box));
    gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (self->priv->navigation_box));

    gtk_widget_show_all (GTK_WIDGET (self->priv->navigation_box));
    gtk_widget_set_margin_right (GTK_WIDGET (self->priv->navigation_box), 6);

    /* Refresh */
    self->priv->refresh_box = gtk_tool_item_new ();
    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    self->priv->refresh_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_RELOAD);
    gtk_container_add (GTK_CONTAINER (box), self->priv->refresh_button);
    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED);

    gtk_container_add (GTK_CONTAINER (self->priv->refresh_box), GTK_WIDGET (box));
    gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (self->priv->refresh_box));

    gtk_widget_show_all (GTK_WIDGET (self->priv->refresh_box));
    gtk_widget_set_margin_right (GTK_WIDGET (self->priv->refresh_box), 6);

    /* Home/Computer */
    self->priv->location_box = gtk_tool_item_new ();
    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    self->priv->home_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_HOME);
    gtk_container_add (GTK_CONTAINER (box), self->priv->home_button);

    self->priv->computer_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_COMPUTER);
    gtk_container_add (GTK_CONTAINER (box), self->priv->computer_button);

    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED);
    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED);

    gtk_container_add (GTK_CONTAINER (self->priv->location_box), GTK_WIDGET (box));
    gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (self->priv->location_box));

    gtk_widget_show_all (GTK_WIDGET (self->priv->location_box));
    gtk_widget_set_margin_right (GTK_WIDGET (self->priv->location_box), 6);

    /* Container to hold the location and pathbars */
    self->priv->stack = gtk_stack_new();
    gtk_stack_set_transition_type (GTK_STACK (self->priv->stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
    gtk_stack_set_transition_duration (GTK_STACK (self->priv->stack), 150);

    /* Regular Path Bar */
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (self->priv->stack), TRUE, TRUE, 0);

    self->priv->path_bar = g_object_new (NEMO_TYPE_PATH_BAR, NULL);
    gtk_stack_add_named(GTK_STACK (self->priv->stack), GTK_WIDGET (self->priv->path_bar), "path_bar");
    
    /* Entry-Like Location Bar */
    self->priv->location_bar = nemo_location_bar_new ();
    gtk_stack_add_named(GTK_STACK (self->priv->stack), GTK_WIDGET (self->priv->location_bar), "location_bar");
    gtk_widget_show_all (hbox);

    tool_box = gtk_tool_item_new ();
    gtk_tool_item_set_expand (tool_box, TRUE);
    gtk_container_add (GTK_CONTAINER (tool_box), hbox);
    gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (tool_box));
    gtk_widget_show (GTK_WIDGET (tool_box));

    /* Search/Open in Terminal/New Folder/Toggle Location */
    self->priv->tools_box = gtk_tool_item_new ();
    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    self->priv->toggle_location_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_TOGGLE_LOCATION);
    gtk_container_add (GTK_CONTAINER (box), self->priv->toggle_location_button);

    self->priv->open_terminal_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_OPEN_IN_TERMINAL);
    gtk_container_add (GTK_CONTAINER (box), self->priv->open_terminal_button);

    self->priv->new_folder_button = toolbar_create_toolbutton (self, FALSE, NEMO_ACTION_NEW_FOLDER);
    gtk_container_add (GTK_CONTAINER (box), self->priv->new_folder_button);

    self->priv->search_button = toolbar_create_toolbutton (self, TRUE, NEMO_ACTION_SEARCH);
    gtk_container_add (GTK_CONTAINER (box), self->priv->search_button);

    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED);
    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED);

    gtk_container_add (GTK_CONTAINER (self->priv->tools_box), GTK_WIDGET (box));
    gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (self->priv->tools_box));

    gtk_widget_show_all (GTK_WIDGET (self->priv->tools_box));
    gtk_widget_set_margin_left (GTK_WIDGET (self->priv->tools_box), 6);

    setup_root_info_bar (self);

    /* View Select */
    self->priv->view_box = gtk_tool_item_new ();
    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    self->priv->icon_view_button = toolbar_create_toolbutton (self, TRUE, NEMO_ACTION_ICON_VIEW);
    gtk_container_add (GTK_CONTAINER (box), self->priv->icon_view_button);

    self->priv->list_view_button = toolbar_create_toolbutton (self, TRUE, NEMO_ACTION_LIST_VIEW);
    gtk_container_add (GTK_CONTAINER (box), self->priv->list_view_button);

    self->priv->compact_view_button = toolbar_create_toolbutton (self, TRUE, NEMO_ACTION_COMPACT_VIEW);
    gtk_container_add (GTK_CONTAINER (box), self->priv->compact_view_button);

    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED);
    gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED);

    gtk_container_add (GTK_CONTAINER (self->priv->view_box), GTK_WIDGET (box));
    gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (self->priv->view_box));

    gtk_widget_show_all (GTK_WIDGET (self->priv->view_box));
    gtk_widget_set_margin_left (GTK_WIDGET (self->priv->view_box), 6);

    /* nemo patch */
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_PREVIOUS_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_NEXT_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_UP_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_EDIT_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_RELOAD_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_HOME_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_COMPUTER_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_SEARCH_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_NEW_FOLDER_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_OPEN_IN_TERMINAL_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_ICON_VIEW_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_LIST_VIEW_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);
    g_signal_connect_swapped (nemo_preferences,
                  "changed::" NEMO_PREFERENCES_SHOW_COMPACT_VIEW_ICON_TOOLBAR,
                  G_CALLBACK (toolbar_update_appearance), self);

	toolbar_update_appearance (self);
}
Ejemplo n.º 25
0
static NimfSettingsPage *
nimf_settings_page_new (NimfSettings *nsettings,
                        const gchar  *schema_id)
{
  NimfSettingsPage *page;
  GSettingsSchema  *schema;
  GList            *key_list = NULL;
  gchar           **keys;
  GList            *l;
  gint              i;

  page = g_slice_new0 (NimfSettingsPage);
  page->gsettings = g_settings_new (schema_id);
  page->label = nimf_settings_page_build_label (page, schema_id);
  page->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 15);
  page->page_keys = g_ptr_array_new_with_free_func ((GDestroyNotify) nimf_settings_page_key_free);

#if GTK_CHECK_VERSION (3, 12, 0)
  gtk_widget_set_margin_start  (page->box, 15);
  gtk_widget_set_margin_end    (page->box, 15);
#else
  gtk_widget_set_margin_left   (page->box, 15);
  gtk_widget_set_margin_right  (page->box, 15);
#endif

  gtk_widget_set_margin_top    (page->box, 15);
  gtk_widget_set_margin_bottom (page->box, 15);

  schema = g_settings_schema_source_lookup (nsettings->schema_source,
                                            schema_id, TRUE);
#if GLIB_CHECK_VERSION (2, 46, 0)
  keys = g_settings_schema_list_keys (schema);
#else
  keys = g_settings_list_keys (page->gsettings);
#endif

  for (i = 0; keys[i] != NULL; i++)
    key_list = g_list_prepend (key_list, keys[i]);

  key_list = g_list_sort (key_list, (GCompareFunc) on_comparison);

  for (i = 0, l = key_list; l != NULL; l = l->next, i++)
  {
    GVariant            *variant;
    GSettingsSchemaKey  *schema_key = NULL;
    NimfSettingsPageKey *page_key;
    const GVariantType  *type;
    const gchar         *key;
    const gchar         *summary;
    const gchar         *desc;

    key = l->data;

    if (g_str_has_prefix (key, "hidden-"))
      continue;

    variant = g_settings_get_value (page->gsettings, key);
    type = g_variant_get_type (variant);
    schema_key = g_settings_schema_get_key (schema, key);
    summary = g_settings_schema_key_get_summary     (schema_key);
    desc    = g_settings_schema_key_get_description (schema_key);

    page_key = nimf_settings_page_key_new (page->gsettings, key, summary, desc);
    g_ptr_array_add (page->page_keys, page_key);

    if (g_variant_type_equal (type, G_VARIANT_TYPE_BOOLEAN))
    {
      GtkWidget *item;
      item = nimf_settings_page_key_build_boolean (page_key);
      gtk_box_pack_start (GTK_BOX (page->box), item, FALSE, FALSE, 0);
    }
    else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
    {
      GtkWidget *item;
      item = nimf_settings_page_key_build_string (page_key, schema_id, key_list);
      gtk_box_pack_start (GTK_BOX (page->box), item, FALSE, FALSE, 0);
    }
    else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING_ARRAY))
    {
      GtkWidget *item;
      item = nimf_settings_page_key_build_string_array (page_key);
      gtk_box_pack_start (GTK_BOX (page->box), item, FALSE, FALSE, 0);
    }
    else
      g_error (G_STRLOC ": %s: not supported variant type: \"%s\"",
               G_STRFUNC, (gchar *) type);

    g_settings_schema_key_unref (schema_key);
    g_variant_unref (variant);
  }

  g_strfreev (keys);
  g_list_free (key_list);
  g_settings_schema_unref (schema);

  return page;
}
Ejemplo n.º 26
0
void
dialog_tabulate (WBCGtk *wbcg, Sheet *sheet)
{
	GtkBuilder *gui;
	GtkDialog *dialog;
	DialogState *dd;
	int i;

	g_return_if_fail (wbcg != NULL);

	/* Only one guru per workbook. */
	if (wbc_gtk_get_guru (wbcg))
		return;

	if (gnm_dialog_raise_if_exists (wbcg, TABULATE_KEY))
		return;
	gui = gnm_gtk_builder_load ("tabulate.ui", NULL, GO_CMD_CONTEXT (wbcg));
        if (gui == NULL)
                return;

	dialog = GTK_DIALOG (go_gtk_builder_get_widget (gui, "tabulate_dialog"));

	dd = g_new (DialogState, 1);
	dd->wbcg = wbcg;
	dd->gui = gui;
	dd->dialog = dialog;
	dd->sheet = sheet;

	dd->grid = GTK_GRID (go_gtk_builder_get_widget (gui, "main-grid"));
	/* we might get the 4 below from the positon of some of the widgets inside the grid */
	for (i = 1; i < 4; i++) {
		GnmExprEntry *ge = gnm_expr_entry_new (wbcg, TRUE);
		gnm_expr_entry_set_flags (ge,
			GNM_EE_SINGLE_RANGE | GNM_EE_SHEET_OPTIONAL,
			GNM_EE_MASK);

		gtk_grid_attach (dd->grid, GTK_WIDGET (ge), COL_CELL, i + 1, 1, 1);
		gtk_widget_set_margin_left (GTK_WIDGET (ge), 18);
		gtk_widget_show (GTK_WIDGET (ge));
	}

	dd->resultrangetext = gnm_expr_entry_new (wbcg, TRUE);
	gnm_expr_entry_set_flags (dd->resultrangetext,
		GNM_EE_SINGLE_RANGE | GNM_EE_SHEET_OPTIONAL,
		GNM_EE_MASK);
	gtk_grid_attach (dd->grid, GTK_WIDGET (dd->resultrangetext), 0, 6, 4, 1);
	gtk_widget_set_margin_left (GTK_WIDGET (dd->resultrangetext), 18);
	gtk_widget_show (GTK_WIDGET (dd->resultrangetext));

	g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "ok_button")),
		"clicked",
		G_CALLBACK (tabulate_ok_clicked), dd);

	g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "cancel_button")),
		"clicked",
		G_CALLBACK (cancel_clicked), dd);
/* FIXME: Add correct helpfile address */
	gnm_init_help_button (
		go_gtk_builder_get_widget (gui, "help_button"),
		GNUMERIC_HELP_LINK_TABULATE);
	g_object_set_data_full (G_OBJECT (dialog),
		"state", dd, (GDestroyNotify) cb_dialog_destroy);

	gnm_dialog_setup_destroy_handlers (dialog, wbcg,
					   GNM_DIALOG_DESTROY_SHEET_REMOVED);

	gtk_widget_show_all (gtk_dialog_get_content_area (dialog));
	wbc_gtk_attach_guru (wbcg, GTK_WIDGET (dialog));

	non_model_dialog (wbcg, dialog, TABULATE_KEY);
}
static void
mail_config_sendmail_backend_insert_widgets (EMailConfigServiceBackend *backend,
                                             GtkBox *parent)
{
	CamelSettings *settings;
	GtkLabel *label;
	GtkWidget *widget;
	GtkWidget *container;
	GtkWidget *use_custom_binary_check;
	GtkWidget *custom_binary_entry;
	GtkWidget *use_custom_args_check;
	GtkWidget *custom_args_entry;
	GtkWidget *send_in_offline;
	gchar *markup;
	PangoAttribute *attr;
	PangoAttrList *attr_list;

	settings = e_mail_config_service_backend_get_settings (backend);

	markup = g_markup_printf_escaped ("<b>%s</b>", _("Configuration"));
	widget = gtk_label_new (markup);
	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);
	g_free (markup);

	widget = gtk_grid_new ();
	gtk_widget_set_margin_left (widget, 12);
	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);

	container = widget;

	widget = gtk_check_button_new_with_mnemonic (_("_Use custom binary, instead of 'sendmail'"));
	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
	use_custom_binary_check = widget;

	widget = gtk_label_new_with_mnemonic (_("_Custom binary:"));
	gtk_widget_set_margin_left (widget, 12);
	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
	label = GTK_LABEL (widget);

	widget = gtk_entry_new ();
	gtk_label_set_mnemonic_widget (label, widget);
	gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (widget, TRUE);
	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
	custom_binary_entry = widget;

	e_binding_bind_property (
		use_custom_binary_check, "active",
		label, "sensitive",
		G_BINDING_SYNC_CREATE);

	widget = gtk_check_button_new_with_mnemonic (_("U_se custom arguments"));
	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 2, 1);
	use_custom_args_check = widget;

	widget = gtk_label_new_with_mnemonic (_("Cus_tom arguments:"));
	gtk_widget_set_margin_left (widget, 12);
	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 1, 1);
	label = GTK_LABEL (widget);

	widget = gtk_entry_new ();
	gtk_label_set_mnemonic_widget (label, widget);
	gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (widget, TRUE);
	gtk_grid_attach (GTK_GRID (container), widget, 1, 3, 1, 1);
	custom_args_entry = widget;

	e_binding_bind_property (
		use_custom_args_check, "active",
		label, "sensitive",
		G_BINDING_SYNC_CREATE);

	widget = gtk_label_new (_(
		"Default arguments are '-i -f %F -- %R', where\n"
		"   %F - stands for the From address\n"
		"   %R - stands for the recipient addresses"));
	gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (widget, TRUE);
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0);
	gtk_label_set_selectable (GTK_LABEL (widget), TRUE);
	gtk_grid_attach (GTK_GRID (container), widget, 1, 4, 1, 1);

	attr_list = pango_attr_list_new ();
	attr = pango_attr_style_new (PANGO_STYLE_ITALIC);
	pango_attr_list_insert (attr_list, attr);
	gtk_label_set_attributes (GTK_LABEL (widget), attr_list);
	pango_attr_list_unref (attr_list);

	widget = gtk_check_button_new_with_mnemonic (_("Send mail also when in offline _mode"));
	gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 2, 1);
	send_in_offline = widget;

	e_binding_bind_property (
		use_custom_binary_check, "active",
		custom_binary_entry, "sensitive",
		G_BINDING_SYNC_CREATE);

	e_binding_bind_property (
		settings, "use-custom-binary",
		use_custom_binary_check, "active",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	e_binding_bind_object_text_property (
		settings, "custom-binary",
		custom_binary_entry, "text",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	e_binding_bind_property (
		use_custom_args_check, "active",
		custom_args_entry, "sensitive",
		G_BINDING_SYNC_CREATE);

	e_binding_bind_property (
		settings, "use-custom-args",
		use_custom_args_check, "active",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	e_binding_bind_object_text_property (
		settings, "custom-args",
		custom_args_entry, "text",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	e_binding_bind_property (
		settings, "send-in-offline",
		send_in_offline, "active",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	gtk_widget_show_all (container);
}
Ejemplo n.º 28
0
static void
add_address_row (CEPageIP6   *page,
                 const gchar *address,
                 const gchar *network,
                 const gchar *gateway)
{
        GtkWidget *row;
        GtkWidget *row_grid;
        GtkWidget *label;
        GtkWidget *widget;
        GtkWidget *delete_button;
        GtkWidget *image;

        row = gtk_list_box_row_new ();

        row_grid = gtk_grid_new ();
        label = gtk_label_new (_("Address"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "address", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), address);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);

        label = gtk_label_new (_("Prefix"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "prefix", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), network);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);

        label = gtk_label_new (_("Gateway"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "gateway", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), gateway);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);

        delete_button = gtk_button_new ();
        gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
        g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page);
        image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
        atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Address"));
        gtk_button_set_image (GTK_BUTTON (delete_button), image);
        gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 2, 1, 1);
        g_object_set_data (G_OBJECT (row), "delete-button", delete_button);

        gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
        gtk_widget_set_margin_left (row_grid, 10);
        gtk_widget_set_margin_right (row_grid, 10);
        gtk_widget_set_margin_top (row_grid, 10);
        gtk_widget_set_margin_bottom (row_grid, 10);
        gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);

        gtk_container_add (GTK_CONTAINER (row), row_grid);
        gtk_widget_show_all (row);
        gtk_container_add (GTK_CONTAINER (page->address_list), row);

        update_row_sensitivity (page, page->address_list);
}
static void
cc_wacom_page_init (CcWacomPage *self)
{
	CcWacomPagePrivate *priv;
	GError *error = NULL;
	GtkComboBox *combo;
	GtkWidget *box;
	GtkSwitch *sw;
	char *objects[] = {
		"main-grid",
		"liststore-tabletmode",
		"liststore-buttons",
		"adjustment-tip-feel",
		"adjustment-eraser-feel",
		NULL
	};

	priv = self->priv = WACOM_PAGE_PRIVATE (self);

	priv->builder = gtk_builder_new ();

	gtk_builder_add_objects_from_resource (priv->builder,
                                               "/org/sagarmatha/control-center/wacom/sagarmatha-wacom-properties.ui",
                                               objects,
                                               &error);
	if (error != NULL) {
		g_warning ("Error loading UI file: %s", error->message);
		g_object_unref (priv->builder);
		g_error_free (error);
		return;
	}

	box = WID ("main-grid");
	gtk_container_add (GTK_CONTAINER (self), box);
	gtk_widget_set_vexpand (GTK_WIDGET (box), TRUE);

	self->priv->notebook = WID ("stylus-notebook");

	g_signal_connect (WID ("button-calibrate"), "clicked",
			  G_CALLBACK (calibrate_button_clicked_cb), self);
	g_signal_connect (WID ("map-buttons-button"), "clicked",
			  G_CALLBACK (map_buttons_button_clicked_cb), self);

	combo = GTK_COMBO_BOX (WID ("combo-tabletmode"));
	combobox_text_cellrenderer (combo, MODELABEL_COLUMN);
	g_signal_connect (G_OBJECT (combo), "changed",
			  G_CALLBACK (tabletmode_changed_cb), self);

	sw = GTK_SWITCH (WID ("switch-left-handed"));
	g_signal_connect (G_OBJECT (sw), "notify::active",
			  G_CALLBACK (left_handed_toggled_cb), self);

	g_signal_connect (G_OBJECT (WID ("display-link")), "activate-link",
			  G_CALLBACK (display_clicked_cb), self);

	g_signal_connect (G_OBJECT (WID ("display-mapping-button")), "clicked",
			  G_CALLBACK (display_mapping_button_clicked_cb), self);

	priv->nav = cc_wacom_nav_button_new ();
        gtk_widget_set_halign (priv->nav, GTK_ALIGN_END);
        gtk_widget_set_margin_left (priv->nav, 10);
	gtk_grid_attach (GTK_GRID (box), priv->nav, 1, 0, 1, 1);
}
Ejemplo n.º 30
0
static void
add_route_row (CEPageIP6   *page,
               const gchar *address,
               gint         prefix,
               const gchar *gateway,
               gint         metric)
{
        GtkWidget *row;
        GtkWidget *row_grid;
        GtkWidget *label;
        GtkWidget *widget;
        GtkWidget *delete_button;
        GtkWidget *image;

        row = gtk_list_box_row_new ();

        row_grid = gtk_grid_new ();
        label = gtk_label_new (_("Address"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "address", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), address);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);

        label = gtk_label_new (_("Prefix"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "prefix", widget);
        if (prefix > 0) {
                gchar *s = g_strdup_printf ("%d", prefix);
                gtk_entry_set_text (GTK_ENTRY (widget), s);
                g_free (s);
        }
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);

        label = gtk_label_new (_("Gateway"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "gateway", widget);
        gtk_entry_set_text (GTK_ENTRY (widget), gateway);
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);

        /* Translators: Please see https://en.wikipedia.org/wiki/Metrics_(networking) */
        label = gtk_label_new (C_("network parameters", "Metric"));
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
        gtk_grid_attach (GTK_GRID (row_grid), label, 1, 4, 1, 1);
        widget = gtk_entry_new ();
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
        g_object_set_data (G_OBJECT (row), "metric", widget);
        if (metric > 0) {
                gchar *s = g_strdup_printf ("%d", metric);
                gtk_entry_set_text (GTK_ENTRY (widget), s);
                g_free (s);
        }
        gtk_widget_set_margin_left (widget, 10);
        gtk_widget_set_margin_right (widget, 10);
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 4, 1, 1);

        delete_button = gtk_button_new ();
        gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
        g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page);
        image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
        atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Route"));
        gtk_button_set_image (GTK_BUTTON (delete_button), image);
        gtk_widget_set_halign (delete_button, GTK_ALIGN_CENTER);
        gtk_widget_set_valign (delete_button, GTK_ALIGN_CENTER);
        gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 1, 1, 4);
        g_object_set_data (G_OBJECT (row), "delete-button", delete_button);

        gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
        gtk_widget_set_margin_left (row_grid, 10);
        gtk_widget_set_margin_right (row_grid, 10);
        gtk_widget_set_margin_top (row_grid, 10);
        gtk_widget_set_margin_bottom (row_grid, 10);
        gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);

        gtk_container_add (GTK_CONTAINER (row), row_grid);
        gtk_widget_show_all (row);
        gtk_container_add (GTK_CONTAINER (page->routes_list), row);

        update_row_sensitivity (page, page->routes_list);
}