⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.c

📁 添加系统调用。。。在LINUX下添加一个新的系统调用。在文件中添加自己的系统调用的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
                gtk_widget_show(blocks_combo);                gtk_widget_show(train_label_frame);        } else {                cell_widget_clear();                gtk_widget_hide(blocks_combo);                gtk_widget_hide(train_label_frame);                gtk_widget_show(clear_button);                gtk_widget_show(keys_button);                gtk_widget_show(insert_button);                gtk_widget_show(buffer_button);        }}static void keys_button_toggled(void){        keys_on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(keys_button));        /* Hide widgets first */        if (keys_on) {                gtk_widget_hide(cell_widget);                gtk_widget_set_sensitive(clear_button, FALSE);                gtk_widget_set_sensitive(insert_button, FALSE);                gtk_widget_set_sensitive(train_button, FALSE);                gtk_widget_set_sensitive(buffer_button, FALSE);        } else {                gtk_widget_hide(key_widget->drawing_area);                gtk_widget_set_sensitive(clear_button, TRUE);                gtk_widget_set_sensitive(insert_button, TRUE);                gtk_widget_set_sensitive(train_button, TRUE);                if (history_valid)                        gtk_widget_set_sensitive(buffer_button, TRUE);        }        /* Resize the window */        docked_move_resize();        /* Show widgets */        if (keys_on)                gtk_widget_show(key_widget->drawing_area);        else                gtk_widget_show(cell_widget);}static int block_combo_to_unicode(int block)/* Find the Combo Box index's unicode block */{        int i, pos;        for (i = 0, pos = 0; unicode_blocks[i].name; i++)                if (unicode_blocks[i].enabled && ++pos > block)                        break;        return i;}static int block_unicode_to_combo(int block)/* Find the Unicode block's combo box position */{        int i, pos;        for (i = 0, pos = 0; i < block && unicode_blocks[i].name; i++)                if (unicode_blocks[i].enabled)                        pos++;        return pos;}static void blocks_combo_changed(void){        int pos;        pos = gtk_combo_box_get_active(GTK_COMBO_BOX(blocks_combo));        training_block = block_combo_to_unicode(pos);        if (training)                cell_widget_train();}static GtkWidget *create_blocks_combo(void){        GtkWidget *event_box;        UnicodeBlock *block;        if (blocks_combo)                gtk_widget_destroy(blocks_combo);        blocks_combo = gtk_combo_box_new_text();        block = unicode_blocks;        while (block->name) {                if (block->enabled)                        gtk_combo_box_append_text(GTK_COMBO_BOX(blocks_combo),                                                  block->name);                block++;        }        gtk_combo_box_set_active(GTK_COMBO_BOX(blocks_combo),                                 block_unicode_to_combo(training_block));        gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(blocks_combo), FALSE);        g_signal_connect(G_OBJECT(blocks_combo), "changed",                         G_CALLBACK(blocks_combo_changed), NULL);        /* Wrap ComboBox in an EventBox for tooltips */        event_box = gtk_event_box_new();        gtk_tooltips_set_tip(tooltips, event_box,                             "Select Unicode block to train", NULL);        gtk_container_add(GTK_CONTAINER(event_box), blocks_combo);        return event_box;}void window_toggle(void){        if (GTK_WIDGET_VISIBLE(window)) {                gtk_widget_hide(window);                window_shown = FALSE;                /* User may have rendered themselves unable to interact with                   the program widgets by pressing one of the modifier keys                   that, for instance, puts the WM in move-window mode, so                   if the window is closed we need to reset the held keys */                key_widget_cleanup(key_widget);        } else {                gtk_widget_show(window);                window_shown = TRUE;        }}void window_show(void){        if (!(GTK_WIDGET_VISIBLE(window)))                window_toggle();}void window_hide(void){        if (GTK_WIDGET_VISIBLE(window))                window_toggle();}gboolean window_close(void){        if (status_icon_embedded()) {                gtk_widget_hide(window);                window_shown = FALSE;                key_widget_cleanup(key_widget);                return TRUE;        }        return FALSE;}static void window_style_set(GtkWidget *w){        GdkColor train_label_bg = RGB_TO_GDKCOLOR(255, 255, 200),                 train_label_fg = RGB_TO_GDKCOLOR(0, 0, 0);        /* The training label color is taken from tooltips */        if (!train_label)                return;#if GTK_CHECK_VERSION(2, 10, 0)        gtk_style_lookup_color(w->style, "tooltip_bg_color", &train_label_bg);        gtk_style_lookup_color(w->style, "tooltip_fg_color", &train_label_fg);#endif        gtk_widget_modify_bg(train_label_frame, GTK_STATE_NORMAL,                             &train_label_bg);        gtk_widget_modify_bg(train_label_box, GTK_STATE_NORMAL,                             &train_label_bg);        gtk_widget_modify_fg(train_label, GTK_STATE_NORMAL,                             &train_label_fg);        gtk_widget_modify_fg(blocks_combo, GTK_STATE_NORMAL,                             &train_label_fg);}static void button_set_image_xpm(GtkWidget *button, char **xpm)/* Creates a button with an XPM icon */{        GdkPixmap *pixmap;        GdkBitmap *mask;        GtkWidget *image;        pixmap = gdk_pixmap_colormap_create_from_xpm_d                 (NULL, gdk_colormap_get_system(), &mask, NULL, xpm);        image = gtk_image_new_from_pixmap(pixmap, mask);        g_object_unref(pixmap);        gtk_button_set_image(GTK_BUTTON(button), image);}static void insert_button_clicked(void){        if (cell_widget_insert()) {                history_valid = TRUE;                gtk_widget_set_sensitive(buffer_button, TRUE);        }}static void buffer_button_pressed(void){        if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(buffer_button))) {                cell_widget_show_buffer(buffer_button);                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(buffer_button),                                             TRUE);        }}static void print_window_xid(GtkWidget *widget){        g_print("%d\n", (unsigned int)GDK_WINDOW_XID(widget->window));}void window_create(void)/* Create the main window and child widgets */{        GtkWidget *widget, *window_vbox, *image;        GdkScreen *screen;        /* Create the window or plug */        window = !window_embedded ? gtk_window_new(GTK_WINDOW_TOPLEVEL) :                                    gtk_plug_new(0);        g_signal_connect(G_OBJECT(window), "delete-event",                         G_CALLBACK(window_close), NULL);        g_signal_connect(G_OBJECT(window), "destroy",                         G_CALLBACK(gtk_main_quit), NULL);        g_signal_connect(G_OBJECT(window), "style-set",                         G_CALLBACK(window_style_set), NULL);        g_signal_connect(G_OBJECT(window), "configure-event",                         G_CALLBACK(window_configure), NULL);        gtk_window_set_accept_focus(GTK_WINDOW(window), FALSE);        gtk_window_set_resizable(GTK_WINDOW(window), FALSE);        /* This hint was alleged to fix the strut problems with metacity but           doesn't and only causes the window to overlap the docked panels */        /*gtk_window_set_type_hint(GTK_WINDOW(window),                                 GDK_WINDOW_TYPE_HINT_DOCK);*/        /* Tooltips */        tooltips = gtk_tooltips_new();        gtk_tooltips_enable(tooltips);        /* Root box */        window_vbox = gtk_vbox_new(FALSE, 0);        gtk_widget_show(window_vbox);        /* Training info label frame */        train_label_frame = gtk_frame_new(NULL);        gtk_widget_set_no_show_all(train_label_frame, TRUE);        gtk_frame_set_shadow_type(GTK_FRAME(train_label_frame), GTK_SHADOW_IN);        gtk_container_set_border_width(GTK_CONTAINER(train_label_frame), 2);        /* Training info label */        train_label = gtk_label_new(NULL);        gtk_label_set_line_wrap(GTK_LABEL(train_label), TRUE);        gtk_label_set_justify(GTK_LABEL(train_label), GTK_JUSTIFY_FILL);        gtk_label_set_markup(GTK_LABEL(train_label),                             "<b>Training Mode:</b> Carefully draw each "                             "character in its cell. Multiple "                             "samples will be stored for each character. "                             "If you make a mistake, reset by "                             "pressing on the cell with the pen eraser.");        gtk_widget_show(train_label);        /* Training info label colored box */        train_label_box = gtk_event_box_new();        gtk_widget_show(train_label_box);        gtk_container_add(GTK_CONTAINER(train_label_box), train_label);        gtk_container_add(GTK_CONTAINER(train_label_frame), train_label_box);        gtk_widget_show_all(train_label_frame);        gtk_box_pack_start(GTK_BOX(window_vbox), train_label_frame,                           FALSE, FALSE, 0);        /* Cell widget */        cell_widget = cell_widget_new();        gtk_box_pack_start(GTK_BOX(window_vbox), cell_widget, TRUE, TRUE, 2);        if (!keyboard_only)                gtk_widget_show_all(cell_widget);        /* Key widget */        key_widget = key_widget_new_full();        gtk_box_pack_start(GTK_BOX(window_vbox), key_widget->drawing_area,                           TRUE, TRUE, 2);        if (keyboard_only) {                gtk_widget_show(key_widget->drawing_area);                keys_on = TRUE;        }        /* Bottom box */        bottom_box = gtk_hbox_new(FALSE, 0);        /* Train button */        train_button = gtk_toggle_button_new_with_label("Train");        gtk_button_set_focus_on_click(GTK_BUTTON(train_button), FALSE);        gtk_button_set_image(GTK_BUTTON(train_button),                             gtk_image_new_from_stock(GTK_STOCK_MEDIA_RECORD,                                                      GTK_ICON_SIZE_BUTTON));        gtk_button_set_relief(GTK_BUTTON(train_button), GTK_RELIEF_NONE);        gtk_box_pack_start(GTK_BOX(bottom_box), train_button, FALSE, FALSE, 0);        g_signal_connect(G_OBJECT(train_button), "toggled",                         G_CALLBACK(train_button_toggled), 0);        gtk_tooltips_set_tip(tooltips, train_button, "Toggle training mode",                             NULL);        /* Setup button */        setup_button = gtk_button_new_with_label("Setup");        gtk_button_set_focus_on_click(GTK_BUTTON(setup_button), FALSE);        gtk_button_set_image(GTK_BUTTON(setup_button),                             gtk_image_new_from_stock(GTK_STOCK_PREFERENCES,                                                      GTK_ICON_SIZE_BUTTON));        gtk_button_set_relief(GTK_BUTTON(setup_button), GTK_RELIEF_NONE);        gtk_box_pack_start(GTK_BOX(bottom_box), setup_button, FALSE, FALSE, 0);        g_signal_connect(G_OBJECT(setup_button), "clicked",                         G_CALLBACK(options_dialog_open), 0);        gtk_tooltips_set_tip(tooltips, setup_button, "Edit program options",                             NULL);        /* Expanding box to keep things tidy */        widget = gtk_vbox_new(FALSE, 0);        gtk_box_pack_start(GTK_BOX(bottom_box), widget, TRUE, FALSE, 0);        /* Training Unicode Block selector */        widget = create_blocks_combo();        gtk_box_pack_start(GTK_BOX(bottom_box), widget, FALSE, FALSE, 0);        gtk_widget_set_no_show_all(blocks_combo, TRUE);        /* Clear button */        clear_button = gtk_button_new_with_label("Clear");        gtk_button_set_focus_on_click(GTK_BUTTON(clear_button), FALSE);        image = gtk_image_new_from_stock(GTK_STOCK_CLEAR, GTK_ICON_SIZE_BUTTON);        gtk_button_set_image(GTK_BUTTON(clear_button), image);        gtk_button_set_relief(GTK_BUTTON(clear_button), GTK_RELIEF_NONE);        gtk_box_pack_start(GTK_BOX(bottom_box), clear_button, FALSE, FALSE, 0);        g_signal_connect(G_OBJECT(clear_button), "clicked",                         G_CALLBACK(cell_widget_clear), 0);        gtk_tooltips_set_tip(tooltips, clear_button, "Clear current input",                             NULL);        /* Keys button */        keys_button = gtk_toggle_button_new_with_label("Keys");        gtk_button_set_focus_on_click(GTK_BUTTON(keys_button), FALSE);        image = gtk_image_new_from_icon_name("keyboard", GTK_ICON_SIZE_BUTTON);        gtk_button_set_image(GTK_BUTTON(keys_button), image);        gtk_button_set_relief(GTK_BUTTON(keys_button), GTK_RELIEF_NONE);        gtk_box_pack_start(GTK_BOX(bottom_box), keys_button, FALSE, FALSE, 0);        g_signal_connect(G_OBJECT(keys_button), "toggled",                         G_CALLBACK(keys_button_toggled), 0);        gtk_tooltips_set_tip(tooltips, keys_button,                             "Switch between on-screen keyboard and "                             "handwriting input", NULL);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -