Example #1
1
GtkWidget * about_widget_create_view_from_file(char * file, char * default_text)
{
	GtkTextView * view = GTK_TEXT_VIEW(gtk_text_view_new());
	gtk_text_view_set_editable(view, FALSE);
	gtk_text_view_set_cursor_visible(view, FALSE);
	gtk_text_view_set_wrap_mode(view, GTK_WRAP_WORD_CHAR);

	char * file_path = vex_term_find_ressource(file);
	if (file_path != NULL){
		SrtParser * srt = srt_parser_new();
		//TODO: need to free the SrtParser
		GtkTextBuffer * buffer = srt_parser_parse_file(srt, file_path);
		free(file_path);
		if (buffer != NULL){
			gtk_text_view_set_buffer(view, buffer);
			return GTK_WIDGET(view);
		}
	}
	GtkTextBuffer * buffer = gtk_text_buffer_new(NULL);
	GtkTextIter iter;
	gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
	gtk_text_view_set_buffer(view, buffer);
	gtk_text_buffer_insert(buffer, &iter, default_text, -1);
	return GTK_WIDGET(view);
}
Example #2
0
/* This test imports an RTF file, exports it, and imports it again. The export
operation cannot fail, but if either import operation fails, the test fails. It
then compares the plaintext of the two GtkTextBuffers, and if they differ, the
test fails. Otherwise, the test succeeds.
Comparing the plaintext is for lack of a better way to compare the text buffers'
formatting. */
static void
rtf_write_pass_case(gconstpointer name)
{
    GError *error = NULL;
    GtkTextBuffer *buffer1 = gtk_text_buffer_new(NULL);
    GtkTextBuffer *buffer2 = gtk_text_buffer_new(NULL);
    gchar *filename = build_filename(name);
    
	if(!rtf_text_buffer_import(buffer1, filename, &error))
	    g_test_message("Import error message: %s", error->message);
	g_free(filename);
	g_assert(error == NULL);
	gchar *string = rtf_text_buffer_export_to_string(buffer1);
	if(!rtf_text_buffer_import_from_string(buffer2, string, &error))
	    g_test_message("Export error message: %s", error->message);
	g_assert(error == NULL);
	    
	GtkTextIter start, end;
	gtk_text_buffer_get_bounds(buffer1, &start, &end);
	gchar *text1 = gtk_text_buffer_get_slice(buffer1, &start, &end, TRUE);
	gtk_text_buffer_get_bounds(buffer2, &start, &end);
	gchar *text2 = gtk_text_buffer_get_slice(buffer2, &start, &end, TRUE);
	g_assert_cmpstr(text1, ==, text2);
	
	g_free(text1);
	g_free(text2);
	g_object_unref(buffer1);
	g_object_unref(buffer2);
	g_free(string);
}
Example #3
0
GtkWidget *hview_get_message_window(HviewWidgetsT *w)
{
	GtkWidget		*window;
	GtkWidget		*log_view;
	GtkTextBuffer	*buf;

	window = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
				       GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_AUTOMATIC);
      
	gtk_widget_set_size_request(GTK_WIDGET(window),
				    HVIEW_LOG_WINDOW_WIDTH,
				    HVIEW_LOG_WINDOW_HEIGHT);
	log_view = gtk_text_view_new();

	buf = gtk_text_buffer_new(NULL);
	gtk_text_view_set_buffer(GTK_TEXT_VIEW(log_view), buf);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(log_view), FALSE);
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(log_view), FALSE);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(window),
					      log_view);

	w->message_view = log_view;

	return window;
}
static GtkTextBuffer *
ev_view_accessible_get_text_buffer (EvViewAccessible *accessible, EvView *view)
{
	EvPageCache *page_cache;
	const gchar *retval = NULL;
	EvViewAccessiblePriv* priv = EV_VIEW_ACCESSIBLE_GET_PRIVATE (accessible);

	page_cache = view->page_cache;
	if (!page_cache) {
		return NULL;
	}

	if (view->current_page == priv->current_page && priv->buffer) {
		return priv->buffer;
	}

	priv->current_page = view->current_page;

	if (!priv->buffer) {
		priv->buffer = gtk_text_buffer_new (NULL);
	}

	retval = ev_page_cache_get_text (page_cache, view->current_page);
	if (retval)
		gtk_text_buffer_set_text (priv->buffer, retval, -1);

	return priv->buffer;
}
Example #5
0
/**
 * 创建好友信息区域.
 * @return 主窗体
 */
GtkWidget *DialogPeer::CreateInfoArea()
{
        GtkWidget *frame, *sw;
        GtkWidget *widget;
        GtkTextBuffer *buffer;

        frame = gtk_frame_new(_("Info."));
        g_datalist_set_data(&widset, "info-frame", frame);
        gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
        sw = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
                                                 GTK_SHADOW_ETCHED_IN);
        gtk_container_add(GTK_CONTAINER(frame), sw);

        buffer = gtk_text_buffer_new(progdt.table);
        if (grpinf->member)
                FillPalInfoToBuffer(buffer, (PalInfo *)grpinf->member->data);
        widget = gtk_text_view_new_with_buffer(buffer);
        gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(widget), FALSE);
        gtk_text_view_set_editable(GTK_TEXT_VIEW(widget), FALSE);
        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(widget), GTK_WRAP_NONE);
        gtk_container_add(GTK_CONTAINER(sw), widget);
        g_datalist_set_data(&widset, "info-textview-widget", widget);

        return frame;
}
Example #6
0
File: main.c Project: chipx86/gtk
static GtkWidget *
create_text (GtkTextBuffer **buffer,
	     gboolean        is_source)
{
  GtkWidget *scrolled_window;
  GtkWidget *text_view;
  PangoFontDescription *font_desc;

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
				       GTK_SHADOW_IN);
  
  text_view = gtk_text_view_new ();
  gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
  
  *buffer = gtk_text_buffer_new (NULL);
  gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), *buffer);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE);

  if (is_source)
    {
      font_desc = pango_font_description_from_string ("Courier 10");
      gtk_widget_modify_font (text_view, font_desc);
      pango_font_description_free (font_desc);
    }
  
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), !is_source);
  
  return scrolled_window;
}
Example #7
0
gchar *
gimp_text_buffer_get_markup (GimpTextBuffer *buffer)
{
  GtkTextTagTable *tag_table;
  GtkTextBuffer   *content;
  GtkTextIter      insert;
  GtkTextIter      start, end;
  gchar           *markup;
  gsize            length;

  g_return_val_if_fail (GIMP_IS_TEXT_BUFFER (buffer), NULL);

  tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (buffer));
  content = gtk_text_buffer_new (tag_table);

  gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
  gtk_text_buffer_get_start_iter (content, &insert);

  gtk_text_buffer_insert_range (content, &insert, &start, &end);

  gimp_text_buffer_pre_serialize (buffer, content);

  gtk_text_buffer_get_bounds (content, &start, &end);

  markup = (gchar *) gtk_text_buffer_serialize (GTK_TEXT_BUFFER (buffer),
                                                content,
                                                buffer->markup_atom,
                                                &start, &end,
                                                &length);

  g_object_unref (content);

  return markup;
}
Example #8
0
GtkTextBuffer *ctk_config_create_help(CtkConfig *ctk_config, GtkTextTagTable *table)
{
    GtkTextIter i;
    GtkTextBuffer *b;

    b = gtk_text_buffer_new(table);
    
    gtk_text_buffer_get_iter_at_offset(b, &i, 0);

    ctk_help_title(b, &i, "nvidia-settings Configuration Help");

    ctk_help_data_list_print_sections(b, &i, ctk_config->help_data);
    
    ctk_help_heading(b, &i, "Active Timers");
    ctk_help_para(b, &i, "Some attributes are polled periodically "
                  "to ensure the reported values are up-to-date.  "
                  "Each row in the 'Active Timers' table reflects "
                  "the configuration of one of these timers and "
                  "controls how frequently, if at all, a given "
                  "attribute is polled.  The 'Description' field "
                  "describes the function of a timer, the 'Enabled' "
                  "field allows enabling/disabling it, the 'Time "
                  "Interval' field controls the delay between two "
                  "consecutive polls (in milliseconds).  The Active "
                  "Timers table is only visible when timers are active.");

    ctk_help_heading(b, &i, "Save Current Configuration");
    ctk_help_para(b, &i, "%s", __save_current_config_help);

    ctk_help_finish(b);

    return b;
    
} /* create_help() */
static GObject*
_gcr_display_view_constructor (GType type, guint n_props, GObjectConstructParam *props)
{
	GObject *obj = G_OBJECT_CLASS (_gcr_display_view_parent_class)->constructor (type, n_props, props);
	GcrDisplayView *self = NULL;
	GtkTextView *view = NULL;
	GtkTextTagTable *tags;

	g_return_val_if_fail (obj, NULL);

	self = GCR_DISPLAY_VIEW (obj);
	view = GTK_TEXT_VIEW (obj);

	tags = create_tag_table (self);
	self->pv->buffer = gtk_text_buffer_new (tags);
	g_object_unref (tags);

	gtk_text_view_set_buffer (view, self->pv->buffer);
	gtk_text_view_set_editable (view, FALSE);
	gtk_text_view_set_left_margin (view, NORMAL_MARGIN);
	gtk_text_view_set_right_margin (view, NORMAL_MARGIN);
	gtk_text_view_set_cursor_visible (view, FALSE);

	return obj;
}
Example #10
0
static GtkTextBuffer *create_default_help(CtkHelp *ctk_help)
{
    GtkTextIter iter, start, end;
    GtkTextBuffer *buffer;

    buffer = gtk_text_buffer_new(ctk_help->tag_table);

    gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);

    gtk_text_buffer_insert_with_tags_by_name
    (buffer, &iter, "\nNVIDIA X Server Settings Help", -1,
     CTK_HELP_TITLE_TAG, NULL);

    gtk_text_buffer_insert(buffer, &iter, "\n\nThere is no help available "
                           "for this page.", -1);

    /*
     * Apply CTK_HELP_HEADING_NOT_EDITABLE_TAG and
     * CTK_HELP_WORD_WRAP_TAG to the whole buffer
     */

    gtk_text_buffer_get_bounds(buffer, &start, &end);
    gtk_text_buffer_apply_tag_by_name
    (buffer, CTK_HELP_HEADING_NOT_EDITABLE_TAG, &start, &end);
    gtk_text_buffer_apply_tag_by_name
    (buffer, CTK_HELP_WORD_WRAP_TAG, &start, &end);
    gtk_text_buffer_apply_tag_by_name
    (buffer, CTK_HELP_MARGIN_TAG, &start, &end);

    return buffer;
}
Example #11
0
bg_gtk_textview_t * bg_gtk_textview_create()
  {
  bg_gtk_textview_t * t;
  
  t = calloc(1, sizeof(*t));
  
  if(!tag_table)
    {
    tag_table = gtk_text_tag_table_new();
    
    text_tag = gtk_text_tag_new("Font");
    g_object_set(text_tag, "editable", 0, NULL);
    
    gtk_text_tag_table_add(tag_table,
                           text_tag);
    }
  
  t->buffer = gtk_text_buffer_new(tag_table);
  t->textview = gtk_text_view_new_with_buffer(t->buffer);

  g_signal_connect(G_OBJECT(t->textview), "realize",
                   G_CALLBACK(set_bg), NULL);
  
  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(t->textview), FALSE);
  
  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(t->textview), GTK_WRAP_NONE);
  gtk_text_view_set_editable(GTK_TEXT_VIEW(t->textview), 0);
  
  gtk_widget_show(t->textview);
  return t;
  }
