当前位置: 首页>>代码示例>>C++>>正文


C++ GTK_TEXT_VIEW函数代码示例

本文整理汇总了C++中GTK_TEXT_VIEW函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_TEXT_VIEW函数的具体用法?C++ GTK_TEXT_VIEW怎么用?C++ GTK_TEXT_VIEW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GTK_TEXT_VIEW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int   argc,
         char *argv[] )
{
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window, *text_view, *vbox, *vbox1, vbox2, *show, *prefs, *win;
    GtkTextTag *tag;
    GtkTextBuffer *buffer;
    GtkTextIter start, end;

    WplPidginSettings *settings = NULL;

    settings = WplPidginSettings_construct();
    WplPidginSettings_loadFromFile(settings);
    settings->wpl->opensearchCallback = G_CALLBACK(opensearchMenuCallback);

    g_print("---\nsettings: %s, %s,\n---", settings->wpl->url, settings->wpl->language);
    //g_print(_("Here is a translation test."));
    /* This is called in all GTK applications. Arguments are parsed
     * from the command line and are returned to the application. */
    gtk_init (&argc, &argv);

    /* create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    /* When the window is given the "delete-event" signal (this is given
     * by the window manager, usually by the "close" option, or on the
     * titlebar), we ask it to call the delete_event () function
     * as defined above. The data passed to the callback
     * function is NULL and is ignored in the callback function. */
    g_signal_connect (window, "delete-event",
		      G_CALLBACK (destroy), NULL);

    /* Here we connect the "destroy" event to a signal handler.
     * This event occurs when we call gtk_widget_destroy() on the window,
     * or if we return FALSE in the "delete-event" callback. */
    g_signal_connect (window, "destroy",
		      G_CALLBACK (destroy), NULL);

    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    gtk_window_set_default_size(GTK_WINDOW(window), 500, 500);


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

    gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
    gtk_widget_show(vbox);


    text_view = gtk_text_view_new();
    //win = gtk_scrolled_window_new(0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), text_view, TRUE, TRUE, 0);
    /*gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(win), GTK_SHADOW_IN);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(win),
                    GTK_POLICY_NEVER,
                    GTK_POLICY_ALWAYS);

    gtk_widget_show(win);

    prefs = WplPidginSettings_createViewAndModel(settings);*/
    gtk_container_add(GTK_CONTAINER(window), text_view);
    //gtk_box_pack_start(GTK_BOX(vbox), text_view, TRUE, TRUE, 0);
    //gtk_widget_set_has_tooltip ( text_view , true ) ;

    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
    /*g_signal_connect( G_OBJECT (text_view) , "query-tooltip" ,
                     G_CALLBACK (querytooltipcb) , (gpointer)settings->wpl) ;*/


    gtk_text_buffer_set_text(buffer, "Hallo Tooltip! Rory Gallagher.", -1);


    //mark = gtk_text_buffer_create_mark(buffer,"tooltip",,TRUE);
    //gtk_widget_set_tooltip_text(GTK_WIDGET(tag), "Word Tooltip");

    gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), TRUE);

    //show = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    //vbox1 = gtk_vbox_new(FALSE, 0);
    //gtk_container_add(GTK_CONTAINER(vbox), vbox1);
    //gtk_container_set_border_width(GTK_CONTAINER(vbox1), 4);
    //gtk_widget_show(vbox1);

    gtk_widget_show_all(window);

    //gtk_widget_show_all(show);

    g_signal_connect(G_OBJECT(text_view), "populate-popup", G_CALLBACK(WikipediaLookup_rightClickPopup), (gpointer)settings->wpl);

    /* All GTK applications must have a gtk_main(). Control ends here
     * and waits for an event to occur (like a key press or
     * mouse event). */
    gtk_main ();

    //g_signal_handlers_disconnect_matched(G_OBJECT(text_view),G_SIGNAL_MATCH_FUNC, 0, 0, NULL, G_CALLBACK(WikipediaLookup_rightClickPopup), NULL);
    WplPidginSettings_saveToFile(settings);
    WplPidginSettings_destruct(settings);

    return 0;
//.........这里部分代码省略.........
开发者ID:cyfsRecs,项目名称:Pidgin-plugin-for-Wikipedia-Lookup,代码行数:101,代码来源:standalone.c

示例2: warlock_view_create_text_view

static void
warlock_view_create_text_view (WarlockView *warlock_view)
{
        PangoFontDescription *font;
        GdkRGBA *color;
        GtkTextIter iter;
	GtkWidget *text_view;
        
        text_view = gtk_text_view_new ();
        gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view),
                        GTK_WRAP_WORD_CHAR);
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);


	warlock_view->text_buffer = gtk_text_buffer_new (highlight_tag_table);
	warlock_view->text_view = text_view;
	gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view),
			warlock_view->text_buffer);

        gtk_text_buffer_get_end_iter (warlock_view->text_buffer, &iter);
        warlock_view->mark = gtk_text_buffer_create_mark
                (warlock_view->text_buffer, NULL, &iter, TRUE);

        /* set the text color */
        color = preferences_get_color (preferences_get_key
                        (PREF_DEFAULT_TEXT_COLOR));
        if (color == NULL) {
                color = g_new (GdkRGBA, 1);
                gdk_rgba_parse (color, "white");
        }
	gtk_widget_override_color (text_view, GTK_STATE_NORMAL, color);
        g_free (color);

        /* set the background color*/
        color = preferences_get_color (preferences_get_key
                        (PREF_DEFAULT_BASE_COLOR));
        if (color == NULL) {
                color = g_new (GdkRGBA, 1);
                gdk_rgba_parse (color, "black");
        }
	gtk_widget_override_background_color (text_view, GTK_STATE_NORMAL,
			color);
        g_free (color);

        /* set the font */
        font = preferences_get_font (preferences_get_key (PREF_DEFAULT_FONT));
        if (font == NULL) {
                font = pango_font_description_from_string ("sans");
        }
	gtk_widget_override_font (text_view, font);

        /* listen to gconf and change the text color when the gconf
         * value changes */
        preferences_notify_add (preferences_get_key (PREF_DEFAULT_TEXT_COLOR),
                        change_text_color, text_view);

        /* listen for background change */
        preferences_notify_add (preferences_get_key (PREF_DEFAULT_BASE_COLOR),
                        change_base_color, text_view);

        /* listen for font change */
        preferences_notify_add (preferences_get_key (PREF_DEFAULT_FONT),
                        change_font, text_view);
}
开发者ID:sproctor,项目名称:warlock-gtk,代码行数:64,代码来源:warlockview.c

