Пример #1
0
void module_setup_window_create ()
{
    gboolean bWriteMode = TRUE;

    chewing_config_open (bWriteMode);
    
    chewing_config_load (&g_chewingConfig);

    if (gcin_chewing_window)
    {
        gtk_window_present (GTK_WINDOW (gcin_chewing_window));
        return;
    }

    gcin_chewing_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    /* main setup win setting */
    gtk_window_set_position (GTK_WINDOW (gcin_chewing_window),
                             GTK_WIN_POS_MOUSE);
    gtk_window_set_has_resize_grip (GTK_WINDOW (gcin_chewing_window), FALSE);

    g_signal_connect (G_OBJECT (gcin_chewing_window), "delete_event",
                      G_CALLBACK (cb_close_window),
                      NULL);

    gtk_window_set_title (GTK_WINDOW (gcin_chewing_window),
                          _(_L("gcin 新酷音設定")));
    gtk_container_set_border_width (GTK_CONTAINER (gcin_chewing_window), 1);

    vbox_top = gtk_vbox_new (FALSE, 3);
    gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_top), GTK_ORIENTATION_VERTICAL);
    gtk_container_add (GTK_CONTAINER (gcin_chewing_window), vbox_top);

    // cand per page
    g_pHBoxCandPerPage = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), g_pHBoxCandPerPage, TRUE, TRUE, 1);
    g_pLabelCandPerPage = gtk_label_new (_(_L("每頁候選字數")));
    gtk_box_pack_start (GTK_BOX (g_pHBoxCandPerPage), g_pLabelCandPerPage, TRUE, TRUE, 0);
    g_pGtkAdj = (GtkAdjustment *)gtk_adjustment_new (g_chewingConfig.candPerPage, 1, 10, 1.0, 1.0, 0.0);
    g_pSpinButtonCandPerPage = gtk_spin_button_new (g_pGtkAdj, 0, 0);
    gtk_box_pack_start (GTK_BOX (g_pHBoxCandPerPage), g_pSpinButtonCandPerPage, FALSE, FALSE, 0);

    // space as selection
    g_pHBoxSpaceAsSelection = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), g_pHBoxSpaceAsSelection, TRUE, TRUE, 1);
    g_pLabelSpaceAsSelection = gtk_label_new (_(_L("空白鍵選字")));
    gtk_box_pack_start (GTK_BOX (g_pHBoxSpaceAsSelection), g_pLabelSpaceAsSelection, TRUE, TRUE, 0);
    g_pCheckButtonSpaceAsSelection = gtk_check_button_new ();
    gtk_box_pack_start (GTK_BOX (g_pHBoxSpaceAsSelection), g_pCheckButtonSpaceAsSelection, FALSE, FALSE, 0);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_pCheckButtonSpaceAsSelection), g_chewingConfig.bSpaceAsSelection);

    // esc clean buf
    g_pHBoxEscCleanAllBuf = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), g_pHBoxEscCleanAllBuf, TRUE, TRUE, 1);
    g_pLabelEscCleanAllBuf = gtk_label_new (_(_L("ESC 鍵清空緩衝區")));
    gtk_box_pack_start (GTK_BOX (g_pHBoxEscCleanAllBuf), g_pLabelEscCleanAllBuf, TRUE, TRUE, 0);
    g_pCheckButtonEscCleanAllBuf = gtk_check_button_new ();
    gtk_box_pack_start (GTK_BOX (g_pHBoxEscCleanAllBuf), g_pCheckButtonEscCleanAllBuf, FALSE, FALSE, 0);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_pCheckButtonEscCleanAllBuf), g_chewingConfig.bEscCleanAllBuf);

    // auto shift cursor
    g_pHBoxAutoShiftCur = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), g_pHBoxAutoShiftCur, TRUE, TRUE, 1);
    g_pLabelAutoShiftCur = gtk_label_new (_(_L("選字完畢自動跳字")));
    gtk_box_pack_start (GTK_BOX (g_pHBoxAutoShiftCur), g_pLabelAutoShiftCur, TRUE, TRUE, 0);
    g_pCheckButtonAutoShiftCur = gtk_check_button_new ();
    gtk_box_pack_start (GTK_BOX (g_pHBoxAutoShiftCur), g_pCheckButtonAutoShiftCur, FALSE, FALSE, 0);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_pCheckButtonAutoShiftCur), g_chewingConfig.bAutoShiftCur);

    // add phrase forward
    g_pHBoxAddPhraseForward = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), g_pHBoxAddPhraseForward, TRUE, TRUE, 1);
    g_pLabelAddPhraseForward = gtk_label_new (_(_L("向後加詞")));
    gtk_box_pack_start (GTK_BOX (g_pHBoxAddPhraseForward), g_pLabelAddPhraseForward, TRUE, TRUE, 0);
    g_pCheckButtonAddPhraseForward = gtk_check_button_new ();
    gtk_box_pack_start (GTK_BOX (g_pHBoxAddPhraseForward), g_pCheckButtonAddPhraseForward, FALSE, FALSE, 0);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_pCheckButtonAddPhraseForward), g_chewingConfig.bAddPhraseForward);

    // cancel & ok buttons
    hbox_cancel_ok = gtk_hbox_new (FALSE, 10);
    gtk_box_pack_start (GTK_BOX (vbox_top), hbox_cancel_ok , FALSE, FALSE, 5);

    button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
    gboolean button_order;
    g_object_get(gtk_settings_get_default(), "gtk-alternative-button-order", &button_order, NULL);
    if (button_order)
      gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);
    else
      gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0);
    button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
#if !GTK_CHECK_VERSION(2,91,2)
    if (button_order)
      gtk_box_pack_end (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 5);
    else
      gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 5);
#else
    if (button_order)
      gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_LEFT, 1, 1);
    else
      gtk_grid_attach_next_to (GTK_BOX (hbox_cancel_ok), button_ok, button_cancel, GTK_POS_RIGHT, 1, 1);
#endif

    g_signal_connect (G_OBJECT (button_cancel), "clicked",
                      G_CALLBACK (cb_close_window),
                      G_OBJECT (gcin_chewing_window));

    g_signal_connect (G_OBJECT (button_ok), "clicked",
                      G_CALLBACK (cb_update_setting),
                      G_OBJECT (gcin_chewing_window));

    gtk_widget_show_all (gcin_chewing_window);
}
Пример #2
0
GtkWidget *
do_editable_cells (GtkWidget *do_widget)
{
    if (!window)
    {
        GtkWidget *vbox;
        GtkWidget *hbox;
        GtkWidget *sw;
        GtkWidget *treeview;
        GtkWidget *button;
        GtkTreeModel *items_model;
        GtkTreeModel *numbers_model;

        /* create window, etc */
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_set_screen (GTK_WINDOW (window),
                               gtk_widget_get_screen (do_widget));
        gtk_window_set_title (GTK_WINDOW (window), "Editable Cells");
        gtk_container_set_border_width (GTK_CONTAINER (window), 5);
        g_signal_connect (window, "destroy",
                          G_CALLBACK (gtk_widget_destroyed), &window);

        vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_add (GTK_CONTAINER (window), vbox);

        gtk_box_pack_start (GTK_BOX (vbox),
                            gtk_label_new ("Shopping list (you can edit the cells!)"),
                            FALSE, FALSE, 0);

        sw = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
                                             GTK_SHADOW_ETCHED_IN);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);

        /* create models */
        items_model = create_items_model ();
        numbers_model = create_numbers_model ();

        /* create tree view */
        treeview = gtk_tree_view_new_with_model (items_model);
        gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
                                     GTK_SELECTION_SINGLE);

        add_columns (GTK_TREE_VIEW (treeview), items_model, numbers_model);

        g_object_unref (numbers_model);
        g_object_unref (items_model);

        gtk_container_add (GTK_CONTAINER (sw), treeview);

        /* some buttons */
        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
        gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

        button = gtk_button_new_with_label ("Add item");
        g_signal_connect (button, "clicked",
                          G_CALLBACK (add_item), treeview);
        gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);

        button = gtk_button_new_with_label ("Remove item");
        g_signal_connect (button, "clicked",
                          G_CALLBACK (remove_item), treeview);
        gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);

        gtk_window_set_default_size (GTK_WINDOW (window), 320, 200);
    }

    if (!gtk_widget_get_visible (window))
        gtk_widget_show_all (window);
    else
    {
        gtk_widget_destroy (window);
        window = NULL;
    }

    return window;
}
Пример #3
0
/*
 * ctk_xvideo_new() - constructor for the XVideo widget
 */
GtkWidget* ctk_xvideo_new(CtrlTarget *ctrl_target,
                          CtkConfig *ctk_config,
                          CtkEvent *ctk_event)
{
    GObject *object;
    CtkXVideo *ctk_xvideo;
    GtkWidget *banner;
    GtkWidget *frame;
    GtkWidget *alignment;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *hseparator;
    int xv_overlay_present, xv_texture_present, xv_blitter_present;
    int display_id;
    gboolean show_page;
    ReturnStatus ret;
    gchar *current_sync_name;

    /*
     * before we do anything else, determine if any of the Xv adapters
     * are present
     */

    ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ATTR_EXT_XV_OVERLAY_PRESENT,
                             &xv_overlay_present);
    if (ret != NvCtrlSuccess) {
        xv_overlay_present = FALSE;
    }

    ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ATTR_EXT_XV_TEXTURE_PRESENT,
                             &xv_texture_present);
    if (ret != NvCtrlSuccess) {
        xv_texture_present = FALSE;
    }

    ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ATTR_EXT_XV_BLITTER_PRESENT,
                             &xv_blitter_present);
    if (ret != NvCtrlSuccess) {
        xv_blitter_present = FALSE;
    }

    if (!xv_overlay_present && !xv_texture_present && !xv_blitter_present) {
        return NULL;
    }

    /* If nothing to show, bail */

    show_page = FALSE;
    if (xv_texture_present || xv_blitter_present) {
        ret = NvCtrlGetAttribute(ctrl_target,
                                 NV_CTRL_XV_SYNC_TO_DISPLAY_ID,
                                 &display_id);
        if (ret == NvCtrlSuccess) {
            show_page = TRUE;
        }
    }

    if (!show_page) {
        return NULL;
    }


    /* create the XVideo widget */

    object = g_object_new(CTK_TYPE_XVIDEO, NULL);
    ctk_xvideo = CTK_XVIDEO(object);

    ctk_xvideo->ctrl_target = ctrl_target;
    ctk_xvideo->ctk_config = ctk_config;
    ctk_xvideo->active_attributes = 0;

    gtk_box_set_spacing(GTK_BOX(ctk_xvideo), 10);


    /* Video film banner */

    banner = ctk_banner_image_new(BANNER_ARTWORK_XVIDEO);
    gtk_box_pack_start(GTK_BOX(object), banner, FALSE, FALSE, 0);

    /* Top Label */

    hbox = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, 0);

    label = gtk_label_new("Xvideo Settings");
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

    hseparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 0);

    /* Current Sync Value */

    ret = NvCtrlGetAttribute(ctrl_target,
                             NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID,
                             &display_id);
    if (ret == NvCtrlSuccess) {
        hbox = gtk_hbox_new(FALSE, 5);
        gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, 5);

        label = gtk_label_new("Currently synced to display:");
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
        label = gtk_label_new("");
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);

        current_sync_name = xv_sync_to_display_radio_button_label(ctk_xvideo,
                                                                  display_id);
        gtk_label_set_text(GTK_LABEL(label), current_sync_name);
        g_free(current_sync_name);

        ctk_xvideo->current_xv_sync_to_display_label = label;
    } else {
        ctk_xvideo->current_xv_sync_to_display_label = NULL;
    }

    /* Sync to display selection */

    frame = gtk_frame_new("Sync to this display device");
    gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0);

    vbox = gtk_vbox_new(FALSE, 5);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING);
    gtk_container_add(GTK_CONTAINER(frame), vbox);
    ctk_xvideo->xv_sync_to_display_button_box = vbox;

    ctk_config_set_tooltip(ctk_xvideo->ctk_config,
                           ctk_xvideo->xv_sync_to_display_button_box,
                           __xv_sync_to_display_help);

    xv_sync_to_display_rebuild_buttons(ctk_xvideo, FALSE);

    g_signal_connect(G_OBJECT(ctk_event),
                     CTK_EVENT_NAME(NV_CTRL_XV_SYNC_TO_DISPLAY_ID),
                     G_CALLBACK(xv_sync_to_display_id_handler),
                     (gpointer) ctk_xvideo);

    if (ctk_xvideo->current_xv_sync_to_display_label) {
        g_signal_connect(G_OBJECT(ctk_event),
                         CTK_EVENT_NAME(NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID),
                         G_CALLBACK(current_xv_sync_to_display_id_handler),
                         (gpointer) ctk_xvideo);
    }

    g_signal_connect(G_OBJECT(ctk_event),
                     CTK_EVENT_NAME(NV_CTRL_ENABLED_DISPLAYS),
                     G_CALLBACK(enabled_displays_handler),
                     (gpointer) ctk_xvideo);


    alignment = gtk_alignment_new(1, 1, 0, 0);
    gtk_box_pack_start(GTK_BOX(object), alignment, TRUE, TRUE, 0);

    /* finally, show the widget */

    gtk_widget_show_all(GTK_WIDGET(ctk_xvideo));

    return GTK_WIDGET(ctk_xvideo);
}
/**
 * init_view_raw_attr:
 * @view:
 * @raw_attr:
 *
 * TODO: Write me
 */
void 
init_view_raw_attr(CongAdvancedNodePropertiesView *view,
		   struct RawAttr* raw_attr)
{
	/* FIXME: use libglade for this... */
	GtkWidget *vbox = gtk_vbox_new(FALSE, 6);
	GtkWidget *hbox = gtk_hbox_new(FALSE, 6);

	g_assert(view);
	g_assert(raw_attr);
	g_assert(cong_node_type(view->node)==CONG_NODE_TYPE_ELEMENT);