Example #12
0
int main (int argc, char *argv[])
{

    gtk_init(&argc, &argv);
    GtkWidget *window1;
    GtkButton *button,*button10;

    GtkBuilder *gtkbuilder = gtk_builder_new();
    gtk_builder_add_from_file(gtkbuilder,"arayuz-chat.glade",NULL);


    window1 = GTK_WIDGET( gtk_builder_get_object( gtkbuilder, "window1" ) );
    button = GTK_BUTTON(gtk_builder_get_object(gtkbuilder,"button11"));
    button10 = GTK_BUTTON(gtk_builder_get_object(gtkbuilder,"button10"));
    textentry2 = GTK_WIDGET(gtk_builder_get_object(gtkbuilder,"entry2"));
    text1 = GTK_TEXT_VIEW(gtk_builder_get_object(gtkbuilder,"textview1"));
    label3 = GTK_LABEL(gtk_builder_get_object(gtkbuilder,"label3"));
    g_object_unref(G_OBJECT(gtkbuilder));
    //Buton tıklama sinyalini tanımladık
    g_signal_connect( GTK_BUTTON( button ), "clicked", G_CALLBACK( on_button4_clicked ), NULL );
    g_signal_connect( GTK_BUTTON( button10 ), "clicked", G_CALLBACK( on_button10_clicked ), NULL );
    g_signal_connect(GTK_ENTRY(textentry2),"changed",G_CALLBACK(on_entry2_changed),NULL);

    textbuffer1 = gtk_text_buffer_new(NULL);
    gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text1), GTK_WRAP_WORD);


    //Arayüzü başlatır
    gtk_text_buffer_set_text(textbuffer1,"selam",-1);
    gtk_widget_show_all(window1);
    gtk_main ();

    return 0;
}
Example #13
0
void		create_area(t_editor *editor)
{
  editor->area = gtk_text_view_new();
  gtk_widget_set_size_request(editor->area, 500, 680);
  gtk_fixed_put(GTK_FIXED(editor->frame), editor->area, 30, 40);
  editor->buffer = gtk_text_buffer_new(NULL);
}
Example #14
0
static InfSession*
inf_test_gtk_browser_session_new(InfIo* io,
                                 InfConnectionManager* manager,
                                 InfConnectionManagerGroup* sync_group,
                                 InfXmlConnection* sync_connection,
                                 gpointer user_data)
{
  InfTextGtkBuffer* buffer;
  InfUserTable* user_table;
  GtkTextBuffer* textbuffer;
  InfTextSession* session;

  textbuffer = gtk_text_buffer_new(NULL);
  user_table = inf_user_table_new();
  buffer = inf_text_gtk_buffer_new(textbuffer, user_table);

  session = inf_text_session_new_with_user_table(
    manager,
    INF_TEXT_BUFFER(buffer),
    io,
    user_table,
    sync_group,
    sync_connection
  );

  return INF_SESSION(session);
}
void entries_vis_init (void){
	/*GtkTreeViewColumn *c1, *c2, *c3;
	GtkCellRenderer *cr1, *cr2, *cr3;
*/
	clip = gtk_clipboard_get (GDK_NONE);
	if (clip) //why shouldn't it?
		isThereAClip = TRUE;

	entryBuf = gtk_text_buffer_new (NULL);
	simpleSheet = gtk_text_view_new_with_buffer (entryBuf);
	gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (simpleSheet), GTK_WRAP_WORD);
	simpleSigID = g_signal_connect (G_OBJECT (entryBuf), "changed",
		G_CALLBACK (meta_saveable), GINT_TO_POINTER (GRG_SAVE_ACTIVE));