示例3: init_main_window

/* Main Window Initialization */
void init_main_window(const gchar * glade_file)
{
	GladeXML *xml;
	GtkWidget *widget;
	GtkTextBuffer *txtbuf;
	GtkStyle *style;

	xml = glade_xml_new(glade_file, "window1", NULL);
	if (!xml)
		g_error(_("GUI loading failed !\n"));
	glade_xml_signal_autoconnect(xml);

	main_wnd = glade_xml_get_widget(xml, "window1");
	hpaned = glade_xml_get_widget(xml, "hpaned1");
	vpaned = glade_xml_get_widget(xml, "vpaned1");
	tree1_w = glade_xml_get_widget(xml, "treeview1");
	tree2_w = glade_xml_get_widget(xml, "treeview2");
	text_w = glade_xml_get_widget(xml, "textview3");

	back_btn = glade_xml_get_widget(xml, "button1");
	gtk_widget_set_sensitive(back_btn, FALSE);

	widget = glade_xml_get_widget(xml, "show_name1");
	gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
				       show_name);

	widget = glade_xml_get_widget(xml, "show_range1");
	gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
				       show_range);

	widget = glade_xml_get_widget(xml, "show_data1");
	gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
				       show_value);

	save_btn = glade_xml_get_widget(xml, "button3");
	save_menu_item = glade_xml_get_widget(xml, "save1");
	conf_set_changed_callback(conf_changed);

	style = gtk_widget_get_style(main_wnd);
	widget = glade_xml_get_widget(xml, "toolbar1");

#if 0	/* Use stock Gtk icons instead */
	replace_button_icon(xml, main_wnd->window, style,
			    "button1", (gchar **) xpm_back);
	replace_button_icon(xml, main_wnd->window, style,
			    "button2", (gchar **) xpm_load);
	replace_button_icon(xml, main_wnd->window, style,
			    "button3", (gchar **) xpm_save);
#endif
	replace_button_icon(xml, main_wnd->window, style,
			    "button4", (gchar **) xpm_single_view);
	replace_button_icon(xml, main_wnd->window, style,
			    "button5", (gchar **) xpm_split_view);
	replace_button_icon(xml, main_wnd->window, style,
			    "button6", (gchar **) xpm_tree_view);

#if 0
	switch (view_mode) {
	case SINGLE_VIEW:
		widget = glade_xml_get_widget(xml, "button4");
		g_signal_emit_by_name(widget, "clicked");
		break;
	case SPLIT_VIEW:
		widget = glade_xml_get_widget(xml, "button5");
		g_signal_emit_by_name(widget, "clicked");
		break;
	case FULL_VIEW:
		widget = glade_xml_get_widget(xml, "button6");
		g_signal_emit_by_name(widget, "clicked");
		break;
	}
#endif
	txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
	tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
					  "foreground", "red",
					  "weight", PANGO_WEIGHT_BOLD,
					  NULL);
	tag2 = gtk_text_buffer_create_tag(txtbuf, "mytag2",
					  /*"style", PANGO_STYLE_OBLIQUE, */
					  NULL);

	gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);

	gtk_widget_show(main_wnd);
}
开发者ID:0919061,项目名称:PX4NuttX,代码行数:86,代码来源:gconf.c

示例4: mdu_shell_raise_error


//.........这里部分代码省略.........
                break;
        case MDU_ERROR_CANCELLED:
                error_msg = _("The operation was canceled.");
                break;
        case MDU_ERROR_INHIBITED:
                error_msg = _("The daemon is being inhibited.");
                break;
        case MDU_ERROR_INVALID_OPTION:
                error_msg = _("An invalid option was passed.");
                break;
        case MDU_ERROR_NOT_SUPPORTED:
                error_msg = _("The operation is not supported.");
                break;
        case MDU_ERROR_ATA_SMART_WOULD_WAKEUP:
                error_msg = _("Getting ATA SMART data would wake up the device.");
                break;
        case MDU_ERROR_PERMISSION_DENIED:
                error_msg = _("Permission denied.");
                break;
        default:
                error_msg = _("Unknown error");
                break;
        }

        dialog = gtk_message_dialog_new_with_markup (
                GTK_WINDOW (shell->priv->app_window),
                GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
                GTK_MESSAGE_ERROR,
                GTK_BUTTONS_CLOSE,
                "<big><b>%s</b></big>",
                error_text);
        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error_msg);

	/* Here we cheat a little by poking in the messagedialog internals
         * to add the details expander to the inner vbox and arrange things
         * so that resizing the dialog works as expected.
         */
	box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
	children = gtk_container_get_children (GTK_CONTAINER (box));
	hbox = GTK_WIDGET (children->data);
	gtk_container_child_set (GTK_CONTAINER (box), hbox,
                                 "expand", TRUE,
                                 "fill", TRUE,
                                 NULL);
	g_list_free (children);
	children = gtk_container_get_children (GTK_CONTAINER (hbox));
	box = GTK_WIDGET (children->next->data);
	g_list_free (children);
	children = gtk_container_get_children (GTK_CONTAINER (box));
	gtk_container_child_set (GTK_CONTAINER (box), GTK_WIDGET (children->next->data),
                                 "expand", FALSE,
                                 "fill", FALSE,
                                 NULL);
	g_list_free (children);

	expander = g_object_new (GTK_TYPE_EXPANDER,
                                 "label", _("_Details:"),
                                 "use-underline", TRUE,
                                 "use-markup", TRUE,
                                 NULL);
        sw = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
                           "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
                           "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
                           "shadow-type", GTK_SHADOW_IN,
                           NULL);
        buffer = gtk_text_buffer_new (NULL);
        gtk_text_buffer_set_text (buffer, error->message, -1);
	tv = gtk_text_view_new_with_buffer (buffer);
        gtk_text_view_set_editable (GTK_TEXT_VIEW (tv), FALSE);

        gtk_container_add (GTK_CONTAINER (sw), tv);
        gtk_container_add (GTK_CONTAINER (expander), sw);
	gtk_box_pack_end (GTK_BOX (box), expander, TRUE, TRUE, 0);
        gtk_widget_show_all (expander);

        /* Make the window resizable when the details are visible
         */
	g_signal_connect (expander, "notify::expanded", G_CALLBACK (expander_cb), dialog);

        /* We don't want the initial focus to end up on the expander,
         * so grab it to the close button on map.
         */
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
        g_signal_connect (dialog, "map", G_CALLBACK (fix_focus_cb), NULL);


        // TODO: no support for GIcon in GtkWindow
        //gtk_window_set_icon_name (GTK_WINDOW (dialog), window_icon_name);

        g_signal_connect_swapped (dialog,
                                  "response",
                                  G_CALLBACK (gtk_widget_destroy),
                                  dialog);
        gtk_window_present (GTK_WINDOW (dialog));

        g_free (window_title);
        if (window_icon != NULL)
                g_object_unref (window_icon);
        g_free (error_text);
}
开发者ID:raveit65,项目名称:mate-disk-utility,代码行数:101,代码来源:mdu-shell.c

