void secure_buffer_display () { int line, count, count_encrypted; if (!secure_buffer) return; gui_buffer_clear (secure_buffer); /* set title buffer */ gui_buffer_set_title (secure_buffer, _("WeeChat secured data (sec.conf) | " "Keys: [alt-v] Toggle values")); line = 0; gui_chat_printf_y (secure_buffer, line++, "Hash algo: %s Cipher: %s Salt: %s", secure_hash_algo_string[CONFIG_INTEGER(secure_config_crypt_hash_algo)], secure_cipher_string[CONFIG_INTEGER(secure_config_crypt_cipher)], (CONFIG_BOOLEAN(secure_config_crypt_salt)) ? _("on") : _("off")); /* display passphrase */ line++; gui_chat_printf_y (secure_buffer, line++, (secure_passphrase) ? _("Passphrase is set") : _("Passphrase is not set")); /* display secured data */ count = secure_hashtable_data->items_count; count_encrypted = secure_hashtable_data_encrypted->items_count; if (count > 0) { line++; gui_chat_printf_y (secure_buffer, line++, _("Secured data:")); line++; hashtable_map (secure_hashtable_data, &secure_buffer_display_data, &line); } /* display secured data not decrypted */ if (count_encrypted > 0) { line++; gui_chat_printf_y (secure_buffer, line++, _("Secured data STILL ENCRYPTED: (use /secure decrypt, " "see /help secure)")); line++; hashtable_map (secure_hashtable_data_encrypted, &secure_buffer_display_data, &line); } if ((count == 0) && (count_encrypted == 0)) { line++; gui_chat_printf_y (secure_buffer, line++, _("No secured data set")); } }
void gui_main_init () { struct t_gui_buffer *ptr_buffer; struct t_gui_bar *ptr_bar; struct t_gui_bar_window *ptr_bar_win; GdkColor color_fg, color_bg; gui_color_init (); gui_ok = 1; /* build prefixes according to config */ gui_chat_prefix_build (); /* init clipboard buffer */ gui_input_clipboard = NULL; /* create Gtk widgets */ gdk_color_parse ("white", &color_fg); gdk_color_parse ("black", &color_bg); gui_gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (gui_gtk_main_window), PACKAGE_STRING); g_signal_connect (G_OBJECT (gui_gtk_main_window), "destroy", gtk_main_quit, NULL); gui_gtk_vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_show (gui_gtk_vbox1); gtk_container_add (GTK_CONTAINER (gui_gtk_main_window), gui_gtk_vbox1); gui_gtk_entry_topic = gtk_entry_new (); gtk_widget_show (gui_gtk_entry_topic); gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_entry_topic, FALSE, FALSE, 0); gtk_widget_modify_text (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_fg); gtk_widget_modify_base (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_bg); gui_gtk_notebook1 = gtk_notebook_new (); gtk_widget_show (gui_gtk_notebook1); gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_notebook1, TRUE, TRUE, 0); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (gui_gtk_notebook1), GTK_POS_BOTTOM); gui_gtk_vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (gui_gtk_vbox2); gtk_container_add (GTK_CONTAINER (gui_gtk_notebook1), gui_gtk_vbox2); gui_gtk_hbox1 = gtk_hbox_new (FALSE, 0); gtk_widget_show (gui_gtk_hbox1); gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_hbox1, TRUE, TRUE, 0); gui_gtk_hpaned1 = gtk_hpaned_new (); gtk_widget_show (gui_gtk_hpaned1); gtk_box_pack_start (GTK_BOX (gui_gtk_hbox1), gui_gtk_hpaned1, TRUE, TRUE, 0); gtk_paned_set_position (GTK_PANED (gui_gtk_hpaned1), 0); gui_gtk_scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (gui_gtk_scrolledwindow_chat); gtk_paned_pack1 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_chat, FALSE, TRUE); //gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_chat, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gui_gtk_scrolledwindow_chat), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_widget_modify_text (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_fg); gtk_widget_modify_base (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_bg); gui_gtk_scrolledwindow_nick = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (gui_gtk_scrolledwindow_nick); gtk_paned_pack2 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_nick, FALSE, TRUE); //gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_nick, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gui_gtk_scrolledwindow_nick), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_widget_modify_text (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_fg); gtk_widget_modify_base (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_bg); gui_gtk_entry_input = gtk_entry_new (); gtk_widget_show (gui_gtk_entry_input); gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_entry_input, FALSE, FALSE, 0); gtk_widget_modify_text (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_fg); gtk_widget_modify_base (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_bg); gui_gtk_label1 = gtk_label_new (_("server")); gtk_widget_show (gui_gtk_label1); gtk_notebook_set_tab_label (GTK_NOTEBOOK (gui_gtk_notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (gui_gtk_notebook1), 0), gui_gtk_label1); gtk_label_set_justify (GTK_LABEL (gui_gtk_label1), GTK_JUSTIFY_LEFT); gtk_widget_show_all (gui_gtk_main_window); gui_init_ok = 0; /* create core buffer */ ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL); if (ptr_buffer) { gui_init_ok = 1; /* set title for core buffer */ gui_buffer_set_title (ptr_buffer, "WeeChat " WEECHAT_COPYRIGHT_DATE " - " WEECHAT_WEBSITE); /* create main window (using full space) */ if (gui_window_new (NULL, ptr_buffer, 0, 0, 0, 0, 100, 100)) { gui_current_window = gui_windows; if (CONFIG_BOOLEAN(config_look_set_title)) gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION); } /* create bar windows for root bars (they were read from config, but no window was created (GUI was not initialized) */ for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) { if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT) && (!ptr_bar->bar_window)) { gui_bar_window_new (ptr_bar, NULL); } } for (ptr_bar_win = gui_windows->bar_windows; ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window) { gui_bar_window_calculate_pos_size (ptr_bar_win, gui_windows); gui_bar_window_create_win (ptr_bar_win); } } }
void gui_main_init () { struct t_gui_buffer *ptr_buffer; struct t_gui_bar *ptr_bar; struct t_gui_bar_window *ptr_bar_win; char title[256]; initscr (); if (CONFIG_BOOLEAN(config_look_eat_newline_glitch)) gui_term_set_eat_newline_glitch (0); curs_set (1); noecho (); nodelay (stdscr, TRUE); raw (); gui_color_init (); /* build prefixes according to configuration */ gui_chat_prefix_build (); refresh (); gui_term_cols = COLS; gui_term_lines = LINES; gui_window_read_terminal_size (); /* init clipboard buffer */ gui_input_clipboard = NULL; /* get time length */ gui_chat_time_length = gui_chat_get_time_length (); /* init bar items */ gui_bar_item_init (); gui_init_ok = 0; /* create core buffer */ ptr_buffer = gui_buffer_new (NULL, GUI_BUFFER_MAIN, NULL, NULL, NULL, NULL); if (ptr_buffer) { gui_init_ok = 1; ptr_buffer->num_displayed = 1; /* set short name */ if (!ptr_buffer->short_name) ptr_buffer->short_name = strdup (GUI_BUFFER_MAIN); /* set title for core buffer */ snprintf (title, sizeof (title), "WeeChat %s %s - %s", version_get_version (), WEECHAT_COPYRIGHT_DATE, WEECHAT_WEBSITE); gui_buffer_set_title (ptr_buffer, title); /* create main window (using full space) */ if (gui_window_new (NULL, ptr_buffer, 0, 0, gui_term_cols, gui_term_lines, 100, 100)) { gui_current_window = gui_windows; if (CONFIG_STRING(config_look_window_title) && CONFIG_STRING(config_look_window_title)[0]) { gui_window_set_title (CONFIG_STRING(config_look_window_title)); } } /* * create bar windows for root bars (they were read from config, * but no window was created, GUI was not initialized) */ for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) { if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT) && (!ptr_bar->bar_window)) { gui_bar_window_new (ptr_bar, NULL); } } for (ptr_bar_win = gui_windows->bar_windows; ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window) { gui_bar_window_calculate_pos_size (ptr_bar_win, gui_windows); gui_bar_window_create_win (ptr_bar_win); } } if (CONFIG_BOOLEAN(config_look_mouse)) gui_mouse_enable (); else gui_mouse_disable (); gui_window_set_bracketed_paste_mode (CONFIG_BOOLEAN(config_look_paste_bracketed)); }
void gui_color_buffer_display () { int y, i, lines, line, col, color, max_color, num_items; char str_line[1024], str_color[64], str_rgb[64], **items; struct t_gui_color_palette *color_palette; if (!gui_color_buffer) return; gui_buffer_clear (gui_color_buffer); /* set title buffer */ gui_buffer_set_title (gui_color_buffer, _("WeeChat colors | Actions: " "[e] Display extra infos [r] Refresh " "[z] Reset colors [q] Close buffer | " "Keys: [alt-c] Temporarily switch to terminal " "colors")); /* display terminal/colors infos */ y = 0; gui_color_info_term_colors (str_line, sizeof (str_line)); gui_chat_printf_y (gui_color_buffer, y++, "%s", str_line); /* display palette of colors */ y++; if (gui_color_use_term_colors) { gui_color_buffer_display_timer (); y++; } else { gui_chat_printf_y (gui_color_buffer, y++, _("WeeChat color pairs (in use: %d, left: %d):"), gui_color_pairs_used, gui_color_num_pairs - gui_color_pairs_used); } max_color = (gui_color_use_term_colors) ? gui_color_term_colors - 1 : gui_color_num_pairs; if (max_color > 255) max_color = 255; lines = (max_color <= 64) ? 8 : 16; for (line = 0; line < lines; line++) { str_line[0] = '\0'; for (col = 0; col < 16; col++) { color = (col * lines) + line; if (color <= max_color) { if (color == 0) { snprintf (str_color, sizeof (str_color), " "); } else if (gui_color_use_term_colors || (color <= gui_color_pairs_used)) { snprintf (str_color, sizeof (str_color), "%c%c%05d%c%03d%c", GUI_COLOR_COLOR_CHAR, GUI_COLOR_EXTENDED_CHAR, color, (color == 0) ? '<' : ' ', color, (color == 0) ? '>' : ' '); } else { snprintf (str_color, sizeof (str_color), "%s - ", GUI_NO_COLOR); } strcat (str_line, str_color); } else { snprintf (str_color, sizeof (str_color), "%s ", GUI_COLOR(GUI_COLOR_CHAT)); strcat (str_line, str_color); } } gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); } if (gui_color_buffer_extra_info) { /* display time of last auto reset of color pairs */ y++; gui_chat_printf_y (gui_color_buffer, y++, _("Last auto reset of pairs: %s"), (gui_color_pairs_auto_reset_last == 0) ? "-" : ctime (&gui_color_pairs_auto_reset_last)); /* display WeeChat basic colors */ y++; gui_chat_printf_y (gui_color_buffer, y++, _("WeeChat basic colors:")); str_line[0] = '\0'; for (i = 0; i < GUI_CURSES_NUM_WEECHAT_COLORS; i++) { if (gui_color_use_term_colors) { snprintf (str_color, sizeof (str_color), " %s", gui_weechat_colors[i].string); } else { snprintf (str_color, sizeof (str_color), "%c%c%02d %s", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR, i, gui_weechat_colors[i].string); } if (gui_chat_strlen_screen (str_line) + gui_chat_strlen_screen (str_color) > 80) { gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); str_line[0] = '\0'; } strcat (str_line, str_color); } if (str_line[0]) { gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); } /* display nick colors */ y++; gui_chat_printf_y (gui_color_buffer, y++, _("Nick colors:")); items = string_split (CONFIG_STRING(config_color_chat_nick_colors), ",", 0, 0, &num_items); if (items) { str_line[0] = '\0'; for (i = 0; i < num_items; i++) { if (gui_color_use_term_colors) { snprintf (str_color, sizeof (str_color), " %s", items[i]); } else { snprintf (str_color, sizeof (str_color), "%s %s", gui_color_get_custom (items[i]), items[i]); } if (gui_chat_strlen_screen (str_line) + gui_chat_strlen_screen (str_color) > 80) { gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); str_line[0] = '\0'; } strcat (str_line, str_color); } if (str_line[0]) { gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); } string_free_split (items); } /* display palette colors */ if (gui_color_hash_palette_color->items_count > 0) { y++; gui_chat_printf_y (gui_color_buffer, y++, _("Color aliases:")); for (i = 1; i <= gui_color_num_pairs; i++) { color_palette = gui_color_palette_get (i); if (color_palette) { str_color[0] = '\0'; if (!gui_color_use_term_colors) { snprintf (str_color, sizeof (str_color), "%c%c%c%05d", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR, GUI_COLOR_EXTENDED_CHAR, i); } str_rgb[0] = '\0'; if ((color_palette->r >= 0) && (color_palette->g >= 0) && (color_palette->b >= 0)) { snprintf (str_rgb, sizeof (str_rgb), " (%d/%d/%d)", color_palette->r, color_palette->g, color_palette->b); } gui_chat_printf_y (gui_color_buffer, y++, " %5d: %s%s%s", i, str_color, (color_palette->alias) ? color_palette->alias : "", str_rgb); } } } /* display content of colors */ if (gui_color_term_color_content) { y++; gui_chat_printf_y (gui_color_buffer, y++, _("Content of colors (r/g/b):")); for (i = 0; i < gui_color_term_colors; i++) { gui_chat_printf_y (gui_color_buffer, y++, " %3d: %4hd / %4hd / %4hd", i, gui_color_term_color_content[i * 3], gui_color_term_color_content[(i* 3) + 1], gui_color_term_color_content[(i* 3) + 2]); } } } }