gchar *get_help_message_key_binding(gboolean convert_to_html) { #ifdef DETAIL g_debug("! Launch get_help_message_key_binding() with convert_to_html = %d!", convert_to_html); #endif gchar *msg_head = _("Default key binding:"); // TRANSLATE NOTE: Please be care of the spacing when translating the following key binding description. // TRANSLATE NOTE: Please check it in [Right Click Menu] -> [Usage] -> [Key binding] page after translating. gchar *disable_key_binding = _(" * <Ctrl><`> Disable/Enable hyperlinks, function keys and menu."); GString *message = g_string_new(NULL); g_string_append(message, _(" * <Ctrl><T> Add a New tab with current directory.\n")); g_string_append(message, _(" * <Ctrl><PgUp/PgDn> Switch to Prev/Next tab.\n")); g_string_append(message, _(" * <Ctrl><Home/End> Switch to First/Last tab.\n")); g_string_append(message, _(" * <Ctrl><[/]> Move current tab Forward/Backward.\n")); g_string_append(message, _(" * <Ctrl><Up/Down> Move current tab to First/Last.\n")); g_string_append(message, _(" * <Ctrl><F1~F12> Switch to 1st ~ 12th tab.\n")); g_string_append(message, _(" * <Ctrl><+/-/Enter> Increase/Decrease/Reset the font size of current tab.\n")); g_string_append(message, _(" * <Shift><Left/Right> Emulate a mouse Scroll Up/Down event on terminal.\n")); g_string_append(message, _(" * <Shift><Up/Down> Asks to Scroll Up/Down 1 line on terminal.\n")); g_string_append(message, _(" * <Shift><PgUp/PgDn> Gtk+ default behavior, Scroll Up/Down on terminal.\n")); g_string_append(message, _(" * <Shift><Home/End> Gtk+ default behavior, Scroll terminal to Top/Bottom.\n")); g_string_append(message, _(" * <Alt><F11/Enter> Switch between full/unfullwindow and full/unfullscreen.\n")); g_string_append(message, _(" * <Ctrl><F> Find text in the terminal.\n" " Use <F3>/<Shift><F3> to find Next/Prev.\n")); g_string_append(message, _(" * <Ctrl><O> Select all the text in the terminal.\n")); g_string_append(message, _(" * <Ctrl><Del/Ins> Copy/Paste the text in clipboard.\n")); g_string_append(message, _(" * <Shift><Del/Ins> Copy/Paste the text in primary clipboard.\n")); g_string_append(message, _(" (i.e. Emulate middle button mouse click to Copy/Paste)\n")); g_string_append(message,"\n"); g_string_append(message, _("Some key bindings that disabled by default but maybe useful:\n")); g_string_append(message, _(" * <Ctrl><Q> Trying to close current tab.\n")); g_string_append(message, _(" (Using <Ctrl><D> or 'exit' to close tabs is recommended)\n")); g_string_append(message, _(" * <Ctrl><N> Open a new window with current directory.\n")); g_string_append(message, _(" * <Ctrl><E> Rename the current tab.\n")); gchar *final_message = NULL; if (convert_to_html) { gchar *str[5]; str[0] = g_strdup_printf (_("TIP: These key bindings may custom or disable by right click menu [%s]."), _("Set key binding")); str[1] = convert_text_to_html(&msg_head, FALSE, NULL, "tt", NULL); str[2] = convert_text_to_html(&disable_key_binding, FALSE, "darkred", "tt", NULL); str[3] = convert_text_to_html(&(message->str), FALSE, NULL, "tt", NULL); str[4] = convert_text_to_html(&str[0], FALSE, "darkblue", "tt", "b", NULL); final_message = g_strdup_printf("%s\n%s\n%s\n%s", str[1], str[2], str[3], str[4]); gint i; for (i=0; i<5; i++) g_free(str[i]); } else final_message = g_strdup_printf("%s\n%s\n%s", msg_head, disable_key_binding, message->str); g_string_free (message, TRUE); return final_message; }
// It will be ok if profile=NULL here. gchar *get_help_message_usage(gchar *profile, gboolean convert_to_html) { #ifdef DETAIL g_debug("! Launch get_help_message_usage() with profile = %s, convert_to_html = %d!", profile, convert_to_html); #endif GString *help_message = g_string_new(NULL); // TRANSLATE NOTE: Please be care of the length of the following usage translation, // TRANSLATE NOTE: It should be shorter than 80 columns. g_string_append_printf(help_message, _("%s is a libvte based X Terminal Emulator.\n\n"), PACKAGE); g_string_append(help_message, _("Use -T/--title {title} to specify the window title.\n")); g_string_append(help_message, _("Use -R/--role {role} to specify the window role (WM_WINDOW_ROLE).\n")); g_string_append(help_message, _("Use -t/--tab {number} to open multi tabs when starting up.\n")); g_string_append(help_message, _("Use -n/--tab_names {tab names} to specify tab names, separate with <space>.\n")); g_string_append(help_message, _("Use -d/--directory {directory} to specify the init directory when starting up.\n")); g_string_append(help_message, _("Use -g/--geometry {WIDTHxHEIGHT[+-]XOFFSET[+-]YOFFSET} to specify the geometry.\n")); g_string_append(help_message, _("Use -l/-ls/--login to make the shell invoked as a login shell.\n")); g_string_append(help_message, _("Use -ut to disable recording the session in lastlog, utmp and wtmp.\n")); g_string_append(help_message, _("Use -H/--hold to hold the terminal window open when -e/-x command terminated.\n")); // g_string_append(help_message, _("\t\t\tThis option will be ignored when using with -e/-x/--execute option.\n")); g_string_append(help_message, _("Use -s/--separate to run in separate process.\n")); g_string_append(help_message, _("Use -j/--join to integrate new created tabs to the last accessed window.\n")); g_string_append(help_message, _("Use -p/--profile to get a profile sample.\n")); g_string_append_printf(help_message, _("Use -u/--user_profile {%s} to use a specified profile.\n"), PROFILE); g_string_append(help_message, _("Use -v/--version to show the version information.\n")); g_string_append(help_message, _("Use -e/-x/--execute {Command} to run a command. (Must be the final option).\n\n")); g_string_append_printf(help_message, _("The %s system configure file is: %s\n"), PACKAGE, SYS_PROFILE); gchar *current_profile = NULL; // g_debug("get_help_message_usage(): profile = %s", profile); if (profile) current_profile = g_strdup(profile); else current_profile = g_strdup_printf("%s/%s", profile_dir, USER_PROFILE); #ifdef SAFEMODE if (current_profile) { #endif if (convert_to_html) { gchar *msg_str = g_string_free(help_message, FALSE); gchar *new_help_message = convert_text_to_html (&msg_str, TRUE, NULL, "tt", NULL); #ifdef SAFEMODE if (new_help_message) #endif help_message = g_string_new(new_help_message); #ifdef SAFEMODE else help_message = g_string_new(""); #endif g_free(new_help_message); current_profile = convert_text_to_html (¤t_profile, TRUE, "darkgreen", "tt", NULL); } else { gchar *new_current_profile = g_strdup_printf("%s\n\n", current_profile); g_free(current_profile); current_profile = new_current_profile; } gchar *profile_message = g_strdup_printf(_("And your %s profile is: "), PACKAGE); #ifdef SAFEMODE if (profile_message) #endif if (convert_to_html) profile_message = convert_text_to_html(&profile_message, TRUE, NULL, "tt", NULL); // g_debug("FINAL: profile_message = %s", profile_message); #ifdef SAFEMODE if (profile_message) #endif g_string_append(help_message, profile_message); #ifdef SAFEMODE if (current_profile) #endif g_string_append(help_message, current_profile); g_free(profile_message); #ifdef SAFEMODE } #endif g_free(current_profile); return g_string_free(help_message, FALSE); }
gboolean update_page_name(GtkWidget *window, GtkWidget *vte, gchar *page_name, GtkWidget *label, gint page_no, gchar *custom_page_name, const gchar *tab_color, gboolean is_root, gboolean is_bold, gboolean show_encoding, gchar *encoding_str, gboolean custom_window_title, gboolean lost_focus) { #ifdef DETAIL g_debug("! Launch update_page_name() with vte = %p, label_name = %s, page_no = %d, " "custom_page_name = %s, tab_color = %s, is_root = %d, is_bold = %d, " "show_encoding = %d, encoding_str = %s", vte, page_name, page_no, custom_page_name, tab_color, is_root, is_bold, show_encoding, encoding_str); #endif #ifdef DEFENSIVE if (vte==NULL) return FALSE; #endif // page_name = NULL when initing a new page. if (page_name == NULL) { struct Page *page_data = (struct Page *)g_object_get_data(G_OBJECT(vte), "Page_Data"); #ifdef DEFENSIVE if (page_data==NULL) return FALSE; #endif // g_debug("page_name = NULL!! trying to call get_and_update_page_name()"); get_and_update_page_name(page_data, FALSE); } gboolean page_name_updated = FALSE; struct Window *win_data = (struct Window *)g_object_get_data(G_OBJECT(window), "Win_Data"); #ifdef DEFENSIVE if (win_data==NULL) return FALSE; #endif // We don't update label name when the size of window is changing. // 0xfe = 11,111,110 // g_debug("win_data->keep_vte_size = %x", win_data->keep_vte_size); #ifdef USE_GTK2_GEOMETRY_METHOD if (!(win_data->keep_vte_size&0xfffc)) { #endif // g_debug("Updating %d page name to %s...", page_no, page_name); gchar *label_name = NULL; if (custom_page_name==NULL) label_name = page_name; else label_name = custom_page_name; #ifdef ENABLE_SET_TOOLTIP_TEXT if (! lost_focus) gtk_widget_set_tooltip_text(label, label_name); #endif // g_debug("[1] Updating %d page name to %s...", page_no, label_name); // FIXME: label_name = NULL when initing page. if (label_name==NULL) return FALSE; if (win_data->page_shows_number) label_name = g_strdup_printf("(%d) %s", page_no, label_name); else label_name = g_strdup(label_name); // g_debug("[2] Updating %d page name to %s...", page_no, label_name); // label_name will be freed later. if (win_data->page_shows_encoding && show_encoding && encoding_str) { gchar *temp_str = g_strdup_printf("%s (%s)", label_name, encoding_str); g_free(label_name); label_name = temp_str; // g_debug("[3] Updating %d page name to %s...", page_no, label_name); } // if the window is lost focus, don't update the tab name // g_debug("lost_focus = %d", lost_focus); if (! lost_focus) { // win_data->keep_vte_size |= 1; // g_debug("window_resizable in update_page_name! and keep_vte_size =%d", keep_vte_size); // window_resizable(window, vte, 2, 1); // DANGEROUS: remark the following keep_window_size() // will break the geometry of window when drag and drop. // g_debug("update_page_name(): launch keep_window_size()!"); #ifdef USE_GTK2_GEOMETRY_METHOD # ifdef GEOMETRY g_debug("@ update_page_name(): Call keep_gtk2_window_size() with keep_vte_size = %x", win_data->keep_vte_size); # endif keep_gtk2_window_size (win_data, vte, 0x3); #endif #ifdef USE_GTK3_GEOMETRY_METHOD win_data->keep_vte_size++; #endif if (win_data->use_color_page && (tab_color != NULL)) { // g_debug("[Debug] Updating %d page name to %s...", page_no, label_name); gchar *color_label_name; if (is_bold) color_label_name = convert_text_to_html (&label_name, FALSE, (gchar *)tab_color, "b", NULL); else color_label_name = convert_text_to_html (&label_name, FALSE, (gchar *)tab_color, NULL); gtk_label_set_markup (GTK_LABEL(label), color_label_name); // g_debug("[FINAL] Updating %d page name to %s...", page_no, color_label_name); g_free(color_label_name); } else gtk_label_set_text(GTK_LABEL(label), label_name); // g_debug("Updated the tab name to %s!", page_name); page_name_updated = TRUE; } // else // g_debug("!!! the window is lost focus, don't update the tab name"); // free the data g_free(label_name); #ifdef USE_GTK2_GEOMETRY_METHOD } #endif // we should update window title if page name changed. check_and_update_window_title(win_data, custom_window_title, page_no, custom_page_name, page_name); // g_debug("(update_page_name): page_name_updated = %d", page_name_updated); return page_name_updated; }