示例5: normal_contents

static GtkWidget *
normal_contents (void)
{
  GtkWidget *table;
  GtkWidget *toolbar;
  GtkWidget *handlebox;
  GtkWidget *statusbar;
  GtkWidget *contents;
  GtkWidget *sw;
  GtkItemFactory *item_factory;

  table = gtk_table_new (1, 4, FALSE);

  /* Create the menubar
   */

  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", NULL);

  gtk_item_factory_set_translate_func(item_factory,
				      (GtkTranslateFunc)gettext, NULL, NULL);

  /* Set up item factory to go away */
  g_object_ref (item_factory);
  g_object_ref_sink (item_factory);
  g_object_unref (item_factory);
  g_object_set_data_full (G_OBJECT (table),
                          "<main>",
                          item_factory,
                          (GDestroyNotify) g_object_unref);

  /* create menu items */
  gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
                                 menu_items, NULL);

  gtk_table_attach (GTK_TABLE (table),
                    gtk_item_factory_get_widget (item_factory, "<main>"),
                    /* X direction */          /* Y direction */
                    0, 1,                      0, 1,
                    GTK_EXPAND | GTK_FILL,     0,
                    0,                         0);

  /* Create the toolbar
   */
  toolbar = gtk_toolbar_new ();

  GtkToolItem *newButton = gtk_tool_button_new_from_stock(GTK_STOCK_NEW);
  gtk_tool_item_set_tooltip_text(newButton,
				 "Open another one of these windows");
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     newButton,
		     -1); /*-1 means append to end of toolbar*/

  GtkToolItem *openButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
  gtk_tool_item_set_tooltip_text(openButton,
				 "This is a demo button with an \'open\' icon");
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     openButton,
		     -1); /*-1 means append to end of toolbar*/

  GtkToolItem *quitButton = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
  gtk_tool_item_set_tooltip_text(quitButton,
				 "This is a demo button with a \'quit\' icon");
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     quitButton,
		     -1); /*-1 means append to end of toolbar*/


  handlebox = gtk_handle_box_new ();

  gtk_container_add (GTK_CONTAINER (handlebox), toolbar);

  gtk_table_attach (GTK_TABLE (table),
                    handlebox,
                    /* X direction */       /* Y direction */
                    0, 1,                   1, 2,
                    GTK_EXPAND | GTK_FILL,  0,
                    0,                      0);

  /* Create document
   */

  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_IN);

  gtk_table_attach (GTK_TABLE (table),
                    sw,
                    /* X direction */       /* Y direction */
                    0, 1,                   2, 3,
                    GTK_EXPAND | GTK_FILL,  GTK_EXPAND | GTK_FILL,
                    0,                      0);

  contents = gtk_text_view_new ();
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
                               PANGO_WRAP_WORD);
//.........这里部分代码省略.........
开发者ID:Samsagax,项目名称:marco,代码行数:101,代码来源:theme-viewer.c

示例6: get_widget

G_MODULE_EXPORT void
on_options_generate_go_clicked         (GtkButton       *button,
                                        gpointer         user_data)
{
#ifndef _WIN32
	GtkWidget *number = get_widget ("options_generate_number");
	int n = gtk_spin_button_get_value (GTK_SPIN_BUTTON (number));
	char nn[10];
	snprintf (nn, sizeof(nn), "%d", n);
	GtkWidget *view = get_widget ("options_generate_entry");
	GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
	GtkTextIter start, end;
	gtk_text_buffer_get_iter_at_offset (buffer, &start, 0);
	gtk_text_buffer_get_iter_at_offset (buffer, &end, -1);
	char *text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);

	int wfd[2], rfd[2];
	pid_t cpid;

	if (pipe(wfd) == -1 || pipe(rfd) == -1) {
		perror("pipe");
		exit(EXIT_FAILURE);
	}

	cpid = fork();
	if (cpid == -1) {
		perror("fork");
		exit(EXIT_FAILURE);
	}

	if (cpid == 0) {    /* Child reads from pipe */
		close (wfd[1]);          /* Close unused write end */
		close (rfd[0]);
		dup2 (0, wfd[0]);
		dup2 (1, rfd[1]);
		execlp ("dealer", "dealer", "-v", "-p", nn, NULL);
		perror ("execlp");
		_exit(EXIT_FAILURE);

	} else {
		close (wfd[0]);          /* Close unused read end */
		close (rfd[1]);
		if (write (wfd[1], text, strlen (text)) == -1) {
			perror ("write");
			return;
		}
		close (wfd[1]);          /* Reader will see EOF */
	}

	int i;
	do {
		char buf[100];
		i = read (rfd[0], buf, sizeof (buf));
		buf[i == sizeof (buf) ? sizeof (buf) - 1 : i] = '\0';
		puts (buf);
	} while (i > 0);
	close (rfd[0]);

	g_free (text);
#endif
}
开发者ID:ChristophBerg,项目名称:tenace,代码行数:61,代码来源:options.c

示例7: quotefmt_create_forward_fmt_widgets


//.........这里部分代码省略.........
    size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

    if (checkbtn_forward_with_format)
        PACK_CHECK_BUTTON (parent_box, checkbtn_use_format,
                           _("Use template when forwarding messages"));

    vbox_quote = gtk_vbox_new (FALSE, 4);
    gtk_widget_show(vbox_quote);
    gtk_container_add(GTK_CONTAINER (parent_box), vbox_quote);
    gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);

    if (override_from_format) {
        hbox3 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox3);
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox3, FALSE, FALSE, 0);

        label_from = gtk_label_new (prefs_common_translated_header_name("From"));
        gtk_misc_set_alignment(GTK_MISC(label_from), 1, 0.5);
        gtk_widget_show (label_from);
        gtk_box_pack_start (GTK_BOX (hbox3), label_from, FALSE, FALSE, 0);
        gtk_size_group_add_widget(size_group, label_from);

        entry_from = gtk_entry_new ();
        gtk_widget_show (entry_from);
        gtk_box_pack_start (GTK_BOX (hbox3), entry_from, TRUE, TRUE, 0);
        gtk_widget_set_size_request (entry_from, 100, -1);

        CLAWS_SET_TIP(entry_from,
                      _("Override From header. This doesn't change the account used to forward."));
    }

    hbox1 = gtk_hbox_new (FALSE, 32);
    gtk_widget_show (hbox1);
    gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);

    hbox2 = gtk_hbox_new (FALSE, 8);
    gtk_widget_show (hbox2);
    gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);

    label_quotemark = gtk_label_new (_("Quotation mark"));
    gtk_misc_set_alignment(GTK_MISC(label_quotemark), 1, 0.5);
    gtk_widget_show (label_quotemark);
    gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
    gtk_size_group_add_widget(size_group, label_quotemark);

    entry_fw_quotemark = gtk_entry_new ();
    gtk_widget_show (entry_fw_quotemark);
    gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
                        FALSE, FALSE, 0);
    gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);

    scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (scrolledwin_quotefmt);
    gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
                        TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy
    (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type
    (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);

    text_fw_quotefmt = gtk_text_view_new ();
    if (prefs_common.textfont) {
        PangoFontDescription *font_desc;

        font_desc = pango_font_description_from_string
                    (prefs_common.textfont);
        if (font_desc) {
            gtk_widget_modify_font(text_fw_quotefmt, font_desc);
            pango_font_description_free(font_desc);
        }
    }
    gtk_widget_show(text_fw_quotefmt);
    gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
                      text_fw_quotefmt);
    gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
    gtk_widget_set_size_request (text_fw_quotefmt, -1, 100);

    if (checkbtn_forward_with_format) {
        SET_TOGGLE_SENSITIVITY(checkbtn_use_format, label_quotemark);
        SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_fw_quotemark);
        if (override_from_format) {
            SET_TOGGLE_SENSITIVITY(checkbtn_use_format, entry_from);
            SET_TOGGLE_SENSITIVITY(checkbtn_use_format, label_from);
        }
        SET_TOGGLE_SENSITIVITY(checkbtn_use_format, text_fw_quotefmt);
    }

    quote_fmt_add_buttons(parent_window, vbox_quote,
                          add_info_button, set_defaults_func);

    if (checkbtn_forward_with_format)
        *checkbtn_forward_with_format = checkbtn_use_format;
    *edit_fw_quotemark = entry_fw_quotemark;
    if (override_from_format)
        *override_from_format = entry_from;
    *edit_fw_format = text_fw_quotefmt;

    g_object_unref(G_OBJECT(size_group));
}
开发者ID:Tux,项目名称:claws-mail,代码行数:101,代码来源:quote_fmt.c

示例8: main


//.........这里部分代码省略.........
    // widget (GhbCompositor).
    blender = gtk_overlay_new();
    gtk_container_add(GTK_CONTAINER(align), blender);
    gtk_container_add(GTK_CONTAINER(blender), draw);
    gtk_widget_set_valign (hud, GTK_ALIGN_END);
    gtk_widget_set_halign (hud, GTK_ALIGN_CENTER);
    gtk_overlay_add_overlay(GTK_OVERLAY(blender), hud);

    g_signal_connect(G_OBJECT(blender), "get-child-position",
                    G_CALLBACK(position_overlay_cb), ud);

    gtk_widget_show(blender);
#else
    // Set up compositing for hud
    blender = ghb_compositor_new();

    gtk_container_add(GTK_CONTAINER(align), blender);
    ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1);
    ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85);
    gtk_widget_show(blender);
#endif

    // Redirect stderr to the activity window
    ghb_preview_init(ud);
    IoRedirect(ud);
    ghb_log( "%s - %s - %s",
        HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
    ghb_init_dep_map();

    // Need to connect x264_options textview buffer to the changed signal
    // since it can't be done automatically
    GtkTextView *textview;
    GtkTextBuffer *buffer;
    textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "x264Option"));
    buffer = gtk_text_view_get_buffer(textview);
    g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud);

    textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "x264OptionExtra"));
    buffer = gtk_text_view_get_buffer(textview);
    g_signal_connect(buffer, "changed", (GCallback)x264_option_changed_cb, ud);

    ghb_combo_init(ud);

    g_debug("ud %p\n", ud);
    g_debug("ud->builder %p\n", ud->builder);

    bind_audio_tree_model(ud);
    bind_subtitle_tree_model(ud);
    bind_presets_tree_model(ud);
    bind_queue_tree_model(ud);
    bind_chapter_tree_model(ud);
    // Connect up the signals to their callbacks
    // I wrote my own connector so that I could pass user data
    // to the callbacks.  Builder's standard autoconnect doesn't all this.
    gtk_builder_connect_signals_full(ud->builder, MyConnect, ud);

    GtkWidget *presetSlider = GHB_WIDGET(ud->builder, "x264PresetSlider");
    const char * const *x264_presets;
    int count = 0;
    x264_presets = hb_x264_presets();
    while (x264_presets && x264_presets[count]) count++;
    gtk_range_set_range(GTK_RANGE(presetSlider), 0, count-1);

    // Load all internal settings
    ghb_settings_init(ud);
    // Load the presets files
