1 /* 2 * Copyright (c) 2008-2010 Lu, Chao-Ming (Tetralet). All rights reserved. 3 * 4 * This file is part of LilyTerm. 5 * 6 * LilyTerm is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * LilyTerm is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with LilyTerm. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 21 #ifndef LILYTERM_H 22 #define LILYTERM_H 23 24 #include "data.h" 25 26 typedef gchar StrAddr; 27 typedef gchar StrLists; 28 29 // 30 // **************************** misc.c **************************** 31 // 32 33 gchar *convert_array_to_string(gchar **array, gchar separator); 34 gchar *convert_str_to_utf8(gchar *string, gchar *encoding_str); 35 gboolean compare_strings(const gchar *string_a, const gchar *string_b, gboolean case_sensitive); 36 void set_VTE_CJK_WIDTH_environ(gint VTE_CJK_WIDTH); 37 gchar *get_VTE_CJK_WIDTH_str(gint VTE_CJK_WIDTH); 38 gint get_default_VTE_CJK_WIDTH(); 39 void restore_SYSTEM_VTE_CJK_WIDTH_STR(); 40 void set_env(const gchar *variable, const gchar *value, gboolean overwrite); 41 const gchar *get_default_lc_data(gint lc_type); 42 gchar *get_encoding_from_locale(const gchar *locale); 43 gboolean check_string_in_array(gchar *str, gchar **lists); 44 gchar *get_proc_data(pid_t pid, gchar *file, gsize *length); 45 gchar **split_string(const gchar *str, const gchar *split, gint max_tokens); 46 gint count_char_in_string(const gchar *str, const gchar split); 47 gchar **get_pid_stat(pid_t pid, gint max_tokens); 48 gchar *convert_text_to_html(StrAddr **text, gboolean free_text, gchar *color, StrLists *tag, ...); 49 gchar *join_strings_to_string(const gchar separator, const gint total, const StrLists *string, ...); 50 gchar *colorful_max_new_lines(gchar *string, gint max, gint output_line); 51 gboolean dirty_gdk_color_parse(const gchar *spec, GdkColor *color); 52 #if defined(OUT_OF_MEMORY) || defined(UNIT_TEST) 53 gchar *fake_g_strdup(const gchar *gchar); 54 gchar *fake_g_strdup_printf(const StrLists *format, ...); 55 #endif 56 57 // 58 // **************************** main.c **************************** 59 // 60 61 gboolean init_socket_data(); 62 gboolean query_socket(); 63 gboolean send_socket(int argc, char *argv[], gboolean wait); 64 void main_quit(GtkWidget *widget, struct Window *win_data); 65 void quit_gtk(); 66 67 // 68 // **************************** console.c **************************** 69 // 70 71 void command_option(int argc, char *argv[]); 72 gchar *get_help_message_usage(gchar *profile, gboolean convert_to_html); 73 gchar *get_help_message_key_binding(gboolean convert_to_html); 74 75 // 76 // **************************** window.c **************************** 77 // 78 79 GtkNotebook *new_window(int argc, 80 char *argv[], 81 gchar *shell, 82 gchar *environment, 83 gchar *locale_list, 84 gchar *PWD, 85 gchar *HOME, 86 const gchar *VTE_CJK_WIDTH_STR, 87 gboolean VTE_CJK_WIDTH_STR_overwrite_profile, 88 const gchar *wmclass_name, 89 gchar *wmclass_class, 90 gchar *user_environ, 91 gchar *encoding, 92 gboolean encoding_overwrite_profile, 93 gchar *lc_messages, 94 struct Window *win_data_orig, 95 struct Page *page_data_orig); 96 gchar *get_init_dir(pid_t pid, gchar *pwd, gchar *home); 97 #if defined(USE_GTK2_GEOMETRY_METHOD) || defined(UNIT_TEST) 98 void keep_gtk2_window_size (struct Window *win_data, GtkWidget *vte, guint keep_vte_size); 99 #endif 100 #if defined(USE_GTK3_GEOMETRY_METHOD) || defined(UNIT_TEST) 101 void save_vte_geometry(struct Window *win_data); 102 void save_current_vte_geometry(struct Window *win_data, GtkWidget *vte); 103 void keep_gtk3_window_size(struct Window *win_data, GtkWidget *vte); 104 #endif 105 void dim_window(struct Window *win_data, gint dim_window); 106 void set_window_icon(GtkWidget *window); 107 gboolean window_quit(GtkWidget *window, GdkEvent *event, struct Window *win_data); 108 GString *close_multi_tabs(struct Window *win_data, int window_no); 109 gboolean display_child_process_dialog (GString *child_process_list, struct Window *win_data, gsize style); 110 GString *get_child_process_list(GtkWidget *window, gint window_no, gint page_no, GString *process_list, pid_t pid, struct Window *win_data, gboolean show_foreground); 111 void clean_process_data(); 112 gboolean deal_key_press(GtkWidget *window, gint type, struct Window *win_data); 113 #ifdef DISABLE_PAGE_ADDED 114 void notebook_page_added(GtkNotebook *notebook, GtkWidget *child, guint page_num, struct Window *win_data); 115 #endif 116 void show_close_button_on_tab(struct Window *win_data, struct Page *page_data); 117 void set_fill_tabs_bar(GtkNotebook *notebook, gboolean fill_tabs_bar, struct Page *page_data); 118 void remove_notebook_page (GtkNotebook *notebook, GtkWidget *child, guint page_num, struct Window *win_data); 119 void update_window_hint(struct Window *win_data, struct Page *page_data); 120 gboolean hide_and_show_tabs_bar(struct Window *win_data , Switch_Type show_tabs_bar); 121 void set_widget_can_not_get_focus(GtkWidget *widget); 122 gboolean hide_scrollback_lines(GtkWidget *widget, struct Window *win_data); 123 #if defined(FATAL) || defined(UNIT_TEST) 124 void print_array(gchar *name, gchar **data); 125 #endif 126 void clear_win_data(struct Window *win_data); 127 gboolean confirm_to_paste_form_clipboard(Clipboard_Type type, struct Window *win_data, struct Page *page_data); 128 gboolean show_clipboard_dialog(Clipboard_Type type, struct Window *win_data, 129 struct Page *page_data, Dialog_Type_Flags dialog_type); 130 131 void print_color(gint no, gchar *name, GdkColor color); 132 133 // 134 // **************************** profile.c **************************** 135 // 136 137 void init_page_parameters(struct Window *win_data, struct Page *page_data); 138 void init_user_color(struct Window *win_data, gchar *theme_name); 139 void init_locale_restrict_data(gchar *lc_messages); 140 GString *save_user_settings(GtkWidget *widget, struct Window *win_data); 141 gchar *get_user_profile_path(struct Window *win_data, int argc, char *argv[]); 142 void get_user_settings(struct Window *win_data, const gchar *encoding); 143 void init_prime_user_datas(struct Window *win_data); 144 void get_prime_user_settings(GKeyFile *keyfile, struct Window *win_data, gchar *encoding); 145 gboolean check_boolean_value(GKeyFile *keyfile, const gchar *group_name, const gchar *key, const gboolean default_value); 146 void check_profile_version (GKeyFile *keyfile, struct Window *win_data); 147 void profile_is_invalid_dialog(GError *error, struct Window *win_data); 148 void convert_string_to_user_key(gint i, gchar *value, struct Window *win_data); 149 gchar *get_profile(); 150 #if defined(ENABLE_RGBA) || defined(UNIT_TEST) 151 void init_rgba(struct Window *win_data); 152 #endif 153 154 // 155 // **************************** property.c **************************** 156 // 157 158 void create_theme_color_data(GdkColor color[COLOR], GdkColor color_orig[COLOR], gdouble color_brightness, gboolean invert_color, 159 gboolean default_vte_theme, gboolean dim_fg_color); 160 void adjust_ansi_color(GdkColor *color, GdkColor *color_orig, gdouble color_brightness); 161 void generate_all_color_datas(struct Window *win_data); 162 GdkColor *get_current_color_theme(struct Window *win_data); 163 void init_new_page(struct Window *win_data, struct Page *page_data, glong column, glong row); 164 void set_cursor_blink(struct Window *win_data, struct Page *page_data); 165 void set_hyprelink(struct Window *win_data, struct Page *page_data); 166 void set_vte_color(GtkWidget *vet, gboolean default_vte_color, GdkColor cursor_color, GdkColor color[COLOR], gboolean update_fg_only); 167 gboolean use_default_vte_theme(struct Window *win_data); 168 void set_page_width(struct Window *win_data, struct Page *page_data); 169 void pack_vte_and_scroll_bar_to_hbox(struct Window *win_data, struct Page *page_data); 170 void add_remove_page_timeout_id(struct Window *win_data, struct Page *page_data); 171 void add_remove_window_title_changed_signal(struct Page *page_data); 172 gboolean set_background_saturation(GtkRange *range, GtkScrollType scroll, gdouble value, GtkWidget *vte); 173 gboolean set_window_opacity (GtkRange *range, GtkScrollType scroll, gdouble value, struct Window *win_data); 174 void window_resizable(GtkWidget *window, GtkWidget *vte, gint set_hints_inc); 175 #if defined(vte_terminal_get_padding) || defined(UNIT_TEST) 176 void fake_vte_terminal_get_padding(VteTerminal *vte, gint *width, gint *height); 177 #endif 178 void apply_new_win_data_to_page (struct Window *win_data_orig, struct Window *win_data, struct Page *page_data); 179 gboolean compare_color(GdkColor *a, GdkColor *b); 180 gboolean check_show_or_hide_scroll_bar(struct Window *win_data); 181 void show_and_hide_scroll_bar(struct Page *page_data, gboolean show_scroll_bar); 182 void set_widget_thickness(GtkWidget *widget, gint thickness); 183 184 // 185 // **************************** notebook.c **************************** 186 // 187 188 struct Page *add_page(struct Window *win_data, 189 struct Page *page_data_prev, 190 GtkWidget *menuitem_encoding, 191 gchar *encoding, 192 gchar *runtime_locale_encoding, 193 gchar *locale, 194 gchar *environments, 195 gchar *user_environ, 196 const gchar *VTE_CJK_WIDTH_STR, 197 gboolean add_to_next); 198 void dim_vte_text (struct Window *win_data, struct Page *page_data, gint dim_text); 199 gboolean close_page(GtkWidget *vte, gint close_type); 200 gboolean open_url_with_external_command (gchar *url, gint tag, struct Window *win_data, struct Page *page_data); 201 struct Page *get_page_data_from_nth_page(struct Window *win_data, guint page_no); 202 203 // 204 // **************************** font.c **************************** 205 // 206 207 void set_vte_font(GtkWidget *widget, Font_Set_Type type); 208 void apply_font_to_every_vte(GtkWidget *window, gchar *new_font_name, glong column, glong row); 209 gboolean check_if_every_vte_is_using_restore_font_name (struct Window *win_data); 210 // 211 // **************************** pagename.c **************************** 212 // 213 214 void update_window_title(GtkWidget *window, gchar *name, gboolean window_title_append_package_name); 215 void init_monitor_cmdline_datas(struct Window *win_data, struct Page *page_data); 216 gboolean monitor_cmdline(struct Page *page_data); 217 void update_page_window_title (VteTerminal *vte, struct Page *page_data); 218 gchar *get_cmdline(const pid_t tpgid); 219 gboolean check_is_root(pid_t tpgid); 220 gint get_tpgid(pid_t pid); 221 void check_and_update_window_title(struct Window *win_data, gboolean custom_window_title, gint page_no, 222 gchar *custom_page_name, gchar *page_name); 223 gboolean get_and_update_page_name(struct Page *page_data, gboolean lost_focus); 224 void reorder_page_number (GtkNotebook *notebook, GtkWidget *child, guint page_num, GtkWidget *window); 225 gchar *get_tab_name_with_current_dir(pid_t pid); 226 void update_page_name_wintitle(StrAddr **page_name, 227 StrAddr **page_color, 228 struct Window *win_data, 229 struct Page *page_data); 230 void update_page_name_cmdline(StrAddr **page_name, 231 StrAddr **page_color, 232 struct Window *win_data, 233 struct Page *page_data); 234 void update_page_name_pwd(StrAddr **page_name, 235 StrAddr **page_color, 236 struct Window *win_data, 237 struct Page *page_data, 238 gboolean lost_focus); 239 gboolean update_page_name(GtkWidget *window, GtkWidget *vte, gchar *page_name, GtkWidget *label, 240 gint page_no, gchar *custom_page_name, const gchar *tab_color, gboolean is_root, 241 gboolean is_bold, gboolean show_encoding, gchar *encoding_str, 242 gboolean custom_window_title, gboolean lost_focus); 243 void update_page_name_normal(StrAddr **page_name, 244 StrAddr **page_color, 245 struct Window *win_data, 246 struct Page *page_data); 247 248 // 249 // **************************** dialog.c **************************** 250 // 251 252 GtkResponseType dialog(GtkWidget *widget, gsize style); 253 gint get_color_index(gboolean invert_color, gint index); 254 gboolean find_str_in_vte(GtkWidget *vte, Dialog_Find_Type type); 255 void set_markup_key_value(gboolean bold, gchar *color, gchar *key_value, GtkWidget *label); 256 gboolean check_and_add_locale_to_warned_locale_list(struct Window *win_data, gchar *new_locale); 257 void create_invalid_locale_error_message(gchar *locale); 258 void error_dialog(GtkWidget *window, gchar *title_translation, gchar *title, 259 gchar *icon, gchar *message, gchar *encoding); 260 #if defined(FATAL) || defined(UNIT_TEST) 261 void print_switch_out_of_range_error_dialog(gchar *function, gchar *var, gint value); 262 #endif 263 GdkColor get_inactive_color(GdkColor original_fg_color, gdouble new_brightness, gdouble old_brightness); 264 gboolean upgrade_dialog(gchar *version_str); 265 gchar *get_colorful_profile(struct Window *win_data); 266 267 // 268 // **************************** menu.c **************************** 269 // 270 271 void recreate_theme_menu_items(struct Window *win_data); 272 gboolean refresh_locale_and_encoding_list(struct Window *win_data); 273 void set_encoding(GtkWidget *menuitem, gpointer user_data); 274 gboolean create_menu(struct Window *win_data); 275 void set_urgent_bell(GtkWidget *widget, struct Window *win_data); 276 void set_vte_urgent_bell(struct Window *win_data, struct Page *page_data); 277 gboolean stop_urgency_hint(GtkWidget *window, GdkEvent *event, struct Window *win_data); 278 GtkWidget *add_radio_menuitem_to_sub_menu(GSList *encoding_group, 279 GtkWidget *sub_menu, 280 const gchar *name, 281 GSourceFunc func, 282 gpointer func_data); 283 void refresh_profile_list (struct Window *win_data); 284 long get_profile_dir_modtime(); 285 286 #if defined(FATAL) || defined(UNIT_TEST) 287 void print_active_window_is_null_error_dialog(gchar *function); 288 #endif 289 290 #endif 291