📄 xo-misc.c
字号:
else if (!ui.view_continuous) gnome_canvas_item_move(GNOME_CANVAS_ITEM(ui.cur_page->group), 0., 0.); }}void update_page_stuff(void){ gchar tmp[10]; GtkComboBox *layerbox; int i; GList *pglist; GtkSpinButton *spin; struct Page *pg; double vertpos, maxwidth; struct Layer *layer; int relscroll; // move the page groups to their rightful locations or hide them if (ui.view_continuous) { vertpos = 0.; maxwidth = 0.; for (i=0, pglist = journal.pages; pglist!=NULL; i++, pglist = pglist->next) { pg = (struct Page *)pglist->data; if (pg->group!=NULL) { pg->hoffset = 0.; pg->voffset = vertpos; gnome_canvas_item_set(GNOME_CANVAS_ITEM(pg->group), "x", pg->hoffset, "y", pg->voffset, NULL); gnome_canvas_item_show(GNOME_CANVAS_ITEM(pg->group)); } vertpos += pg->height + VIEW_CONTINUOUS_SKIP; if (pg->width > maxwidth) maxwidth = pg->width; } vertpos -= VIEW_CONTINUOUS_SKIP; gnome_canvas_set_scroll_region(canvas, 0, 0, maxwidth, vertpos); } else { for (pglist = journal.pages; pglist!=NULL; pglist = pglist->next) { pg = (struct Page *)pglist->data; if (pg == ui.cur_page && pg->group!=NULL) { pg->hoffset = 0.; pg->voffset = 0.; gnome_canvas_item_set(GNOME_CANVAS_ITEM(pg->group), "x", pg->hoffset, "y", pg->voffset, NULL); gnome_canvas_item_show(GNOME_CANVAS_ITEM(pg->group)); } else { if (pg->group!=NULL) gnome_canvas_item_hide(GNOME_CANVAS_ITEM(pg->group)); } } gnome_canvas_set_scroll_region(canvas, 0, 0, ui.cur_page->width, ui.cur_page->height); } // update the page / layer info at bottom of screen spin = GTK_SPIN_BUTTON(GET_COMPONENT("spinPageNo")); ui.in_update_page_stuff = TRUE; // avoid a bad retroaction gtk_spin_button_set_range(spin, 1, journal.npages+1); /* npages+1 will be used to create a new page at end */ gtk_spin_button_set_value(spin, ui.pageno+1); g_snprintf(tmp, 10, " of %d", journal.npages); gtk_label_set_text(GTK_LABEL(GET_COMPONENT("labelNumpages")), tmp); layerbox = GTK_COMBO_BOX(GET_COMPONENT("comboLayer")); if (ui.layerbox_length == 0) { gtk_combo_box_prepend_text(layerbox, "Background"); ui.layerbox_length++; } while (ui.layerbox_length > ui.cur_page->nlayers+1) { gtk_combo_box_remove_text(layerbox, 0); ui.layerbox_length--; } while (ui.layerbox_length < ui.cur_page->nlayers+1) { g_snprintf(tmp, 10, "Layer %d", ui.layerbox_length++); gtk_combo_box_prepend_text(layerbox, tmp); } gtk_combo_box_set_active(layerbox, ui.cur_page->nlayers-1-ui.layerno); ui.in_update_page_stuff = FALSE; // update the paper-style menu radio buttons if (ui.view_continuous) gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewContinuous")), TRUE); else gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewOnePage")), TRUE); if (ui.cur_page->bg->type == BG_SOLID && !ui.bg_apply_all_pages) { switch (ui.cur_page->bg->color_no) { case COLOR_WHITE: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorWhite")), TRUE); break; case COLOR_YELLOW: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorYellow")), TRUE); break; case COLOR_RED: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorPink")), TRUE); break; case COLOR_ORANGE: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorOrange")), TRUE); break; case COLOR_BLUE: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorBlue")), TRUE); break; case COLOR_GREEN: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorGreen")), TRUE); break; default: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorOther")), TRUE); break; } switch (ui.cur_page->bg->ruling) { case RULING_NONE: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("paperstylePlain")), TRUE); break; case RULING_LINED: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("paperstyleLined")), TRUE); break; case RULING_RULED: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("paperstyleRuled")), TRUE); break; case RULING_GRAPH: gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("paperstyleGraph")), TRUE); break; } } else { gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorNA")), TRUE); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("paperstyleNA")), TRUE); } // enable/disable the page/layer menu items and toolbar buttons gtk_widget_set_sensitive(GET_COMPONENT("journalPaperColor"), ui.cur_page->bg->type == BG_SOLID || ui.bg_apply_all_pages); gtk_widget_set_sensitive(GET_COMPONENT("journalSetAsDefault"), ui.cur_page->bg->type == BG_SOLID); gtk_widget_set_sensitive(GET_COMPONENT("viewFirstPage"), ui.pageno!=0); gtk_widget_set_sensitive(GET_COMPONENT("viewPreviousPage"), ui.pageno!=0); gtk_widget_set_sensitive(GET_COMPONENT("viewNextPage"), TRUE); gtk_widget_set_sensitive(GET_COMPONENT("viewLastPage"), ui.pageno!=journal.npages-1); gtk_widget_set_sensitive(GET_COMPONENT("buttonFirstPage"), ui.pageno!=0); gtk_widget_set_sensitive(GET_COMPONENT("buttonPreviousPage"), ui.pageno!=0); gtk_widget_set_sensitive(GET_COMPONENT("buttonNextPage"), TRUE); gtk_widget_set_sensitive(GET_COMPONENT("buttonLastPage"), ui.pageno!=journal.npages-1); gtk_widget_set_sensitive(GET_COMPONENT("viewShowLayer"), ui.layerno!=ui.cur_page->nlayers-1); gtk_widget_set_sensitive(GET_COMPONENT("viewHideLayer"), ui.layerno>=0); gtk_widget_set_sensitive(GET_COMPONENT("editPaste"), ui.cur_layer!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("buttonPaste"), ui.cur_layer!=NULL);}void update_toolbar_and_menu(void){ update_tool_buttons(); // takes care of other toolbar buttons as well update_tool_menu(); update_color_menu(); update_pen_props_menu(); update_eraser_props_menu(); update_highlighter_props_menu(); update_mappings_menu(); gtk_toggle_tool_button_set_active( GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), ui.fullscreen); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), ui.fullscreen);}void update_file_name(char *filename){ gchar tmp[100], *p; if (ui.filename != NULL) g_free(ui.filename); ui.filename = filename; if (filename == NULL) { gtk_window_set_title(GTK_WINDOW (winMain), "Xournal"); return; } p = g_utf8_strrchr(filename, -1, '/'); if (p == NULL) p = filename; else p = g_utf8_next_char(p); g_snprintf(tmp, 100, "Xournal - %s", p); gtk_window_set_title(GTK_WINDOW (winMain), tmp); new_mru_entry(filename);}void update_undo_redo_enabled(void){ gtk_widget_set_sensitive(GET_COMPONENT("editUndo"), undo!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("editRedo"), redo!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("buttonUndo"), undo!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("buttonRedo"), redo!=NULL);}void update_copy_paste_enabled(void){ gtk_widget_set_sensitive(GET_COMPONENT("editCut"), ui.selection!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("editCopy"), ui.selection!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("editPaste"), ui.cur_item_type!=ITEM_TEXT); gtk_widget_set_sensitive(GET_COMPONENT("editDelete"), ui.selection!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("buttonCut"), ui.selection!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("buttonCopy"), ui.selection!=NULL); gtk_widget_set_sensitive(GET_COMPONENT("buttonPaste"), ui.cur_item_type!=ITEM_TEXT);}void update_mapping_linkings(int toolno){ int i; for (i = 1; i<=NUM_BUTTONS; i++) { if (ui.linked_brush[i] == BRUSH_LINKED) { if (toolno >= 0 && toolno < NUM_STROKE_TOOLS) g_memmove(&(ui.brushes[i][toolno]), &(ui.brushes[0][toolno]), sizeof(struct Brush)); ui.ruler[i] = ui.ruler[0]; if (ui.toolno[i]!=TOOL_PEN && ui.toolno[i]!=TOOL_HIGHLIGHTER) ui.ruler[i] = FALSE; } if (ui.linked_brush[i] == BRUSH_COPIED && toolno == ui.toolno[i]) { ui.linked_brush[i] = BRUSH_STATIC; if (i==1 || i==2) update_mappings_menu_linkings(); } }}void set_cur_color(int color){ ui.cur_brush->color_no = color; if (ui.toolno[0] == TOOL_HIGHLIGHTER) ui.cur_brush->color_rgba = predef_colors_rgba[color] & ui.hiliter_alpha_mask; else ui.cur_brush->color_rgba = predef_colors_rgba[color]; update_mapping_linkings(ui.toolno[0]);}void recolor_temp_text(int color_no, guint color_rgba){ GdkColor gdkcolor; if (ui.cur_item_type!=ITEM_TEXT) return; if (ui.cur_item->text!=NULL && ui.cur_item->brush.color_rgba != color_rgba) { prepare_new_undo(); undo->type = ITEM_TEXT_ATTRIB; undo->item = ui.cur_item; undo->str = g_strdup(ui.cur_item->font_name); undo->val_x = ui.cur_item->font_size; undo->brush = (struct Brush *)g_memdup(&(ui.cur_item->brush), sizeof(struct Brush)); } ui.cur_item->brush.color_no = color_no; ui.cur_item->brush.color_rgba = color_rgba; rgb_to_gdkcolor(color_rgba, &gdkcolor); gtk_widget_modify_text(ui.cur_item->widget, GTK_STATE_NORMAL, &gdkcolor); gtk_widget_grab_focus(ui.cur_item->widget);}void process_color_activate(GtkMenuItem *menuitem, int color){ if (GTK_OBJECT_TYPE(menuitem) == GTK_TYPE_RADIO_MENU_ITEM) { if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; } else { if (!gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem))) return; } if (ui.cur_mapping != 0) return; // not user-generated reset_focus(); if (ui.cur_item_type == ITEM_TEXT) recolor_temp_text(color, predef_colors_rgba[color]); if (ui.selection != NULL) { recolor_selection(color); update_color_buttons(); update_color_menu(); } if (ui.toolno[0] != TOOL_PEN && ui.toolno[0] != TOOL_HIGHLIGHTER && ui.toolno[0] != TOOL_TEXT) { if (ui.selection != NULL) return; end_text(); ui.toolno[0] = TOOL_PEN; ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); update_tool_buttons(); update_tool_menu(); } set_cur_color(color); update_color_buttons(); update_color_menu(); update_cursor();}void process_thickness_activate(GtkMenuItem *menuitem, int tool, int val){ if (GTK_OBJECT_TYPE(menuitem) == GTK_TYPE_RADIO_MENU_ITEM) { if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; } else { if (!gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem))) return; } if (ui.cur_mapping != 0) return; // not user-generated if (ui.selection != NULL && GTK_OBJECT_TYPE(menuitem) != GTK_TYPE_RADIO_MENU_ITEM) { reset_focus(); rethicken_selection(val); update_thickness_buttons(); } if (tool >= NUM_STROKE_TOOLS) { update_thickness_buttons(); // undo illegal button selection return; } if (ui.brushes[0][tool].thickness_no == val) return; reset_focus(); end_text(); ui.brushes[0][tool].thickness_no = val; ui.brushes[0][tool].thickness = predef_thickness[tool][val]; update_mapping_linkings(tool); update_thickness_buttons(); if (tool == TOOL_PEN) update_pen_props_menu(); if (tool == TOOL_ERASER) update_eraser_props_menu(); if (tool == TOOL_HIGHLIGHTER) update_highlighter_props_menu(); update_cursor();}void process_papercolor_activate(GtkMenuItem *menuitem, int color){ struct Page *pg; GList *pglist; gboolean hasdone; if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; if ((ui.cur_page->bg->type != BG_SOLID) || ui.bg_apply_all_pages) gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorNA")), TRUE); pg = ui.cur_page; hasdone = FALSE; for (pglist = journal.pages; pglist!=NULL; pglist = pglist->next) { if (ui.bg_apply_all_pages) pg = (struct Page *)pglist->data; if (pg->bg->type == BG_SOLID && pg->bg->color_no != color) { prepare_new_undo(); if (hasdone) undo->multiop |= MULTIOP_CONT_UNDO; undo->multiop |= MULTIOP_CONT_REDO; hasdone = TRUE; undo->type = ITEM_NEW_BG_ONE; undo->page = pg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -