venkat_330

Texpage with GTK

Dec 13th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.90 KB | None | 0 0
  1.  
  2. gboolean dispTextPage_callBack(dispTextPage_struct *params)
  3. {
  4.     char* fileName = params -> fileName;
  5.     int isJustifyCenter = 0;
  6.     GtkWidget *textv;
  7.     GdkWindow *textv_window;
  8.     GdkPixmap *pixmap;
  9.     GtkTextBuffer* textBuffer;
  10.     GdkColor color;
  11.     destroyWidget(0);
  12.     textv = gtk_text_view_new ();
  13.     gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textv), 22);
  14.     gtk_text_view_set_right_margin(GTK_TEXT_VIEW(textv), 20);
  15.     gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(textv),1);
  16.     gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textv), GTK_WRAP_CHAR);
  17.     if (isJustifyCenter == 1)
  18.     {
  19.         gtk_text_view_set_justification(GTK_TEXT_VIEW(textv), GTK_JUSTIFY_CENTER);
  20.     }
  21.     else
  22.     {
  23.         gtk_text_view_set_justification(GTK_TEXT_VIEW(textv), GTK_JUSTIFY_LEFT);
  24.     }
  25.     gtk_text_view_set_editable(GTK_TEXT_VIEW(textv), FALSE);
  26.     gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textv), FALSE);
  27.     gtk_container_add(GTK_CONTAINER(window), textv);
  28.    textv_window = gtk_text_view_get_window (GTK_TEXT_VIEW (textv),GTK_TEXT_WINDOW_TEXT);
  29.     gdk_color_parse ("#68604d", &color);
  30.     pixmap = gdk_pixmap_create_from_xpm ((GdkDrawable *) textv_window, NULL,&color, fileName);
  31.     gdk_window_set_back_pixmap (textv_window, pixmap, FALSE);
  32.     g_object_unref(pixmap);
  33.     textBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textv));
  34.     gtk_text_buffer_create_tag (textBuffer, "bold","foreground", "Black", NULL);
  35.     gtk_text_buffer_create_tag (textBuffer, "Redbold","foreground", "Red",NULL);
  36.     gtk_text_buffer_create_tag (textBuffer, "fontSize","font", "saxmono 20",NULL);
  37.     gtk_text_buffer_create_tag (textBuffer, "smallFontSize", "font", "saxmono 14", NULL);
  38.     gtk_text_buffer_create_tag (textBuffer, "fontweight","weight", 1000,NULL);
  39.     index = addToWidgetsAlive(textv, NULL);
  40.     gtk_widget_show(textv);
  41.     gtk_widget_show(window);   
  42.     free(params);
  43. return FALSE;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment