diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-10 01:22:08 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-10 01:22:08 +0200 |
commit | 57c6478b9184979ad1a09336076b0c07cd7fc56b (patch) | |
tree | 60a01bcb7d788217b5c47431c0c1db12dcc053b3 /src/gui | |
parent | 09c42f4cf0787a72a70dd5273da355e522e9fdf5 (diff) | |
download | weechat-57c6478b9184979ad1a09336076b0c07cd7fc56b.zip |
Add function window_set_title in API (task #9361)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 4 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 142 | ||||
-rw-r--r-- | src/gui/curses/gui-curses.h | 3 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-main.c | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-window.c | 16 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk.h | 3 | ||||
-rw-r--r-- | src/gui/gui-window.h | 3 |
7 files changed, 85 insertions, 90 deletions
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index ce6571101..f6258d6f4 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -135,7 +135,7 @@ gui_main_init () gui_current_window = gui_windows; if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_title_set (); + gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION); } /* create bar windows for root bars (they were read from config, @@ -382,7 +382,7 @@ gui_main_end (int clean_exit) /* reset title */ if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_title_reset (); + gui_window_set_title (NULL); /* end color */ gui_color_end (); diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index d60e37fb8..03195c672 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -1372,83 +1372,89 @@ gui_window_refresh_screen (int full_refresh) } /* - * gui_window_title_set: set terminal title + * gui_window_set_title: set terminal title */ void -gui_window_title_set () -{ - char *envterm = getenv ("TERM"); - - if (envterm) - { - if (strcmp( envterm, "sun-cmd") == 0) - printf ("\033]l%s %s\033\\", PACKAGE_NAME, PACKAGE_VERSION); - else if (strcmp(envterm, "hpterm") == 0) - printf ("\033&f0k%dD%s %s", - (int)(strlen(PACKAGE_NAME) + strlen(PACKAGE_VERSION) + 1), - PACKAGE_NAME, PACKAGE_VERSION); - /* the following term supports the xterm excapes */ - else if (strncmp (envterm, "xterm", 5) == 0 - || strncmp (envterm, "rxvt", 4) == 0 - || strcmp (envterm, "Eterm") == 0 - || strcmp (envterm, "aixterm") == 0 - || strcmp (envterm, "iris-ansi") == 0 - || strcmp (envterm, "dtterm") == 0) - printf ("\33]0;%s %s\7", PACKAGE_NAME, PACKAGE_VERSION); - else if (strcmp (envterm, "screen") == 0) - { - printf ("\033k%s %s\033\\", PACKAGE_NAME, PACKAGE_VERSION); - /* tryning to set the title of a backgrounded xterm like terminal */ - printf ("\33]0;%s %s\7", PACKAGE_NAME, PACKAGE_VERSION); - } - } -} - -/* - * gui_window_title_reset: reset terminal title - */ - -void -gui_window_title_reset () +gui_window_set_title (const char *title) { char *shell, *shellname; char *envterm = getenv ("TERM"); char *envshell = getenv ("SHELL"); - + if (envterm) { - if (strcmp( envterm, "sun-cmd") == 0) - printf ("\033]l%s\033\\", "Terminal"); - else if (strcmp( envterm, "hpterm") == 0) - printf ("\033&f0k%dD%s", (int)strlen("Terminal"), "Terminal"); - /* the following term supports the xterm excapes */ - else if (strncmp (envterm, "xterm", 5) == 0 - || strncmp (envterm, "rxvt", 4) == 0 - || strcmp (envterm, "Eterm") == 0 - || strcmp( envterm, "aixterm") == 0 - || strcmp( envterm, "iris-ansi") == 0 - || strcmp( envterm, "dtterm") == 0) - printf ("\33]0;%s\7", "Terminal"); - else if (strcmp (envterm, "screen") == 0) - { - if (envshell) - { - shell = strdup (envshell); - if (shell) - { - shellname = basename (shell); - printf ("\033k%s\033\\", (shellname) ? shellname : shell); - free (shell); - } - else - printf ("\033k%s\033\\", envterm); - } - else - printf ("\033k%s\033\\", envterm); - /* tryning to reset the title of a backgrounded xterm like terminal */ - printf ("\33]0;%s\7", "Terminal"); - } + if (title && title[0]) + { + if (strcmp (envterm, "sun-cmd") == 0) + { + printf ("\033]l%s\033\\", title); + } + else if (strcmp (envterm, "hpterm") == 0) + { + printf ("\033&f0k%dD%s", (int)(strlen(title) + 1), title); + } + /* the following term supports the xterm excapes */ + else if ((strncmp (envterm, "xterm", 5) == 0) + || (strncmp (envterm, "rxvt", 4) == 0) + || (strcmp (envterm, "Eterm") == 0) + || (strcmp (envterm, "aixterm") == 0) + || (strcmp (envterm, "iris-ansi") == 0) + || (strcmp (envterm, "dtterm") == 0)) + { + printf ("\33]0;%s\7", title); + } + else if (strcmp (envterm, "screen") == 0) + { + printf ("\033k%s\033\\", title); + /* tryning to set the title of a backgrounded xterm like terminal */ + printf ("\33]0;%s\7", title); + } + } + else + { + if (strcmp (envterm, "sun-cmd") == 0) + { + printf ("\033]l%s\033\\", "Terminal"); + } + else if (strcmp (envterm, "hpterm") == 0) + { + printf ("\033&f0k%dD%s", (int)strlen("Terminal"), "Terminal"); + } + /* the following term supports the xterm excapes */ + else if ((strncmp (envterm, "xterm", 5) == 0) + || (strncmp (envterm, "rxvt", 4) == 0) + || (strcmp (envterm, "Eterm") == 0) + || (strcmp( envterm, "aixterm") == 0) + || (strcmp( envterm, "iris-ansi") == 0) + || (strcmp( envterm, "dtterm") == 0)) + { + printf ("\33]0;%s\7", "Terminal"); + } + else if (strcmp (envterm, "screen") == 0) + { + if (envshell) + { + shell = strdup (envshell); + if (shell) + { + shellname = basename (shell); + printf ("\033k%s\033\\", (shellname) ? shellname : shell); + free (shell); + } + else + { + printf ("\033k%s\033\\", envterm); + } + } + else + { + printf ("\033k%s\033\\", envterm); + } + /* tryning to reset the title of a backgrounded xterm like terminal */ + printf ("\33]0;%s\7", "Terminal"); + } + } } } diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index a5125c0d3..3f7783b6b 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -83,7 +83,6 @@ extern void gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg); extern void gui_window_set_custom_color_fg (WINDOW *window, int fg); extern void gui_window_set_custom_color_bg (WINDOW *window, int bg); extern void gui_window_clrtoeol_with_current_bg (WINDOW *window); -extern void gui_window_title_set (); -extern void gui_window_title_reset (); +extern void gui_window_set_title (const char *title); #endif /* gui-curses.h */ diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c index bc5d2d6b7..eff99b2c2 100644 --- a/src/gui/gtk/gui-gtk-main.c +++ b/src/gui/gtk/gui-gtk-main.c @@ -192,7 +192,7 @@ gui_main_init () gui_current_window = gui_windows; if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_title_set (); + gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION); } /* create bar windows for root bars (they were read from config, @@ -270,7 +270,7 @@ gui_main_end (int clean_exit) /* reset title */ if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_title_reset (); + gui_window_set_title (NULL); /* end color */ gui_color_end (); diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c index 627448c2e..5d1abe61b 100644 --- a/src/gui/gtk/gui-gtk-window.c +++ b/src/gui/gtk/gui-gtk-window.c @@ -786,26 +786,18 @@ gui_window_refresh_screen (int full_refresh) } /* - * gui_window_title_set: set terminal title + * gui_window_set_title: set terminal title */ void -gui_window_title_set () +gui_window_set_title (const char *title) { + (void) title; + /* TODO: write this function for Gtk */ } /* - * gui_window_title_reset: reset terminal title - */ - -void -gui_window_title_reset () -{ - /* This function does nothing in Gtk GUI */ -} - -/* * gui_window_objects_print_log: print Gtk objects infos in log * (usually for crash dump) */ diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h index bab6a7960..a7955cf13 100644 --- a/src/gui/gtk/gui-gtk.h +++ b/src/gui/gtk/gui-gtk.h @@ -103,7 +103,6 @@ extern void gui_keyboard_flush (); /* window functions */ extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer); -extern void gui_window_title_set (); -extern void gui_window_title_reset (); +extern void gui_window_set_title (const char *title); #endif /* gui-gtk.h */ diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h index ae81801c7..2c0afd74d 100644 --- a/src/gui/gui-window.h +++ b/src/gui/gui-window.h @@ -171,8 +171,7 @@ extern void gui_window_switch_down (struct t_gui_window *window); extern void gui_window_switch_left (struct t_gui_window *window); extern void gui_window_switch_right (struct t_gui_window *window); extern void gui_window_refresh_screen (int full_refresh); -extern void gui_window_title_set (); -extern void gui_window_title_reset (); +extern void gui_window_set_title (const char *title); extern void gui_window_objects_print_log (struct t_gui_window *window); #endif /* gui-window.h */ |