	raw_attr->category = cong_dialog_content_add_category(view->dialog_content, 
							      _("Raw Attributes"));
	
	raw_attr->list_store = GTK_LIST_STORE(gtk_list_store_new(RAW_ATTR_MODEL_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING));

	/* Initialise store: */
	raw_attr_list_refresh(view, &view->raw_attr);

	/* Initialise treeview */
	{
		GtkCellRenderer *renderer;
		GtkTreeViewColumn *column;

		raw_attr->tree_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(raw_attr->list_store)));
		
		/* Build columns & renderers: */
		renderer = gtk_cell_renderer_text_new();
		g_object_set(G_OBJECT(renderer),
			     "editable", TRUE,
			     NULL);
		g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(on_name_edited), view);

		column = gtk_tree_view_column_new_with_attributes( _("Name"),
								   renderer,
								   "text", RAW_ATTR_MODEL_COLUMN_NAME,
								   NULL);
		gtk_tree_view_append_column (GTK_TREE_VIEW (raw_attr->tree_view), column);

		renderer = gtk_cell_renderer_text_new();
		g_object_set(G_OBJECT(renderer),
			     "editable", TRUE,
			     NULL);				      
		g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(on_value_edited), view);

		column = gtk_tree_view_column_new_with_attributes( _("Value"),
								   renderer,
								   "text", RAW_ATTR_MODEL_COLUMN_VALUE,
								   NULL);

		gtk_tree_view_append_column (GTK_TREE_VIEW (raw_attr->tree_view), column);

		g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(raw_attr->tree_view)), "changed", G_CALLBACK(on_tree_view_selection_change), view);

	}

	/* Buttons to add and remove attributes: */
	{
		GtkWidget *add_button = gtk_button_new_from_stock(GTK_STOCK_ADD);
		raw_attr->delete_button = gtk_button_new_from_stock(GTK_STOCK_DELETE);

		gtk_container_add(GTK_CONTAINER(hbox), add_button);
		gtk_container_add(GTK_CONTAINER(hbox), raw_attr->delete_button);

		gtk_widget_set_sensitive(raw_attr->delete_button, FALSE);

		g_signal_connect(G_OBJECT(add_button), "clicked", G_CALLBACK(on_add_attribute), view);
		g_signal_connect(G_OBJECT(raw_attr->delete_button), "clicked", G_CALLBACK(on_delete_attribute), view);

		gtk_widget_show(raw_attr->delete_button);
		gtk_widget_show(add_button);
	}

	gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(raw_attr->tree_view));
	gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 0);

	gtk_widget_show(GTK_WIDGET(raw_attr->tree_view));
	gtk_widget_show(hbox);
	gtk_widget_show(vbox);

	cong_dialog_category_add_selflabelled_field(raw_attr->category, vbox, TRUE);
}
Пример #5
0
static void _preferences_window(Camera * camera)
{
	GtkWidget * dialog;
	GtkWidget * notebook;
	GtkWidget * vbox;
	GtkWidget * widget;
	GtkListStore * store;
	GtkTreeIter iter;
	GtkCellRenderer * renderer;
	const struct {
		GdkInterpType type;
		char const * name;
	} interp[] =
	{
		{ GDK_INTERP_NEAREST, N_("Nearest") },
		{ GDK_INTERP_TILES, N_("Tiles") },
		{ GDK_INTERP_BILINEAR, N_("Bilinear") },
		{ GDK_INTERP_HYPER, N_("Hyperbolic") },
	};
	const struct {
		CameraSnapshotFormat format;
		char const * name;
	} sformats[CSF_COUNT - 1] =
	{
		{ CSF_JPEG, "JPEG" },
		{ CSF_PNG, "PNG" }
	};
	size_t i;

	dialog = gtk_dialog_new_with_buttons(_("Preferences"),
			GTK_WINDOW(camera->window),
			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
			GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
	camera->pr_window = dialog;
	g_signal_connect(dialog, "response", G_CALLBACK(
				_preferences_on_response), camera);
	notebook = gtk_notebook_new();
	/* picture */
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
#else
	vbox = gtk_vbox_new(FALSE, 4);
#endif
	camera->pr_hflip = gtk_check_button_new_with_mnemonic(
			_("Flip _horizontally"));
	gtk_box_pack_start(GTK_BOX(vbox), camera->pr_hflip, FALSE, TRUE, 0);
	camera->pr_vflip = gtk_check_button_new_with_mnemonic(
			_("Flip _vertically"));
	gtk_box_pack_start(GTK_BOX(vbox), camera->pr_vflip, FALSE, TRUE, 0);
	camera->pr_ratio = gtk_check_button_new_with_mnemonic(
			_("Keep aspect _ratio"));
	gtk_box_pack_start(GTK_BOX(vbox), camera->pr_ratio, FALSE, TRUE, 0);
	/* interpolation */
#if GTK_CHECK_VERSION(3, 0, 0)
	widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
	widget = gtk_hbox_new(FALSE, 4);
#endif
	gtk_box_pack_start(GTK_BOX(widget), gtk_label_new(_("Interpolation: ")),
			FALSE, TRUE, 0);
	store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
	for(i = 0; i < sizeof(interp) / sizeof(*interp); i++)
	{
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter, 0, interp[i].type,
				1, _(interp[i].name), -1);
	}
	camera->pr_interp = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(camera->pr_interp), renderer,
			TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(camera->pr_interp),
			renderer, "text", 1, NULL);
	gtk_box_pack_start(GTK_BOX(widget), camera->pr_interp, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
			gtk_label_new(_("Picture")));
	/* snapshots */
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
#else
	vbox = gtk_vbox_new(FALSE, 4);
#endif
	/* format */
#if GTK_CHECK_VERSION(3, 0, 0)
	widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
	widget = gtk_hbox_new(FALSE, 4);
#endif
	gtk_box_pack_start(GTK_BOX(widget), gtk_label_new(_("Format: ")),
			FALSE, TRUE, 0);
	store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
	for(i = 0; i < sizeof(sformats) / sizeof(*sformats); i++)
	{
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter, 0, sformats[i].format,
				1, sformats[i].name, -1);
	}
	camera->pr_sformat = gtk_combo_box_new_with_model(
			GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(camera->pr_sformat),
			renderer, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(camera->pr_sformat),
			renderer, "text", 1, NULL);
	gtk_box_pack_start(GTK_BOX(widget), camera->pr_sformat, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
			gtk_label_new(_("Snapshots")));
#if GTK_CHECK_VERSION(2, 14, 0)
	vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
#else
	vbox = dialog->vbox;