开发者ID:manuguerra,项目名称:HandBrakeMirror,代码行数:67,代码来源:main.c

示例9: gtk_accel_group_new


//.........这里部分代码省略.........

  // Fullscreen checkbox
  fullscreencheck = gtk_check_button_new_with_mnemonic ("_Fullscreen");
  gtk_widget_show (fullscreencheck);
  gtk_fixed_put (GTK_FIXED (configlayout), fullscreencheck, 248, 0);
  gtk_widget_set_size_request (fullscreencheck, 85, 29);
  gtk_widget_add_accelerator (fullscreencheck, "grab_focus", accel_group,
                              GDK_F, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);

  // Always show config checkbox
  alwaysshowcheck = gtk_check_button_new_with_mnemonic ("_Always show configuration on start");
  gtk_widget_show (alwaysshowcheck);
  gtk_box_pack_start (GTK_BOX (configvlayout), alwaysshowcheck, FALSE, FALSE, 0);
  gtk_widget_add_accelerator (alwaysshowcheck, "grab_focus", accel_group,
                              GDK_A, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);

  // Configuration tab
  configtab = gtk_label_new ("Configuration");
  gtk_widget_show (configtab);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 0), configtab);

  // Messages scrollable area
  messagesscroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (messagesscroll);
  gtk_container_add (GTK_CONTAINER (tabs), messagesscroll);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

  // Messages text area
  messagestext = gtk_text_view_new ();
  gtk_widget_show (messagestext);
  gtk_container_add (GTK_CONTAINER (messagesscroll), messagestext);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (messagestext), FALSE);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (messagestext), GTK_WRAP_WORD);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (messagestext), FALSE);
  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (messagestext), 2);
  gtk_text_view_set_right_margin (GTK_TEXT_VIEW (messagestext), 2);

  // Messages tab
  messagestab = gtk_label_new ("Messages");
  gtk_widget_show (messagestab);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 1), messagestab);

  // Dialogue box buttons layout
  buttons = gtk_hbutton_box_new ();
  gtk_widget_show (buttons);
  gtk_box_pack_start (GTK_BOX (vlayout), buttons, FALSE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (buttons), 3);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (buttons), GTK_BUTTONBOX_END);

  // Cancel button
  cancelbutton = gtk_button_new ();
  gtk_widget_show (cancelbutton);
  gtk_container_add (GTK_CONTAINER (buttons), cancelbutton);
  GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT);
  gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group,
                              GDK_C, GDK_MOD1_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group,
                              GDK_Escape, 0,
                              GTK_ACCEL_VISIBLE);

  cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (cancelbuttonalign);
  gtk_container_add (GTK_CONTAINER (cancelbutton), cancelbuttonalign);
开发者ID:Hendricks266,项目名称:jfbuild,代码行数:67,代码来源:startgtk.game.c

示例10: edit_properties


//.........这里部分代码省略.........
		return;
	}

	prop_dialog = g_new0 (PartPropDialog, 1);

	prop_dialog->part_item = item;

	prop_dialog->dialog = GTK_DIALOG (gtk_builder_get_object (gui, 
	                      "part-properties-dialog"));

	prop_grid = GTK_GRID (gtk_builder_get_object (gui, "prop_grid"));
	notebook  = GTK_NOTEBOOK (gtk_builder_get_object (gui, "notebook"));

	g_signal_connect (prop_dialog->dialog, "destroy",
		G_CALLBACK (prop_dialog_destroy),  prop_dialog);

	prop_dialog->widgets = NULL;
	has_model = FALSE;

	for (properties = part_get_properties (part); properties;
		properties = properties->next) {
		Property *prop;
		
		prop = properties->data;

		if (prop->name) {
			GtkWidget *entry;
			GtkWidget *label;
			gchar *temp=NULL;
			
			if (!g_ascii_strcasecmp (prop->name, "internal"))
				continue;

			if (!g_ascii_strcasecmp (prop->name,  "model")) {
				has_model = TRUE;
				model_name = g_strdup (prop->value);
			}
			
			// Find the Refdes and replace by their real value
			temp = prop->name;
			if (!g_ascii_strcasecmp (temp,  "Refdes")) temp = _("Designation");
			if (!g_ascii_strcasecmp (temp,  "Template")) temp  = _("Template");
			if (!g_ascii_strcasecmp (temp,  "Res")) temp  = _("Resistor");
			if (!g_ascii_strcasecmp (temp,  "Cap")) temp  = _("Capacitor");
			if (!g_ascii_strcasecmp (temp,  "Ind")) temp  = _("Inductor");
			label = gtk_label_new (temp);

			entry = gtk_entry_new ();
			gtk_entry_set_text (GTK_ENTRY (entry),  prop->value);
			g_object_set_data (G_OBJECT (entry),  "user",  g_strdup (prop->name));

			gtk_grid_attach (prop_grid, label, 0,y, 1,1);
			
			gtk_grid_attach (prop_grid, entry, 1,y, 1,1);
			
			y++;
			gtk_widget_show (label);
			gtk_widget_show (entry);

			prop_dialog->widgets = g_list_prepend (prop_dialog->widgets, entry);
		}
	}

	if (!has_model) {
		gtk_notebook_remove_page (notebook, 1); 
	} 
	else {
		GtkTextBuffer *txtbuffer;
		GtkTextView *txtmodel;
		gchar *filename, *str;
		GError *read_error = NULL;

		txtmodel = GTK_TEXT_VIEW (gtk_builder_get_object (gui, "txtmodel"));
		txtbuffer = gtk_text_buffer_new (NULL);

		filename = g_strdup_printf ("%s/%s.model", OREGANO_MODELDIR, model_name);
		if (g_file_get_contents (filename, &str, NULL, &read_error)) {
			gtk_text_buffer_set_text (txtbuffer, str, -1);
			g_free (str);
		} 
		else {
			gtk_text_buffer_set_text (txtbuffer, read_error->message, -1);
			g_error_free (read_error);
		}

		g_free (filename);
		g_free (model_name);

		gtk_text_view_set_buffer (txtmodel, txtbuffer);
	}

	gtk_dialog_set_default_response (prop_dialog->dialog, 1);

	response = gtk_dialog_run (prop_dialog->dialog);

	prop_dialog_response (GTK_WIDGET (prop_dialog->dialog), response, prop_dialog);

	g_slist_free_full (properties, g_object_unref);
	gtk_widget_destroy (GTK_WIDGET (prop_dialog->dialog));
}
开发者ID:rodolforg,项目名称:oregano,代码行数:101,代码来源:part-item.c

