Ejemplo n.º 1
0
int 
main (int argc, char* argv[])
{
	GtkWidget *window;
	GtkWidget *label;
	GtkWidget *vbox;
	
	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quit), NULL);

	vbox = gtk_vbox_new (FALSE, 0);

	gtk_container_add (GTK_CONTAINER (window), vbox);
	
	label = eel_editable_label_new ("Centered dsau dsfgsdfgoydsfiugy oiusdyfg iouysdf goiuys dfioguy siodufgy iusdyfgiu ydsf giusydf gouiysdfgoiuysdfg oiudyfsg Label");

	gtk_widget_set_size_request (label, 200, -1);
	eel_editable_label_set_line_wrap (EEL_EDITABLE_LABEL (label), TRUE);
	
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);

	label = eel_editable_label_new ("Left aligned label");

#if GTK_CHECK_VERSION (3, 14, 0)
	gtk_widget_set_halign (label, GTK_ALIGN_START);
#else
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
#endif
	
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);

	label = eel_editable_label_new ("Right aligned label");

#if GTK_CHECK_VERSION (3, 14, 0)
	gtk_widget_set_halign (label, GTK_ALIGN_END);
	gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
#else
	gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
#endif
	
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
	
	gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
	
	gtk_widget_show_all (window);	
	
	gtk_main ();

	return 0;
}
Ejemplo n.º 2
0
static GtkCellEditable*
marlin_text_renderer_start_editing (GtkCellRenderer     *cell,
                                    GdkEvent            *event,
                                    GtkWidget           *widget,
                                    const gchar         *path,
                                    const GdkRectangle  *background_area,
                                    const GdkRectangle  *cell_area,
                                    GtkCellRendererState flags)
{
    MarlinTextRenderer *text_renderer = MARLIN_TEXT_RENDERER (cell);
    gint xpad, ypad;
    gfloat xalign, yalign;
    gboolean mode, visible;

    /* verify that we are visible & editable */
    g_object_get (cell, "visible", &visible, "mode", &mode, NULL);
    if (!(visible && mode == GTK_CELL_RENDERER_MODE_EDITABLE))
        return NULL;
    //g_message ("%s %s\n", G_STRFUNC, path);

    gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);

    /* allocate a new text entry widget to be used for editing */
    /*text_renderer->entry = g_object_new (GTK_TYPE_ENTRY,
                                         "has-frame", FALSE,
                                         "text", text_renderer->text,
                                         "visible", TRUE,
                                         "xalign", xalign,
                                         NULL);*/
    text_renderer->entry = eel_editable_label_new ("Test text");
    eel_editable_label_set_line_wrap (EEL_EDITABLE_LABEL (text_renderer->entry), TRUE);
    eel_editable_label_set_line_wrap_mode (EEL_EDITABLE_LABEL (text_renderer->entry), text_renderer->wrap_mode);
    eel_editable_label_set_draw_outline (EEL_EDITABLE_LABEL (text_renderer->entry), TRUE);

    /* presume we're in POSITION UNDER */
    if (text_renderer->wrap_width > 0)
        eel_editable_label_set_justify (EEL_EDITABLE_LABEL (text_renderer->entry), GTK_JUSTIFY_CENTER);

    //gtk_misc_set_alignment (GTK_MISC (text_renderer->entry), xalign, yalign);
    g_object_set (text_renderer->entry, "yalign", yalign, NULL);
    gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
    gtk_misc_set_padding (GTK_MISC (text_renderer->entry), xpad, ypad);

    if (text_renderer->zoom_level < MARLIN_ZOOM_LEVEL_NORMAL)
        g_object_set (text_renderer->entry, "small-size", TRUE, NULL);

    gtk_widget_set_size_request (text_renderer->entry, text_renderer->wrap_width, -1);
    eel_editable_label_set_text (EEL_EDITABLE_LABEL (text_renderer->entry),
                                 text_renderer->text);
    gtk_widget_show (text_renderer->entry);

    /* remember the tree path that we're editing */
    g_object_set_data_full (G_OBJECT (text_renderer->entry), "marlin-text-renderer-path", g_strdup (path), g_free);

    /* connect required signals */
    g_signal_connect (G_OBJECT (text_renderer->entry), "editing-done", G_CALLBACK (marlin_text_renderer_editing_done), text_renderer);
    g_signal_connect (G_OBJECT (text_renderer->entry), "focus-out-event", G_CALLBACK (marlin_text_renderer_focus_out_event), text_renderer);
    g_signal_connect (G_OBJECT (text_renderer->entry), "populate-popup", G_CALLBACK (marlin_text_renderer_populate_popup), text_renderer);

    return GTK_CELL_EDITABLE (text_renderer->entry);
}