#endif
	gtk_box_set_spacing(GTK_BOX(vbox), 4);
	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
	gtk_widget_show_all(vbox);
	_preferences_cancel(camera);
}
Пример #6
0
static GtkWidget *
display_simple_dialog(gint type, gint btn_mask, char *message)
{
  GtkWidget   *win, *main_vb, *top_hb, *msg_vb, *type_pm, *msg_label, *ask_cb,
              *bbox, *ok_bt, *yes_bt, *bt, *save_bt, *dont_save_bt;

  /* Main window */
  switch (type) {
  case ESD_TYPE_WARN :
    type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
    break;
  case ESD_TYPE_CONFIRMATION:
    type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
    break;
  case ESD_TYPE_ERROR:
    type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
    break;
  case ESD_TYPE_STOP :
    type_pm = gtk_image_new_from_stock( GTK_STOCK_STOP, GTK_ICON_SIZE_DIALOG);
    break;
  case ESD_TYPE_INFO :
  default :
    type_pm = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
    break;
  }

  /*
   * The GNOME HIG:
   *
   *	http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows
   *
   * says that the title should be empty for alert boxes, so there's "less
   * visual noise and confounding text."
   *
   * The Windows HIG:
   *
   *	http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch09f.asp
   *
   * says it should
   *
   *	...appropriately identify the source of the message -- usually
   *	the name of the object.  For example, if the message results
   *	from editing a document, the title text is the name of the
   *	document, optionally followed by the application name.  If the
   *	message results from a non-document object, then use the
   *	application name."
   *
   * and notes that the title is important "because message boxes might
   * not always the the result of current user interaction" (e.g., some
   * app might randomly pop something up, e.g. some browser letting you
   * know that it couldn't fetch something because of a timeout).
   *
   * It also says not to use "warning" or "caution", as there's already
   * an icon that tells you what type of alert it is, and that you
   * shouldn't say "error", as that provides no useful information.
   *
   * So we give it a title on Win32, and don't give it one on UN*X.
   * For now, we give it a Win32 title of just "Wireshark"; we should
   * arguably take an argument for the title.
   */
  if(btn_mask == ESD_BTN_NONE) {
	win = splash_window_new();
  } else {
#ifdef _WIN32
    win = dlg_window_new("Wireshark");
#else
    win = dlg_window_new("");
#endif
  }

  gtk_window_set_modal(GTK_WINDOW(win), TRUE);
  gtk_container_set_border_width(GTK_CONTAINER(win), 6);

  /* Container for our rows */
  main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
  gtk_container_add(GTK_CONTAINER(win), main_vb);
  gtk_widget_show(main_vb);

  /* Top row: Icon and message text */
  top_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12, FALSE);
  gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
  gtk_container_add(GTK_CONTAINER(main_vb), top_hb);
  gtk_widget_show(top_hb);

  gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f);
  gtk_container_add(GTK_CONTAINER(top_hb), type_pm);
  gtk_widget_show(type_pm);

  /* column for message and optional check button */
  msg_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
  gtk_box_set_spacing(GTK_BOX(msg_vb), 24);
  gtk_container_add(GTK_CONTAINER(top_hb), msg_vb);
  gtk_widget_show(msg_vb);

  /* message */
  msg_label = gtk_label_new(message);

  gtk_label_set_markup(GTK_LABEL(msg_label), message);
  gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
  g_object_set(gtk_widget_get_settings(msg_label),
    "gtk-label-select-on-focus", FALSE, NULL);

  gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
  gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f);
  gtk_container_add(GTK_CONTAINER(msg_vb), msg_label);
  gtk_label_set_line_wrap(GTK_LABEL(msg_label), TRUE);
  gtk_widget_show(msg_label);

  if(btn_mask == ESD_BTN_NONE) {
	gtk_widget_show(win);
	return win;
  }

  /* optional check button */
  ask_cb = gtk_check_button_new_with_label("replace with text...");
  gtk_container_add(GTK_CONTAINER(msg_vb), ask_cb);
  g_object_set_data(G_OBJECT(win), CHECK_BUTTON, ask_cb);

  /* Button row */
  switch(btn_mask) {
  case(ESD_BTN_OK):
    bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
    break;
  case(ESD_BTN_OK | ESD_BTN_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTN_CLEAR | ESD_BTN_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_CLEAR, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_YES_NO_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_SAVE_DONTSAVE_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_QUIT_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
    break;
  case (ESD_BTNS_QUIT_DONTSAVE_CANCEL):
    bbox = dlg_button_row_new(WIRESHARK_STOCK_QUIT_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_YES_NO):
    bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, NULL);
    break;
  default:
    g_assert_not_reached();
    bbox = NULL;
    break;
  }
  gtk_container_add(GTK_CONTAINER(main_vb), bbox);
  gtk_widget_show(bbox);

  ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
  if(ok_bt) {
      g_object_set_data(G_OBJECT(ok_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_OK));
      g_signal_connect(ok_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  save_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE);
  if (save_bt) {
      g_object_set_data(G_OBJECT(save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_SAVE));
      g_signal_connect(save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  dont_save_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_DONT_SAVE);
  if (dont_save_bt) {
      g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_DONT_SAVE));
      g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  dont_save_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_QUIT_DONT_SAVE);
  if (dont_save_bt) {
      g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_QUIT_DONT_SAVE));
      g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }
  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLEAR);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CLEAR));
      g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  yes_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_YES);
  if(yes_bt) {
      g_object_set_data(G_OBJECT(yes_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_YES));
      g_signal_connect(yes_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_NO);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_NO));
      g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CANCEL));
      window_set_cancel_button(win, bt, simple_dialog_cancel_cb);
  }

  if(!bt) {
      if(yes_bt) {
          window_set_cancel_button(win, yes_bt, simple_dialog_cancel_cb);
      } else {
          window_set_cancel_button(win, ok_bt, simple_dialog_cancel_cb);
      }
  }

  dlg_button_focus_nth(bbox, 0);

  gtk_widget_show(win);

  return win;
}
Пример #7
0
GtkWidget *
offset_dialog_new (GimpDrawable *drawable,
                   GimpContext  *context,
                   GtkWidget    *parent)
{
  GimpItem      *item;
  OffsetDialog  *dialog;
  GtkWidget     *main_vbox;
  GtkWidget     *vbox;
  GtkWidget     *hbox;
  GtkWidget     *button;
  GtkWidget     *spinbutton;
  GtkWidget     *frame;
  GtkWidget     *radio_button;
  GtkAdjustment *adjustment;
  gdouble        xres;
  gdouble        yres;
  const gchar   *title = NULL;

  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);

  dialog = g_slice_new0 (OffsetDialog);

  dialog->context   = context;
  dialog->fill_type = gimp_drawable_has_alpha (drawable) | WRAP_AROUND;
  item = GIMP_ITEM (drawable);
  dialog->image     = gimp_item_get_image (item);

  gimp_image_get_resolution (dialog->image, &xres, &yres);

  if (GIMP_IS_LAYER (drawable))
    title = _("Offset Layer");
  else if (GIMP_IS_LAYER_MASK (drawable))
    title = _("Offset Layer Mask");
  else if (GIMP_IS_CHANNEL (drawable))
    title = _("Offset Channel");
  else
    g_warning ("%s: unexpected drawable type", G_STRFUNC);

  dialog->dialog =
    gimp_viewable_dialog_new (GIMP_VIEWABLE (drawable), context,
                              _("Offset"), "gimp-drawable-offset",
                              GIMP_STOCK_TOOL_MOVE,
                              title,
                              parent,
                              gimp_standard_help_func,
                              GIMP_HELP_LAYER_OFFSET,

                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                              /*  offset, used as a verb  */
                              _("_Offset"),     GTK_RESPONSE_OK,

                              NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);

  g_object_weak_ref (G_OBJECT (dialog->dialog),
                     (GWeakNotify) offset_dialog_free, dialog);

  g_signal_connect (dialog->dialog, "response",
                    G_CALLBACK (offset_response),
                    dialog);

  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  /*  The offset frame  */
  frame = gimp_frame_new (_("Offset"));
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (frame), vbox);
  gtk_widget_show (vbox);

  adjustment = (GtkAdjustment *)
    gtk_adjustment_new (1, 1, 1, 1, 10, 0);
  spinbutton = gtk_spin_button_new (adjustment, 1.0, 2);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);

  dialog->off_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
                                        TRUE, TRUE, FALSE, 10,
                                        GIMP_SIZE_ENTRY_UPDATE_SIZE);

  gtk_table_set_col_spacing (GTK_TABLE (dialog->off_se), 0, 4);
  gtk_table_set_col_spacing (GTK_TABLE (dialog->off_se), 1, 4);
  gtk_table_set_row_spacing (GTK_TABLE (dialog->off_se), 0, 2);

  gimp_size_entry_add_field (GIMP_SIZE_ENTRY (dialog->off_se),
                             GTK_SPIN_BUTTON (spinbutton), NULL);
  gtk_table_attach_defaults (GTK_TABLE (dialog->off_se), spinbutton,
                             1, 2, 0, 1);
  gtk_widget_show (spinbutton);

  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (dialog->off_se),
                                _("_X:"), 0, 0, 0.0);
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (dialog->off_se),
                                _("_Y:"), 1, 0, 0.0);

  gtk_box_pack_start (GTK_BOX (vbox), dialog->off_se, FALSE, FALSE, 0);
  gtk_widget_show (dialog->off_se);

  gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (dialog->off_se), GIMP_UNIT_PIXEL);

  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (dialog->off_se), 0,
                                  xres, FALSE);
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (dialog->off_se), 1,
                                  yres, FALSE);

  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (dialog->off_se), 0,
                                         - gimp_item_get_width (item),
                                         gimp_item_get_width (item));
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (dialog->off_se), 1,
                                         - gimp_item_get_height (item),
                                         gimp_item_get_height (item));

  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (dialog->off_se), 0,
                            0, gimp_item_get_width (item));
  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (dialog->off_se), 1,
                            0, gimp_item_get_height (item));

  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (dialog->off_se), 0, 0);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (dialog->off_se), 1, 0);

  button = gtk_button_new_with_mnemonic (_("By width/_2, height/2"));
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (offset_half_xy_callback),
                    dialog);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  button = gtk_button_new_with_mnemonic ("By _width/2");
  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (offset_half_x_callback),
                    dialog);

  button = gtk_button_new_with_mnemonic ("By _height/2");
  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (offset_half_y_callback),
                    dialog);

  /*  The edge behavior frame  */
  frame = gimp_int_radio_group_new (TRUE, _("Edge Behavior"),
                                    G_CALLBACK (gimp_radio_button_update),
                                    &dialog->fill_type, dialog->fill_type,

                                    _("W_rap around"),
                                    WRAP_AROUND, NULL,

                                    _("Fill with _background color"),
                                    GIMP_OFFSET_BACKGROUND, NULL,

                                    _("Make _transparent"),
                                    GIMP_OFFSET_TRANSPARENT, &radio_button,
                                    NULL);

  if (! gimp_drawable_has_alpha (drawable))
    gtk_widget_set_sensitive (radio_button, FALSE);

  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  return dialog->dialog;
}
Пример #8
0
/* camera_new */
Camera * camera_new(GtkWidget * window, GtkAccelGroup * group,
		char const * device)
{
	Camera * camera;
	GtkWidget * vbox;
	GtkWidget * widget;
	GtkToolItem * toolitem;

	if((camera = object_new(sizeof(*camera))) == NULL)
		return NULL;
	camera->device = (device != NULL)
		? string_new(device) : string_new("/dev/video0");
	camera->hflip = FALSE;
	camera->vflip = FALSE;
	camera->ratio = TRUE;
	camera->interp = GDK_INTERP_BILINEAR;
	camera->snapshot_format = CSF_PNG;
	camera->snapshot_quality = 100;
	camera->source = 0;
	camera->fd = -1;
	memset(&camera->cap, 0, sizeof(camera->cap));
	camera->channel = NULL;
	camera->buffers = NULL;
	camera->buffers_cnt = 0;
	camera->raw_buffer = NULL;
	camera->raw_buffer_cnt = 0;
	camera->rgb_buffer = NULL;
	camera->rgb_buffer_cnt = 0;
	camera->yuv_amp = 255;
	camera->overlays = NULL;
	camera->overlays_cnt = 0;
	camera->widget = NULL;
	camera->window = window;
	camera->bold = NULL;
	camera->gc = NULL;
	camera->pr_window = NULL;
	camera->pp_window = NULL;
	/* check for errors */
	if(camera->device == NULL)
	{
		camera_delete(camera);
		return NULL;
	}
	/* create the window */
	camera->bold = pango_font_description_new();
	pango_font_description_set_weight(camera->bold, PANGO_WEIGHT_BOLD);
	camera->gc = gdk_gc_new(window->window); /* XXX */
#if GTK_CHECK_VERSION(3, 0, 0)
	camera->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
	camera->widget = gtk_vbox_new(FALSE, 0);
#endif
	vbox = camera->widget;
	/* toolbar */
	widget = desktop_toolbar_create(_camera_toolbar, camera, group);
	gtk_widget_set_sensitive(GTK_WIDGET(_camera_toolbar[0].widget), FALSE);
	gtk_widget_set_sensitive(GTK_WIDGET(_camera_toolbar[2].widget), FALSE);
	gtk_widget_set_sensitive(GTK_WIDGET(_camera_toolbar[4].widget), FALSE);
	toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_FULLSCREEN);
	g_signal_connect_swapped(toolitem, "clicked", G_CALLBACK(
				_camera_on_fullscreen), camera);
	gtk_toolbar_insert(GTK_TOOLBAR(widget), toolitem, -1);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