示例11: program_init

void program_init(void)
{
	GtkWidget *widget;
	StashGroup *group = stash_group_new("program");
	extern gboolean thread_select_on_running;
	extern gboolean thread_select_on_stopped;
	extern gboolean thread_select_on_exited;
	extern gboolean thread_select_follow;

	program_dialog = dialog_connect("program_dialog");
	program_page_vbox = get_widget("program_page_vbox");

	program_exec_entry = GTK_ENTRY(get_widget("program_executable_entry"));
	gtk_entry_set_max_length(program_exec_entry, PATH_MAX);
	stash_group_add_entry(group, &program_executable, "executable", "", program_exec_entry);
	ui_setup_open_button_callback(get_widget("program_executable_button"), NULL,
		GTK_FILE_CHOOSER_ACTION_OPEN, program_exec_entry);

	stash_group_add_entry(group, &program_arguments, "arguments", "",
		get_widget("program_arguments_entry"));
	widget = get_widget("program_environment");
	environment = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
	stash_group_add_string(group, &program_environment, "environment", "");

	working_dir_entry = GTK_ENTRY(get_widget("program_working_dir_entry"));
	gtk_entry_set_max_length(working_dir_entry, PATH_MAX);
	stash_group_add_entry(group, &program_working_dir, "working_dir", "", working_dir_entry);
	ui_setup_open_button_callback(get_widget("program_working_dir_button"), NULL,
		GTK_FILE_CHOOSER_ACTION_OPEN, working_dir_entry);

	load_script_entry = GTK_ENTRY(get_widget("program_load_script_entry"));
	gtk_entry_set_max_length(load_script_entry, PATH_MAX);
	stash_group_add_entry(group, &program_load_script, "load_script", "", load_script_entry);
	ui_setup_open_button_callback(get_widget("program_load_script_button"), NULL,
		GTK_FILE_CHOOSER_ACTION_OPEN, load_script_entry);

	auto_run_exit = get_widget("program_auto_run_exit");
	stash_group_add_toggle_button(group, &program_auto_run_exit, "auto_run_exit", TRUE,
		auto_run_exit);
	stash_group_add_toggle_button(group, &program_non_stop_mode, "non_stop_mode", FALSE,
		get_widget("program_non_stop_mode"));

	temp_breakpoint = get_widget("program_temp_breakpoint");
	stash_group_add_toggle_button(group, &program_temp_breakpoint, "temp_breakpoint", FALSE,
		temp_breakpoint);
	widget = get_widget("program_temp_break_location");
	gtk_entry_set_max_length(GTK_ENTRY(widget), PATH_MAX + 0xFF);
	stash_group_add_entry(group, &program_temp_break_location, "temp_break_location", "",
		widget);
	program_group = group;
	delete_all_items = GTK_TOGGLE_BUTTON(get_widget("program_delete_all_items"));

	g_signal_connect(program_exec_entry, "changed",
		G_CALLBACK(on_program_name_entry_changed), NULL);
	g_signal_connect(load_script_entry, "changed",
		G_CALLBACK(on_program_name_entry_changed), NULL);
	g_signal_connect(temp_breakpoint, "toggled", G_CALLBACK(on_temp_breakpoint_toggled),
		widget);

	import_button = get_widget("program_import");
	g_signal_connect(import_button, "clicked", G_CALLBACK(on_program_import_button_clicked),
		NULL);

	widget = get_widget("program_ok");
	g_signal_connect(widget, "clicked", G_CALLBACK(on_program_ok_button_clicked), NULL);
	gtk_widget_grab_default(widget);

	group = stash_group_new("options");

	stash_group_add_toggle_button(group, &option_open_panel_on_load, "open_panel_on_load",
		TRUE, get_widget("option_open_panel_on_load"));
	stash_group_add_toggle_button(group, &option_open_panel_on_start, "open_panel_on_start",
		TRUE, get_widget("option_open_panel_on_start"));
	stash_group_add_toggle_button(group, &option_update_all_views, "update_all_views", FALSE,
		get_widget("option_update_all_views"));

	stash_group_add_radio_buttons(group, &option_high_bit_mode, "high_bit_mode", HB_7BIT,
		get_widget("option_high_bit_mode_7bit"), HB_7BIT,
		get_widget("option_high_bit_mode_locale"), HB_LOCALE,
		get_widget("option_high_bit_mode_utf8"), HB_UTF8, NULL);

	stash_group_add_toggle_button(group, &option_member_names, "member_names", TRUE,
		get_widget("option_member_names"));
	stash_group_add_toggle_button(group, &option_argument_names, "argument_names", TRUE,
		get_widget("option_argument_names"));
	long_mr_format = GTK_BUTTON(get_widget("option_mr_long_mr_format"));
	stash_group_add_boolean(group, &option_long_mr_format, "long_mr_format", TRUE);
	LONG_MR_FORMAT[FALSE] = _("as _Name=value");
	LONG_MR_FORMAT[TRUE] = _("as _Name = value");
	g_signal_connect(long_mr_format, "clicked", G_CALLBACK(on_long_mr_format_clicked), NULL);

	stash_group_add_toggle_button(group, &option_inspect_expand, "inspect_expand", TRUE,
		get_widget("option_inspect_expand"));
	stash_group_add_spin_button_integer(group, &option_inspect_count, "inspect_count", 100,
		get_widget("option_inspect_count"));

	stash_group_add_toggle_button(group, &option_library_messages, "library_messages", FALSE,
		get_widget("option_library_messages"));
	stash_group_add_toggle_button(group, &option_editor_tooltips, "editor_tooltips", TRUE,
		get_widget("option_editor_tooltips"));
//.........这里部分代码省略.........
开发者ID:JJ77,项目名称:geany-plugins,代码行数:101,代码来源:program.c

示例12: gail_text_util_get_text


//.........这里部分代码省略.........
            gtk_text_iter_backward_sentence_start (&start);
          while (!gtk_text_iter_ends_sentence (&start))
            {
              if (!gtk_text_iter_backward_char (&start))
                break;
            }
          end = start;
          gtk_text_iter_backward_sentence_start (&start);
          while (!gtk_text_iter_ends_sentence (&start))
            {
              if (!gtk_text_iter_backward_char (&start))
                break;
            }
          break;
        case ATK_TEXT_BOUNDARY_LINE_START:
          if (layout == NULL)
            {
              line_number = gtk_text_iter_get_line (&start);
              if (line_number == 0)
                {
                  gtk_text_buffer_get_iter_at_offset (buffer,
                    &start, 0);
                }
              else
                {
                  gtk_text_iter_backward_line (&start);
                  gtk_text_iter_forward_line (&start);
                }
              end = start;
              gtk_text_iter_backward_line (&start);
            }
          else if GTK_IS_TEXT_VIEW (layout)
            {
              GtkTextView *view = GTK_TEXT_VIEW (layout);

              gtk_text_view_backward_display_line_start (view, &start);
              end = start;
              gtk_text_view_backward_display_line (view, &start);
            }
          else if (PANGO_IS_LAYOUT (layout))
            get_pango_text_offsets (PANGO_LAYOUT (layout),
                                    buffer,
                                    function,
                                    boundary_type,
                                    offset,
                                    start_offset,
                                    end_offset,
                                    &start,
                                    &end);
          break;
        case ATK_TEXT_BOUNDARY_LINE_END:
          if (layout == NULL)
            {
              line_number = gtk_text_iter_get_line (&start);
              if (line_number == 0)
                {
                  gtk_text_buffer_get_iter_at_offset (buffer,
                    &start, 0);
                  end = start;
                }
              else
                {
                  gtk_text_iter_backward_line (&start);
                  end = start;
                  while (!gtk_text_iter_ends_line (&start))
                    {
开发者ID:batman52,项目名称:dingux-code,代码行数:67,代码来源:gailtextutil.c

示例13: hybrid_chat_textview_append

void
hybrid_chat_textview_append(GtkWidget *textview, HybridAccount *account,
							HybridBuddy *buddy,	const gchar *message, time_t msg_time)
{
	GtkTextBuffer *recv_tb;
	GtkTextIter end_iter;
	GtkTextIter stop_iter;
	GtkTextIter start_iter;
	GtkTextMark *mark;
	gchar *names;
	const gchar *color;
	const gchar *name;
	struct tm *tm_time;
	gchar time[128];

	g_return_if_fail(textview != NULL);
	g_return_if_fail(message != NULL);

	tm_time = localtime(&msg_time);
	strftime(time, sizeof(time) - 1, _("%H:%M:%S"), tm_time);

	recv_tb  = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
	gtk_text_buffer_get_end_iter(recv_tb, &end_iter);

	gtk_text_view_backward_display_line(GTK_TEXT_VIEW(textview), &end_iter);

	gtk_text_buffer_get_end_iter(recv_tb, &stop_iter);
	gtk_text_buffer_get_start_iter(recv_tb, &start_iter);

	/* first line */
	if (gtk_text_iter_equal(&end_iter, &stop_iter)) {
		gtk_text_buffer_delete(recv_tb, &start_iter, &stop_iter);

	} else {
		gtk_text_buffer_delete(recv_tb, &end_iter, &stop_iter);

		if (!gtk_text_iter_equal(&start_iter, &end_iter)) {
			gtk_text_buffer_insert(recv_tb, &end_iter, "\n", -1);
		}
	}

	gtk_text_buffer_get_end_iter(recv_tb, &end_iter);

	if (!buddy) {
		color = "blue";
		name = account->nickname && *account->nickname ?
				account->nickname : account->username;

	} else {
		color = "green";
		name = buddy->name && *buddy->name ? buddy->name : buddy->id;
	}

	names = g_strdup_printf(" (%s) ", time);

	gtk_text_buffer_insert_with_tags_by_name(recv_tb, &end_iter, 
					names, strlen(names), color, "wrap", NULL);
	g_free(names);

	gtk_text_buffer_insert_with_tags_by_name(recv_tb, &end_iter, 
					name, strlen(name), color, "bold", "wrap", NULL);

	names = _(" said:");

	gtk_text_buffer_insert_with_tags_by_name(recv_tb, &end_iter, 
					names, strlen(names), color, "wrap", NULL);

	gtk_text_buffer_insert(recv_tb, &end_iter, "\n", -1);
	
	gtk_text_buffer_insert_with_tags_by_name(recv_tb, &end_iter, 
					message, strlen(message), "lm10", "wrap", NULL);

	gtk_text_buffer_insert(recv_tb, &end_iter, "\n", -1);
	gtk_text_iter_set_line_offset(&end_iter, 0);

	mark = gtk_text_buffer_get_mark(recv_tb, "scroll");
	gtk_text_buffer_move_mark(recv_tb, mark, &end_iter);
	gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(textview), mark);
}
开发者ID:chenyukang,项目名称:hybrid,代码行数:79,代码来源:chat-textview.c

示例14: main

int main(int argc, char **argv)
{
  init_TableDir();
  set_is_chs();
  b_pinyin = is_pinyin_kbm();

  gtk_init (&argc, &argv);
  load_setttings();
  load_gtab_list(TRUE);


#if HIME_i18n_message
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
  textdomain(GETTEXT_PACKAGE);
#endif

  pinmd = &inmd[default_input_method];

  if (pinmd->method_type == method_type_TSIN) {
    dbg("is tsin\n");
    pho_load();
    load_tsin_db();
    ph_key_sz = 2;
  } else
  if (pinmd->filename) {
    dbg("gtab filename %s\n", pinmd->filename);
    init_gtab(default_input_method);
    is_gtab = TRUE;
    init_tsin_table_fname(pinmd, gtab_tsin_fname);
    load_tsin_db0(gtab_tsin_fname, TRUE);
  } else
    p_err("Your default input method %s doesn't use phrase database",
      pinmd->cname);

  dbg("ph_key_sz: %d\n", ph_key_sz);

  dpy = GDK_DISPLAY();

  mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_has_resize_grip(GTK_WINDOW(mainwin), FALSE);
  gtk_window_set_default_size(GTK_WINDOW (mainwin), 640, 520);
  set_window_hime_icon(mainwin);

  GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  GtkWidget *vbox_top = gtk_vbox_new (FALSE, 0);
  gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_top), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER(mainwin), vbox_top);

  GtkWidget *view = gtk_text_view_new ();
  gtk_widget_set_hexpand (view, TRUE);
  gtk_widget_set_vexpand (view, TRUE);
  gtk_container_add (GTK_CONTAINER(sw), view);

  gtk_box_pack_start (GTK_BOX (vbox_top), sw, TRUE, TRUE, 0);

  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));

  char *text = _("按滑鼠中鍵, 貼上你要 hime-tslearn 學習的文章。");

  gtk_text_buffer_set_text (buffer, text, -1);

  gtk_text_buffer_create_tag (buffer,
     "blue_background", "background", "blue", "foreground", "white", NULL);

  gtk_text_buffer_create_tag (buffer, "char_wrap",
			      "wrap_mode", GTK_WRAP_CHAR, NULL);

  hbox_buttons = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox_top), hbox_buttons, FALSE, FALSE, 0);

  GtkWidget *button_parse = gtk_button_new_with_label(_("標示已知詞"));
  gtk_box_pack_start (GTK_BOX (hbox_buttons), button_parse, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button_parse), "clicked",
     G_CALLBACK (cb_button_parse), NULL);

  GtkWidget *button_add = gtk_button_new_with_label(_("新增詞"));
  gtk_box_pack_start (GTK_BOX (hbox_buttons), button_add, TRUE, TRUE, 0);
  g_signal_connect (G_OBJECT (button_add), "clicked",
     G_CALLBACK (cb_button_add), NULL);


  GtkWidget *button_quit = gtk_button_new_from_stock (GTK_STOCK_QUIT);
  gtk_box_pack_start (GTK_BOX (hbox_buttons), button_quit, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button_quit), "clicked",
     G_CALLBACK (do_exit), NULL);


  g_signal_connect (G_OBJECT (mainwin), "delete_event",
                    G_CALLBACK (do_exit), NULL);

  all_wrap();

  gtk_widget_show_all(mainwin);

  gtk_main();
  return 0;