/*
	mdl = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
	structSheet = gtk_tree_view_new_with_model (GTK_TREE_MODEL (mdl));
	g_object_unref (G_OBJECT (mdl));
	
	cr1=gtk_cell_renderer_text_new ();
	cr2=gtk_cell_renderer_text_new ();
	cr3=gtk_cell_renderer_text_new ();
	c1=gtk_tree_view_column_new_with_attributes ("URL", cr1, "text", 0, NULL);
	c2=gtk_tree_view_column_new_with_attributes ("UserID", cr2, "text", 1, NULL);
	c3=gtk_tree_view_column_new_with_attributes ("Password", cr3, "text", 2, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (structSheet), c1);
	gtk_tree_view_append_column (GTK_TREE_VIEW (structSheet), c2);
	gtk_tree_view_append_column (GTK_TREE_VIEW (structSheet), c3);*/
}
Example #16
0
void
gui_window_switch_to_buffer (struct t_gui_window *window,
                             struct t_gui_buffer *buffer,
                             int set_last_read)
{
    GtkTextIter start, end;

    gui_buffer_add_value_num_displayed (window->buffer, -1);

    if (window->buffer != buffer)
    {
        window->scroll->start_line = NULL;
        window->scroll->start_line_pos = 0;
        if (!gui_buffers_visited_frozen)
        {
            gui_buffer_visited_add (window->buffer);
            gui_buffer_visited_add (buffer);
        }
        if (set_last_read)
        {
            if (window->buffer->num_displayed == 0)
            {
                window->buffer->lines->last_read_line = window->buffer->lines->last_line;
                window->buffer->lines->first_line_not_read = 0;
            }
            if (buffer->lines->last_read_line == buffer->lines->last_line)
            {
                buffer->lines->last_read_line = NULL;
                buffer->lines->first_line_not_read = 0;
            }
        }
    }

    window->buffer = buffer;
    gui_window_calculate_pos_size (window);

    if (!GUI_WINDOW_OBJECTS(window)->textview_chat)
    {
        GUI_WINDOW_OBJECTS(window)->textview_chat = gtk_text_view_new ();
        gtk_widget_show (GUI_WINDOW_OBJECTS(window)->textview_chat);
        gtk_container_add (GTK_CONTAINER (gui_gtk_scrolledwindow_chat), GUI_WINDOW_OBJECTS(window)->textview_chat);
        gtk_widget_set_size_request (GUI_WINDOW_OBJECTS(window)->textview_chat, 300, -1);
        gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), FALSE);
        gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), FALSE);

        GUI_WINDOW_OBJECTS(window)->textbuffer_chat = gtk_text_buffer_new (NULL);
        gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), GUI_WINDOW_OBJECTS(window)->textbuffer_chat);

        /*GUI_WINDOW_OBJECTS(window)->texttag_chat = gtk_text_buffer_create_tag(GUI_WINDOW_OBJECTS(window)->textbuffer_chat, "courier", "font_family", "lucida");*/
        gtk_text_buffer_get_bounds (GUI_WINDOW_OBJECTS(window)->textbuffer_chat, &start, &end);
        gtk_text_buffer_apply_tag (GUI_WINDOW_OBJECTS(window)->textbuffer_chat, GUI_WINDOW_OBJECTS(window)->texttag_chat, &start, &end);
    }

    window->scroll->start_line = NULL;
    window->scroll->start_line_pos = 0;

    gui_buffer_add_value_num_displayed (buffer, 1);

    gui_hotlist_remove_buffer (buffer);
}
Example #17
0
//
// Constructor
//
CPreview::CPreview():m_Path(NULL), m_Data(NULL), m_FileType(TYPE_UNKNOWN), 
	m_MinX(0.0), m_MaxX(0.0), m_EpsX(0.0), m_MinY(0.0), m_MaxY(0.0), m_EpsY(0.0),
	m_ReverseY(FALSE)
{
	GtkWidget *vbox;

	m_Buffer = gtk_text_buffer_new(NULL);

	// Frame
	m_Widget = gtk_frame_new(NULL);
	vbox = gtk_vbox_new(FALSE, 4);
	gtk_container_add(GTK_CONTAINER(m_Widget), vbox);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);

	// Image area
	m_Preview = cmpack_preview_new();
	gtk_widget_set_size_request(m_Preview, 160, 160);
	gtk_box_pack_start(GTK_BOX(vbox), m_Preview, FALSE, TRUE, 0);
	gtk_widget_set_events(m_Preview, GDK_BUTTON_PRESS_MASK);
	gtk_widget_set_tooltip_text(m_Preview, "Double click to enlarge the preview");
	g_signal_connect(G_OBJECT(m_Preview), "button_press_event", G_CALLBACK(button_press_event), this);

	// Text area
	m_View = gtk_text_view_new_with_buffer(m_Buffer);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(m_View), GTK_WRAP_WORD_CHAR);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(m_View), false);
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(m_View), false);
	gtk_text_view_set_justification(GTK_TEXT_VIEW(m_View), GTK_JUSTIFY_CENTER);
	gtk_box_pack_start(GTK_BOX(vbox), m_View, TRUE, TRUE, 0);

	gtk_widget_show_all(m_Widget);
}
static GObject* 
gcr_certificate_details_widget_constructor (GType type, guint n_props, GObjectConstructParam *props) 
{
	GObject *obj = G_OBJECT_CLASS (gcr_certificate_details_widget_parent_class)->constructor (type, n_props, props);
	GcrCertificateDetailsWidget *self = NULL;
	GtkTextTagTable *tags;
	GtkWidget *widget; 
	GtkWidget *scroll;
	
	g_return_val_if_fail (obj, NULL);
	
	self = GCR_CERTIFICATE_DETAILS_WIDGET (obj);
	
	tags = create_tag_table (self);
	self->pv->buffer = gtk_text_buffer_new (tags);
	g_object_unref (tags);
	
	widget = gtk_text_view_new_with_buffer (self->pv->buffer);
	self->pv->view = GTK_TEXT_VIEW (widget);
	gtk_text_view_set_editable (self->pv->view, FALSE);
	
	scroll = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_container_add (GTK_CONTAINER (scroll), widget);
	
	gtk_container_add (GTK_CONTAINER (self), scroll);
	gtk_widget_show_all (scroll);
	
	return obj;
}
Example #19
0
void CGTKBase::CreateAbout()
{
    const int windoww = 350, windowh = 350;
    
    m_pAboutDialog = gtk_dialog_new_with_buttons(GetTranslation("About"), GTK_WINDOW(m_pMainWindow),
                                                 GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
                                                 GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
    gtk_window_set_default_size(GTK_WINDOW(m_pAboutDialog), windoww, windowh);
    
    GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);
    GtkTextIter iter;
    std::string buf;
    std::ifstream aboutfile(GetAboutFName());
    char c;
    
    gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
    
    while (aboutfile.get(c))
        buf += c;
    
    gtk_text_buffer_insert(buffer, &iter, buf.c_str(), -1);
    
    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    GtkWidget *textview = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(buffer));
    gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
    gtk_container_add(GTK_CONTAINER(scrolled), textview);
    gtk_widget_show(textview);
    
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(m_pAboutDialog)->vbox), scrolled);
    gtk_widget_show(scrolled);
}
void
matedialog_text (MateDialogData *data, MateDialogTextData *text_data)
{
  GtkBuilder *builder;
  GtkWidget *dialog;
  GObject *text_view;
  GtkTextBuffer *text_buffer;

  zen_text_data = text_data;
  builder = matedialog_util_load_ui_file ("matedialog_text_dialog",
  				      "textbuffer1", NULL);
	
  if (builder == NULL) {
    data->exit_code = matedialog_util_return_exit_code (MATEDIALOG_ERROR);
    return;
  }
	
  gtk_builder_connect_signals (builder, NULL);
	  
  dialog = GTK_WIDGET (gtk_builder_get_object (builder, "matedialog_text_dialog"));
	
  g_signal_connect (G_OBJECT (dialog), "response",
                    G_CALLBACK (matedialog_text_dialog_response), data);
	
  if (data->dialog_title)
    gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);

  matedialog_util_set_window_icon (dialog, data->window_icon, MATEDIALOG_IMAGE_FULLPATH ("matedialog-text.png"));

  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);

  text_buffer = gtk_text_buffer_new (NULL);
  text_view = gtk_builder_get_object (builder, "matedialog_text_view");
  gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
  gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);

  if (text_data->uri)
    matedialog_util_fill_file_buffer (text_buffer, text_data->uri);
  else
    matedialog_text_fill_entries_from_stdin (GTK_TEXT_BUFFER (text_buffer));

  if (text_data->editable)
    zen_text_data->buffer = text_buffer;

  if (data->width > -1 || data->height > -1)
    gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
  else
    gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400); 

  matedialog_util_show_dialog (dialog);

  g_object_unref (builder);

  if(data->timeout_delay > 0) {
    g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) matedialog_util_timeout_handle, NULL);
  }

  gtk_main ();
}
Example #21
0
void MultilineOptionView::_createItem() {
	myTextBuffer = GTK_TEXT_BUFFER(gtk_text_buffer_new(0));
	g_signal_connect(myTextBuffer, "changed", G_CALLBACK(_onValueChanged), this);
	myTextView = GTK_TEXT_VIEW(gtk_text_view_new_with_buffer(myTextBuffer));
	gtk_text_view_set_wrap_mode(myTextView, GTK_WRAP_WORD);
	myHolder.attachWidget(*this, GTK_WIDGET(myTextView));
	reset();
}
Example #22
0
Amt::LoggerImpl::LoggerImpl( const crtc::ItemContext* _cntx  ): LoggerImplBase( _cntx ){
	_in_maxLines = 1000;
	_in_size = 8.;    	
	_in_widget = NULL;
	_in_textbuffer = NULL;
	_in_textview = NULL;
	_in_textbuffer = gtk_text_buffer_new(NULL);
}
void
on_clear_chat_contents_clicked         (GtkToolButton   *toolbutton,
                                        gpointer         user_data)
{
	GtkWidget* view = (GtkWidget*)lookup_widget(main_window, "text_chat");
	GtkTextBuffer* buffer = gtk_text_buffer_new(NULL);
	gtk_text_view_set_buffer(GTK_TEXT_VIEW (view),buffer);
}
Example #24
0
GtkWidget *
do_css_basics (GtkWidget *do_widget)
{
  if (!window)
    {
      GtkWidget *container, *child;
      GtkStyleProvider *provider;
      GtkTextBuffer *text;
      GBytes *bytes;

      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
      gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
      gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      text = gtk_text_buffer_new (NULL);
      gtk_text_buffer_create_tag (text,
                                  "warning",
                                  "underline", PANGO_UNDERLINE_SINGLE,
                                  NULL);
      gtk_text_buffer_create_tag (text,
                                  "error",
                                  "underline", PANGO_UNDERLINE_ERROR,
                                  NULL);

      provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());

      container = gtk_scrolled_window_new (NULL, NULL);
      gtk_container_add (GTK_CONTAINER (window), container);
      child = gtk_text_view_new_with_buffer (text);
      gtk_container_add (GTK_CONTAINER (container), child);
      g_signal_connect (text, "changed",
                        G_CALLBACK (css_text_changed), provider);

      bytes = g_resources_lookup_data ("/css_basics/css_basics.css", 0, NULL);
      gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
      g_bytes_unref (bytes);

      g_signal_connect (provider,
                        "parsing-error",
                        G_CALLBACK (show_parsing_error),
                        gtk_text_view_get_buffer (GTK_TEXT_VIEW (child)));

      apply_css (window, provider);
    }

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

  return window;
}
Example #25
0
void EditorActionCreateNoteParagraph::apply (GtkTextTagTable * texttagtable, bool editable, EditorActionCreateParagraph * focused_paragraph, GtkWidget *& to_focus)
{
  // Horizontal box to store the note.
  hbox = gtk_hbox_new (false, 0);
  gtk_widget_show (hbox);
  gtk_box_pack_start(GTK_BOX(parent_vbox), hbox, false, false, 0);

  // Eventbox to catch a few events on the caller of the note.
  eventbox = gtk_event_box_new ();
  gtk_widget_show (eventbox);
  gtk_box_pack_start(GTK_BOX(hbox), eventbox, false, false, 0);
  g_signal_connect ((gpointer) eventbox, "enter_notify_event", G_CALLBACK (on_caller_enter_notify_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox, "leave_notify_event", G_CALLBACK (on_caller_leave_notify_event), gpointer (this));

  // The background of the caller is going to be grey.
  // Courier font is chosen to make the spacing of the callers equal so they line up nicely.
  label = gtk_label_new ("");
  gtk_widget_show (label);
  char *markup = g_markup_printf_escaped("<span background=\"grey\" size=\"x-small\"> </span><span background=\"grey\" face=\"Courier\">%s</span><span background=\"grey\" size=\"x-small\"> </span>", caller_text.c_str());
  gtk_label_set_markup(GTK_LABEL(label), markup);
  g_free(markup);
  gtk_container_add (GTK_CONTAINER (eventbox), label);

  // The textbuffer uses the text tag table.
  textbuffer = gtk_text_buffer_new(texttagtable);

  // Text view to view the text buffer.
  textview = gtk_text_view_new_with_buffer(textbuffer);
  gtk_widget_show(textview);
  gtk_box_pack_start(GTK_BOX(hbox), textview, true, true, 0);

  // Set some parameters of the view.
  gtk_text_view_set_accepts_tab(GTK_TEXT_VIEW(textview), FALSE);
  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);
  gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), editable);
  gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textview), 5);
  gtk_text_view_set_right_margin(GTK_TEXT_VIEW(textview), 5);

  // Move the widget to the right position. To be calculated.
  /*
    vector <GtkWidget *> widgets = editor_get_widgets (parent_vbox);
    gint new_paragraph_offset = 0;
    if (focused_paragraph) {
      for (unsigned int i = 0; i < widgets.size(); i++) {
        if (focused_paragraph->textview == widgets[i]) {
          new_paragraph_offset = i + 1;
          break;
        }
      }
    }
    gtk_box_reorder_child (GTK_BOX(parent_vbox), textview, new_paragraph_offset);
  */
  
  // Let the newly created textview be earmarked to grab focus
  // so that the user can type in it,
  // and the internal Editor logic knows about it.
  to_focus = textview;
}
Example #26
0
void bug_information_window_new(GtkWidget * window)
{
	GtkWidget *dialog;
	GtkTextBuffer *buffer;
	GtkWidget *scrolled_window, *text_view;
	PangoTabArray *tab_array;

	/* Basic dialog with a close button */
	dialog = gtk_dialog_new_with_buttons(_("Bug information"),
										 (window) ? (GtkWindow *) playlist3_get_window() : NULL,
										 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
										 GTK_STOCK_CLOSE, GTK_RESPONSE_YES, NULL);

	/* Set default window size */
	gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 800);
	/* The buffer that holds the "report" */
	buffer = gtk_text_buffer_new(NULL);

	bug_information_generate_message(buffer);

	/* View to show the textbuffer */
	text_view = gtk_text_view_new();
	/* setup textview */
	/* set tabarray */
	tab_array = pango_tab_array_new_with_positions(1, TRUE, PANGO_TAB_LEFT, 500);
	gtk_text_view_set_accepts_tab(GTK_TEXT_VIEW(text_view), TRUE);
	gtk_text_view_set_tabs(GTK_TEXT_VIEW(text_view), tab_array);
	pango_tab_array_free(tab_array);

	/* not editable */
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
	/* set margins */
	gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_view), 12);
	gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text_view), 12);

	/* Add the text buffer */
	gtk_text_view_set_buffer(GTK_TEXT_VIEW(text_view), buffer);

	/* scrolled window, this allows the text view to scroll */
	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	/* setup scrolled window */
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_ETCHED_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	/* add text view to scrolled_window */
	gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
	/* add scrolled_window to dialog */
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolled_window, TRUE, TRUE, 0);

	/* Add dialogs response handler */
	g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL);
	/* show dialog */
	gtk_widget_show_all(dialog);
	if (window == NULL)
	{
		gtk_dialog_run(GTK_DIALOG(dialog));
	}
}
Example #27
0
static void menu_new (GtkMenuItem *menuitem, gpointer data) {
  if (save_if_modified()) {
    // get all the current tag table and put them in the new buffer
    editor_buf = gtk_text_buffer_new(gtk_text_buffer_get_tag_table(editor_buf));
    gtk_text_view_set_buffer(GTK_TEXT_VIEW(editor_view), editor_buf);
    g_object_unref(G_OBJECT(editor_buf)); 
    // needed for freeing memory by the buffer when a new buffer is created
  }
}
Example #28
0
void read_old_notes()
{
	Note *note;
	GtkTextBuffer *text_buffer;
	GtkTextIter iter;
	DIR *dir = opendir(".");
	FILE *file;
	struct dirent *entry;
	int reserved1;
	int reserved2;
	int i;
	char buffer[256];

	rewinddir(dir);
	while((entry = readdir(dir)) != NULL) {
		/* Check if it is a valid note name */
		for(i=0; entry->d_name[i]; i++) {
			if(entry->d_name[i] < '0' || entry->d_name[i] > '9') break;
		}
		if(i < strlen(entry->d_name)) continue;

		file = fopen(entry->d_name, "r");
		note = malloc(sizeof(Note));

		note->id = atoi(entry->d_name);
		if(note->id > highest_note_id) highest_note_id = note->id;

		fscanf(file, "%d,%d,%d,%d,%d,%d,",
			&(note->x), &(note->y), &(note->width), &(note->height),
			&reserved1, &reserved2);

		/* Get color name */
		fgets(buffer, 256, file);
		/* Replace the newline with a null char */
		buffer[strlen(buffer) - 1] = '\0';

		for(i=num_color_schemes; i > 0; i--) {
			if(!strcmp(color_schemes[i].name, buffer)) break;
		}
		note->scheme = &color_schemes[i];

		text_buffer = gtk_text_buffer_new(NULL);
		while(fgets(buffer, 256, file)) {
			gtk_text_buffer_get_end_iter(text_buffer, &iter);
			gtk_text_buffer_insert(text_buffer, &iter, buffer, -1);
		}

		note->text_widget = gtk_text_view_new_with_buffer(text_buffer);

		create_note(note, note->scheme);

		fclose(file);
	}

	closedir(dir);
}
Example #29
0
gint
main (gint   argc,
      gchar *argv[])
{
  GtkWidget     *window;
  GtkWidget     *sw;
  GtkWidget     *view;
  GtkTextBuffer *buffer;
  GdkAtom        atom;
  guint          i, broken = 0;

  gtk_init (&argc, &argv);

  /* initialize random numbers, disable this for deterministic testing */
  if (1)        
    quick_rand32_accu = g_random_int();

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_size_request (window, 400, 300);

  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
                                       GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER (window), sw);

  g_signal_connect (window, "delete-event",
                    G_CALLBACK (delete_event),
                    NULL);

  buffer = gtk_text_buffer_new (NULL);
  view = gtk_text_view_new_with_buffer (buffer);
  g_object_unref (buffer);

  gtk_container_add (GTK_CONTAINER (sw), view);

  gtk_widget_show_all (window);
  if (0)
    gtk_main ();

  for (i = 0; i < 250; i++)
    {
      GError *error = NULL;
      g_printerr ("creating randomly tagged text buffer with accu=0x%x...\n", quick_rand32_accu);
      atom = setup_buffer (buffer);
      if (test_serialize_deserialize (buffer, atom, &error))
        g_printerr ("ok.\n");
      else
        {
          g_printerr ("FAIL: serialization/deserialization failed:\n  %s\n", error->message);
          broken += 1;
        }
      g_clear_error (&error);
    }

  return broken > 0;
}
Example #30
0
static void menu_open (GtkMenuItem *menuitem, gpointer data) {
  if (save_if_modified()) {
    // call save if modified when user opens a new file
    editor_buf = gtk_text_buffer_new(gtk_text_buffer_get_tag_table(editor_buf));
    gtk_text_view_set_buffer(GTK_TEXT_VIEW(editor_view), editor_buf);
    // needed for freeing memory by the buffer when a new buffer is created
    g_object_unref(G_OBJECT(editor_buf));
    load_file(NULL);
  }
}