#if GTK_CHECK_VERSION(2, 18, 0)
	/* infobar */
	camera->infobar = gtk_info_bar_new_with_buttons(GTK_STOCK_CLOSE,
			GTK_RESPONSE_CLOSE, NULL);
	gtk_info_bar_set_message_type(GTK_INFO_BAR(camera->infobar),
			GTK_MESSAGE_ERROR);
	g_signal_connect(camera->infobar, "close", G_CALLBACK(gtk_widget_hide),
			NULL);
	g_signal_connect(camera->infobar, "response", G_CALLBACK(
				gtk_widget_hide), NULL);
	widget = gtk_info_bar_get_content_area(GTK_INFO_BAR(camera->infobar));
	camera->infobar_label = gtk_label_new(NULL);
	gtk_widget_show(camera->infobar_label);
	gtk_box_pack_start(GTK_BOX(widget), camera->infobar_label, TRUE, TRUE,
			0);
	gtk_widget_set_no_show_all(camera->infobar, TRUE);
	gtk_box_pack_start(GTK_BOX(vbox), camera->infobar, FALSE, TRUE, 0);
#endif
	camera->area = gtk_drawing_area_new();
	camera->pixmap = NULL;
	g_signal_connect(camera->area, "configure-event", G_CALLBACK(
				_camera_on_drawing_area_configure), camera);
	g_signal_connect(camera->area, "expose-event", G_CALLBACK(
				_camera_on_drawing_area_expose), camera);
	gtk_box_pack_start(GTK_BOX(vbox), camera->area, TRUE, TRUE, 0);
	gtk_widget_show_all(vbox);
	camera_start(camera);
	return camera;
}
Пример #9
0
int main(int argc, char *argv[]) {

  GtkWidget *window;
  GtkWidget *vbox;

  GtkWidget *menubar;
  GtkWidget *fileMenu;
  GtkWidget *imprMenu;
  GtkWidget *sep;
  GtkWidget *fileMi;
  GtkWidget *imprMi;
  GtkWidget *feedMi;
  GtkWidget *bookMi;
  GtkWidget *mailMi;
  GtkWidget *quitMi;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window), 1024, 728);
  gtk_window_set_title(GTK_WINDOW(window), "Submenu");

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window), vbox);

  menubar = gtk_menu_bar_new();
  
  fileMenu = gtk_menu_new();
  fileMi = gtk_menu_item_new_with_label("File");
  
  imprMenu = gtk_menu_new();
  imprMi = gtk_menu_item_new_with_label("Importar");
  feedMi = gtk_menu_item_new_with_label("Importar novos...");
  bookMi = gtk_menu_item_new_with_label("Importar Favoritos...");
  mailMi = gtk_menu_item_new_with_label("Importar Enviados...");
  
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(imprMi), imprMenu);
  gtk_menu_shell_append(GTK_MENU_SHELL(imprMenu), feedMi);
  gtk_menu_shell_append(GTK_MENU_SHELL(imprMenu), bookMi);
  gtk_menu_shell_append(GTK_MENU_SHELL(imprMenu), mailMi);
  sep = gtk_separator_menu_item_new();  
  quitMi = gtk_menu_item_new_with_label("Sair");

  gtk_menu_item_set_submenu(GTK_MENU_ITEM(fileMi), fileMenu);
  gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), imprMi);
  gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), sep);
  gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), quitMi);
  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), fileMi);
  gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);

  g_signal_connect(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), NULL);

  g_signal_connect(G_OBJECT(quitMi), "activate",
        G_CALLBACK(gtk_main_quit), NULL);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}
Пример #10
0
static void
buoh_view_init (BuohView *buoh_view)
{
        GtkWidget *label;
        GtkWidget *swindow;

	gtk_widget_set_can_focus (GTK_WIDGET (buoh_view), TRUE);
	
        buoh_view->priv = BUOH_VIEW_GET_PRIVATE (buoh_view);

	buoh_view->priv->status = STATE_MESSAGE_WELCOME;

	/* Image view */
        swindow = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
	buoh_view->priv->comic = buoh_view_comic_new (buoh_view);
	gtk_container_add (GTK_CONTAINER (swindow),
			   buoh_view->priv->comic);
	gtk_widget_show (buoh_view->priv->comic);
	
        gtk_notebook_insert_page (GTK_NOTEBOOK (buoh_view), swindow,
                                  NULL, VIEW_PAGE_IMAGE);
        gtk_widget_show (swindow);

        /* Message view */
	swindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
					GTK_POLICY_NEVER,
					GTK_POLICY_NEVER);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow),
					     GTK_SHADOW_NONE);
	buoh_view->priv->message = buoh_view_message_new ();
	buoh_view_message_set_title (BUOH_VIEW_MESSAGE (buoh_view->priv->message),
				     _("Buoh online comic strips reader"));
	buoh_view_message_set_text (BUOH_VIEW_MESSAGE (buoh_view->priv->message),
				    _("Welcome to <b>Buoh</b>, the online comics reader for GNOME Desktop.\n"
				      "The list on the left panel contains your favourite comic strips "
				      "to add or remove comics to the list click on Comic -> Add. "
				      "Just select a comic from the list, and it will be displayed "
				      "on the right side. Thanks for using Buoh."));
	buoh_view_message_set_icon (BUOH_VIEW_MESSAGE (buoh_view->priv->message), "buoh");
	gtk_container_add (GTK_CONTAINER (swindow),
			   buoh_view->priv->message);
	gtk_widget_show (buoh_view->priv->message);
	
        gtk_notebook_insert_page (GTK_NOTEBOOK (buoh_view), swindow,
                                  NULL, VIEW_PAGE_MESSAGE);
        gtk_widget_show (swindow);

        /* Empty view */
        label = gtk_label_new (NULL);
        gtk_notebook_insert_page (GTK_NOTEBOOK (buoh_view), label,
                                  NULL, VIEW_PAGE_EMPTY);
        gtk_widget_show (label);

	
        gtk_notebook_set_current_page (GTK_NOTEBOOK (buoh_view), VIEW_PAGE_MESSAGE);

        /* Callbacks */
        g_signal_connect (G_OBJECT (buoh_view), "notify::status",
                          G_CALLBACK (buoh_view_status_changed_cb),
                          NULL);
	g_signal_connect (G_OBJECT (buoh_view->priv->comic),
			  "notify::scale",
			  G_CALLBACK (buoh_view_scale_changed_cb),
			  (gpointer) buoh_view);

        gtk_widget_show (GTK_WIDGET (buoh_view));
}
Пример #11
0
void
dialog_so_styled (WBCGtk *wbcg, GObject *so, GOStyle *default_style,
		  char const *title, so_styled_t extent)
{
	DialogSOStyled *state;
	GtkWidget	*dialog, *help, *editor;
	GOStyle *style;

	/* Only pop up one copy per workbook */
	if (gnm_dialog_raise_if_exists (wbcg, GNM_SO_STYLED_KEY)) {
		g_object_unref (default_style);
		return;
	}

	state = g_new0 (DialogSOStyled, 1);
	state->so    = G_OBJECT (so);
	state->wbcg  = wbcg;
	state->orig_props = go_object_properties_collect (so);
	force_new_style (state->so);

	dialog = gtk_dialog_new_with_buttons
		(title,
		 wbcg_toplevel (state->wbcg),
		 GTK_DIALOG_DESTROY_WITH_PARENT,
		 NULL, NULL);
	state->extent = extent;

	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (dialog),
					   state->wbcg,
					   GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);

	help = gtk_dialog_add_button (GTK_DIALOG (dialog),
		GTK_STOCK_HELP,		GTK_RESPONSE_HELP);
	gnm_init_help_button (help, "sect-graphics-drawings");

	gtk_dialog_add_buttons (GTK_DIALOG (dialog),
		GNM_STOCK_CANCEL,	GTK_RESPONSE_CANCEL,
		GNM_STOCK_OK,		GTK_RESPONSE_OK,
		NULL);

	g_object_get (so, "style", &style, NULL);
	editor = go_style_get_editor (style, default_style,
				      GO_CMD_CONTEXT (wbcg), G_OBJECT (so));
	g_object_unref (style);

	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
		editor, TRUE, TRUE, TRUE);
	g_object_unref (default_style);

	if (extent & SO_STYLED_TEXT) {
		GtkWidget *text_w = dialog_so_styled_text_widget (state);
		gtk_widget_show_all (text_w);
		if (GTK_IS_NOTEBOOK (editor))
			gtk_notebook_append_page (GTK_NOTEBOOK (editor),
						  text_w,
						  gtk_label_new (_("Content")));
		else
			gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
					    text_w, TRUE, TRUE, TRUE);
	}

	if (extent & SO_STYLED_LINE) {
		GtkWidget *w = dialog_so_styled_line_widget (state, "end-arrow");
		gtk_widget_show_all (w);
		if (GTK_IS_NOTEBOOK (editor))
			gtk_notebook_append_page (GTK_NOTEBOOK (editor), w,
						  gtk_label_new (_("Head")));
		else
			gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
					    w, TRUE, TRUE, TRUE);
	}

	if (extent & SO_STYLED_LINE) {
		GtkWidget *w = dialog_so_styled_line_widget (state, "start-arrow");
		gtk_widget_show_all (w);
		if (GTK_IS_NOTEBOOK (editor))
			gtk_notebook_append_page (GTK_NOTEBOOK (editor), w,
						  gtk_label_new (_("Tail")));
		else
			gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
					    w, TRUE, TRUE, TRUE);
	}

	g_signal_connect (G_OBJECT (dialog), "response",
		G_CALLBACK (cb_dialog_so_styled_response), state);
	gnm_keyed_dialog (state->wbcg, GTK_WINDOW (dialog),
		GNM_SO_STYLED_KEY);
	g_object_set_data_full (G_OBJECT (dialog),
		"state", state, (GDestroyNotify) dialog_so_styled_free);
	go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg),
		GTK_WINDOW (dialog));
	wbc_gtk_attach_guru (state->wbcg, dialog);
	gtk_widget_show (dialog);
}
Пример #12
0
static void
jana_gtk_recurrence_init (JanaGtkRecurrence *self)
{
	GtkWidget *label, *hbox, *sub_hbox, *arrow, *button;
	GtkSizeGroup *size_group;

	JanaGtkRecurrencePrivate *priv = RECURRENCE_PRIVATE (self);
	
	gtk_box_set_spacing (GTK_BOX (self), 6);
	
	/* Create preview text-view */
	priv->preview_frame = gtk_frame_new (NULL);
	priv->preview_textview = gtk_text_view_new ();
	gtk_text_view_set_editable (GTK_TEXT_VIEW (
		priv->preview_textview), FALSE);
	gtk_text_view_set_cursor_visible (
		GTK_TEXT_VIEW (priv->preview_textview), FALSE);
	gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->preview_textview),
		GTK_WRAP_WORD_CHAR);
	gtk_container_add (GTK_CONTAINER (priv->preview_frame),
		priv->preview_textview);
	gtk_box_pack_end (GTK_BOX (self), priv->preview_frame, TRUE, TRUE, 0);
	gtk_frame_set_shadow_type (
		GTK_FRAME (priv->preview_frame), GTK_SHADOW_NONE);
	gtk_widget_show_all (priv->preview_frame);
	
	priv->edit_vbox = gtk_vbox_new (FALSE, 6);
	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
	
	/* 'Repeats' (recurrence type) combo box */
	hbox = gtk_hbox_new (FALSE, 6);
	label = gtk_label_new ("Repeats:");
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_size_group_add_widget (size_group, label);
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
	priv->type_combo = gtk_combo_box_new_text ();
	gtk_combo_box_append_text (GTK_COMBO_BOX (priv->type_combo), "None");
	gtk_combo_box_append_text (GTK_COMBO_BOX (priv->type_combo),
		"Every day");
	gtk_combo_box_append_text (GTK_COMBO_BOX (priv->type_combo),
		"Every week");
	gtk_combo_box_append_text (GTK_COMBO_BOX (priv->type_combo),
		"Every year");
	gtk_combo_box_set_active (GTK_COMBO_BOX (priv->type_combo), 0);
	gtk_box_pack_start (GTK_BOX (hbox), priv->type_combo, TRUE, TRUE, 0);
	g_signal_connect (priv->type_combo, "changed",
		G_CALLBACK (type_combo_changed_cb), self);
	/* Interval buttons */
	sub_hbox = gtk_hbox_new (TRUE, 0);
	priv->interval_dec_button = gtk_button_new ();
	arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (priv->interval_dec_button), arrow);
	gtk_box_pack_start (GTK_BOX (sub_hbox), priv->interval_dec_button,
		FALSE, TRUE, 0);
	priv->interval_inc_button = gtk_button_new ();
	arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (priv->interval_inc_button), arrow);
	gtk_box_pack_start (GTK_BOX (sub_hbox), priv->interval_inc_button,
		FALSE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), sub_hbox, FALSE, TRUE, 0);
	g_signal_connect (priv->interval_inc_button, "clicked",
		G_CALLBACK (interval_inc_clicked_cb), self);
	g_signal_connect (priv->interval_dec_button, "clicked",
		G_CALLBACK (interval_dec_clicked_cb), self);
	
	gtk_widget_show_all (hbox);
	gtk_box_pack_start (GTK_BOX (priv->edit_vbox), hbox, FALSE, TRUE, 0);
	
	/* Weekly recurrence day-chooser */
	priv->week_hbox = gtk_hbox_new (FALSE, 6);
	label = gtk_label_new ("On:");
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_size_group_add_widget (size_group, label);
	gtk_box_pack_start (GTK_BOX (priv->week_hbox), label, FALSE, TRUE, 0);
	sub_hbox = gtk_hbox_new (TRUE, 0);
	/* Weekday toggle widgets */
#define day_toggle_widget(x) \
	button = gtk_toggle_button_new_with_label (jana_utils_ab_day (x)); \
	gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE); \
	gtk_box_pack_start (GTK_BOX (sub_hbox), button, TRUE, TRUE, 0); \
	priv->week_buttons[x] = GTK_TOGGLE_BUTTON (button); \
	g_signal_connect (button, "toggled", \
		G_CALLBACK (day##x##_toggled_cb), self)
	day_toggle_widget(0);
	day_toggle_widget(1);
	day_toggle_widget(2);
	day_toggle_widget(3);
	day_toggle_widget(4);
	day_toggle_widget(5);
	day_toggle_widget(6);
	gtk_box_pack_start (GTK_BOX (priv->week_hbox), sub_hbox, TRUE, TRUE, 0);

	gtk_widget_show_all (priv->week_hbox);
	gtk_box_pack_start (GTK_BOX (priv->edit_vbox), priv->week_hbox,
		FALSE, TRUE, 0);
	
	/* Monthly recurrence by date/day chooser */
	priv->month_hbox = gtk_hbox_new (FALSE, 6);
	label = gtk_label_new ("By:");
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_size_group_add_widget (size_group, label);
	gtk_box_pack_start (GTK_BOX (priv->month_hbox), label, FALSE, TRUE, 0);
	sub_hbox = gtk_hbox_new (TRUE, 0);
	/* By day */
	priv->byday_button = GTK_TOGGLE_BUTTON (
		gtk_radio_button_new_with_label (NULL, "Day"));
	gtk_toggle_button_set_mode (priv->byday_button, FALSE);
	gtk_box_pack_start (GTK_BOX (sub_hbox), GTK_WIDGET (
		priv->byday_button), FALSE, TRUE, 0);
	/* By date */
	priv->bydate_button = GTK_TOGGLE_BUTTON (
		gtk_radio_button_new_with_label_from_widget (
			GTK_RADIO_BUTTON (priv->byday_button), "Date"));
	gtk_toggle_button_set_mode (priv->bydate_button, FALSE);
	g_signal_connect (priv->bydate_button, "toggled",
		G_CALLBACK (bydate_toggled_cb), self);
	gtk_box_pack_start (GTK_BOX (sub_hbox), GTK_WIDGET (
		priv->bydate_button), FALSE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (priv->month_hbox), sub_hbox,
		FALSE, TRUE, 0);
	
	gtk_widget_show_all (priv->month_hbox);
	gtk_box_pack_start (GTK_BOX (priv->edit_vbox), priv->month_hbox,
		FALSE, TRUE, 0);
	
	/* Until time editor */
	priv->end_hbox = gtk_hbox_new (FALSE, 6);
	label = gtk_label_new ("Until:");
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_size_group_add_widget (size_group, label);
	gtk_box_pack_start (GTK_BOX (priv->end_hbox), label, FALSE, TRUE, 0);
	priv->end_button = gtk_button_new ();
	hbox = gtk_hbox_new (FALSE, 6);
	priv->end_label = gtk_label_new (NULL);
	arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
	gtk_box_pack_start (GTK_BOX (hbox), priv->end_label, TRUE, TRUE, 0);
	gtk_box_pack_end (GTK_BOX (hbox), arrow, FALSE, TRUE, 0);
	gtk_container_add (GTK_CONTAINER (priv->end_button), hbox);
	g_signal_connect (priv->end_button, "clicked",
		G_CALLBACK (end_clicked_cb), self);
	gtk_box_pack_start (GTK_BOX (priv->end_hbox), priv->end_button,
		FALSE, TRUE, 0);
	
	gtk_widget_show_all (priv->end_hbox);
	gtk_box_pack_start (GTK_BOX (priv->edit_vbox), priv->end_hbox,
		FALSE, TRUE, 0);
	
	gtk_box_pack_start (GTK_BOX (self), priv->edit_vbox, FALSE, TRUE, 0);

	gtk_widget_set_no_show_all (priv->edit_vbox, TRUE);
	gtk_widget_set_no_show_all (priv->preview_frame, TRUE);
	
	refresh (self);
}
static void budgie_session_dialog_init(BudgieSessionDialog *self)
{
        GtkWidget *main_layout, *layout, *button;
        GtkWidget *top;
        GtkWidget *image;
        GtkWidget *label;
        autofree gchar *txt = NULL;
        GError *error = NULL;
        GtkStyleContext *style;
        gboolean can_reboot = FALSE;
        gboolean can_poweroff = FALSE;
        gboolean can_systemd = TRUE;
        autofree gchar *result = NULL;
        SdResponse response;

        init_styles(self);

        /* Let's set up some systemd logic eh? */
        self->proxy = sd_login_manager_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
                G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
                "org.freedesktop.login1",
                "/org/freedesktop/login1",
                NULL,
                &error);
        if (error) {
                g_error_free(error);
                can_systemd = FALSE;
        } else {
                can_systemd = TRUE;
        }

        if (can_systemd) {
                /* Can we reboot? */
                if (!sd_login_manager_call_can_reboot_sync(self->proxy,
                        &result, NULL, NULL)) {
                        can_reboot = FALSE;
                } else {
                        response = get_response(result);
                        if (response == SD_YES || response == SD_CHALLENGE) {
                                can_reboot = TRUE;
                        }
                }
                /* Can we shutdown? */
                if (!sd_login_manager_call_can_power_off_sync(self->proxy,
                        &result, NULL, NULL)) {
                        can_poweroff = FALSE;
                } else {
                        response = get_response(result);
                        if (response == SD_YES || response == SD_CHALLENGE) {
                                can_poweroff = TRUE;
                        }
                }
        }


        gtk_window_set_position(GTK_WINDOW(self), GTK_WIN_POS_CENTER_ALWAYS);
        gtk_window_set_title(GTK_WINDOW(self), "End your session?");
        gtk_window_set_default_size(GTK_WINDOW(self), 300, -1);

        main_layout = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
        gtk_container_set_border_width(GTK_CONTAINER(main_layout), 10);
        gtk_container_add(GTK_CONTAINER(self), main_layout);

        top = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
        gtk_box_pack_start(GTK_BOX(main_layout), top, FALSE, FALSE, 0);

        layout = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
        gtk_widget_set_halign(layout, GTK_ALIGN_CENTER);
        gtk_box_pack_start(GTK_BOX(main_layout), layout, TRUE, TRUE, 0);

        /* Nice side image.. because why not */
        image = gtk_image_new_from_icon_name("system-shutdown-symbolic",
                GTK_ICON_SIZE_INVALID);
        gtk_image_set_pixel_size(GTK_IMAGE(image), 48);
        gtk_box_pack_start(GTK_BOX(top), image, FALSE, FALSE, 0);

        /* And a helpful label */
        txt = g_strdup_printf("<big>Goodbye, %s!</big>", g_get_user_name());
        label = gtk_label_new(txt);
        gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
        gtk_box_pack_start(GTK_BOX(top), label, TRUE, TRUE, 0);

        /* Add some buttons to uh.. logout, etc. :) */
        button = gtk_button_new_with_label("Logout");
        g_object_set_data(G_OBJECT(button), "action", "logout");
        g_signal_connect(button, "clicked", G_CALLBACK(clicked), self);
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0);

        button = gtk_button_new_with_label("Reboot");
        g_object_set_data(G_OBJECT(button), "action", "reboot");
        g_signal_connect(button, "clicked", G_CALLBACK(clicked), self);
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0);
        if (!can_reboot) {
                gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
        }

        button = gtk_button_new_with_label("Poweroff");
        g_object_set_data(G_OBJECT(button), "action", "poweroff");
        g_signal_connect(button, "clicked", G_CALLBACK(clicked), self);
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0);
        if (!can_poweroff) {
                gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
        }

        button = gtk_button_new_with_label("Cancel");
        g_object_set_data(G_OBJECT(button), "action", "cancel");
        g_signal_connect(button, "clicked", G_CALLBACK(clicked), self);
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0);

        /* Cheat, shadow + styling, but no titlebar */
        gtk_window_set_titlebar(GTK_WINDOW(self), gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));

        /* Can haz style? */
        style = gtk_widget_get_style_context(GTK_WIDGET(self));
        gtk_style_context_add_class(style, GTK_STYLE_CLASS_OSD);
}