//.........这里部分代码省略.........
开发者ID:Tetralet,项目名称:hime,代码行数:101,代码来源:hime-tslearn.c

示例15: sndstretch_about

void sndstretch_about(void)
{
	GtkWidget * vbox, * scrolltext, * button;
	GtkWidget * titlelabel, * copylabel;
	GtkWidget * text;
	GtkTextBuffer * textbuffer;
	GtkTextIter iter;
	GtkWidget * copyhbox, * copy_rbox, * copy_lbox;


	if (sndstretch_about_dialog != NULL)
		return;

	sndstretch_about_dialog = gtk_dialog_new();
	gtk_widget_show(sndstretch_about_dialog);

	GtkWidget * logo = gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_xpm_data
	 ((const gchar * *) sndstretch_xmms_logo_xpm));
	GtkWidget * FBlogo = gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_xpm_data
	 ((const gchar * *) FB_logo_xpm));

	g_signal_connect (sndstretch_about_dialog, "destroy", (GCallback)
	 sndstretch_about_destroy_cb, NULL);
	gtk_window_set_title(GTK_WINDOW(sndstretch_about_dialog), _("About SndStretch"));


	/* labels */
	titlelabel = gtk_label_new(sndstretch_title_text);
	copylabel  = gtk_label_new(sndstretch_about_text);
	gtk_label_set_justify(GTK_LABEL(copylabel), GTK_JUSTIFY_LEFT);

	copy_lbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
	copy_rbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
	gtk_box_pack_end  (GTK_BOX(copy_lbox), FBlogo,    FALSE, TRUE,  0);
	gtk_box_pack_start(GTK_BOX(copy_rbox), copylabel, FALSE, TRUE,  0);
	copyhbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
	gtk_box_pack_start(GTK_BOX(copyhbox), copy_lbox,    TRUE, TRUE,  5);
	gtk_box_pack_start(GTK_BOX(copyhbox), copy_rbox,    TRUE, TRUE,  5);

	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
	gtk_box_pack_start ((GtkBox *) gtk_dialog_get_content_area ((GtkDialog *)
	 sndstretch_about_dialog), vbox, TRUE, TRUE, 5);

	scrolltext = gtk_scrolled_window_new(NULL,NULL);
	text = gtk_text_view_new();
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
	textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
	gtk_text_buffer_get_iter_at_offset(textbuffer, &iter, 0);
	gtk_text_buffer_insert(textbuffer, &iter,
						   sndstretch_GPL_text, strlen(sndstretch_GPL_text));


	scrolltext = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolltext),
								   GTK_POLICY_AUTOMATIC,
								   GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrolltext), text);

	gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, TRUE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), titlelabel, FALSE, TRUE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), copyhbox, FALSE, TRUE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), scrolltext, TRUE, TRUE, 5);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);

	button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
	gtk_box_pack_start ((GtkBox *) gtk_dialog_get_action_area ((GtkDialog *)
	 sndstretch_about_dialog), button, FALSE, FALSE, 0);
	g_signal_connect (button, "clicked", (GCallback) sndstretch_about_ok_cb,
	 NULL);
	gtk_widget_set_can_default (button, TRUE);
	gtk_widget_grab_default(button);
	gtk_widget_show(button);
	gtk_widget_show_all(sndstretch_about_dialog);
}
开发者ID:ivan-dives,项目名称:audacious-plugins,代码行数:75,代码来源:sndstretch_xmms.c


注:本文中的GTK_TEXT_VIEW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。