summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-10-25 15:48:27 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-10-25 15:48:27 +0100
commit88838d51bb77e1f4dd7da9621f5f34c90f753f4d (patch)
tree6df792601e39c04d4f80c4372999fbddc9c2f847
parent88ca82dea256be57b59a9ea536311b68a5580b12 (diff)
parent2962faed63f4d4520ff34045859420b96b67d5ae (diff)
downloadnetsurf-88838d51bb77e1f4dd7da9621f5f34c90f753f4d.tar.gz
netsurf-88838d51bb77e1f4dd7da9621f5f34c90f753f4d.tar.bz2
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
-rw-r--r--gtk/scaffolding.c40
-rw-r--r--gtk/tabs.c3
-rw-r--r--gtk/tabs.h9
3 files changed, 40 insertions, 12 deletions
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 80b6dea4c..3d86975cc 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -2162,25 +2162,45 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
return g;
}
+/** set the title in the window
+ *
+ * @param gw The gui window to set title on
+ * @param title The title to set (may be NULL)
+ */
void gui_window_set_title(struct gui_window *gw, const char *title)
{
- static char suffix[] = " - NetSurf";
- char nt[strlen(title) + strlen(suffix) + 1];
struct gtk_scaffolding *gs = nsgtk_get_scaffold(gw);
+ int title_len;
+ char *newtitle;
- nsgtk_tab_set_title(gw, title);
-
- if (gs->top_level == gw) {
- if (title == NULL || title[0] == '\0') {
+ if ((title == NULL) || (title[0] == '\0')) {
+ if (gs->top_level != gw) {
gtk_window_set_title(gs->window, "NetSurf");
- } else {
- strcpy(nt, title);
- strcat(nt, suffix);
- gtk_window_set_title(gs->window, nt);
}
+ return;
+ }
+
+ nsgtk_tab_set_title(gw, title);
+
+ if (gs->top_level != gw) {
+ /* not top level window so do not set window title */
+ return;
+ }
+
+ title_len = strlen(title) + SLEN(" - NetSurf") + 1;
+ newtitle = malloc(title_len);
+ if (newtitle == NULL) {
+ return;
}
+
+ snprintf(newtitle, title_len, "%s - NetSurf", title);
+
+ gtk_window_set_title(gs->window, newtitle);
+
+ free(newtitle);
}
+
void gui_window_set_url(struct gui_window *_g, const char *url)
{
struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
diff --git a/gtk/tabs.c b/gtk/tabs.c
index c5ef6fe9c..62a864ed1 100644
--- a/gtk/tabs.c
+++ b/gtk/tabs.c
@@ -334,8 +334,8 @@ void nsgtk_tab_set_title(struct gui_window *g, const char *title)
{
GtkWidget *label;
GtkWidget *tab;
- tab = nsgtk_window_get_tab(g);
+ tab = nsgtk_window_get_tab(g);
if (tab == NULL) {
return;
}
@@ -343,7 +343,6 @@ void nsgtk_tab_set_title(struct gui_window *g, const char *title)
label = g_object_get_data(G_OBJECT(tab), "label");
gtk_label_set_text(GTK_LABEL(label), title);
gtk_widget_set_tooltip_text(tab, title);
-
}
/* exported interface documented in gtk/tabs.h */
diff --git a/gtk/tabs.h b/gtk/tabs.h
index 959799edd..caa683e40 100644
--- a/gtk/tabs.h
+++ b/gtk/tabs.h
@@ -23,6 +23,15 @@ struct gui_window;
void nsgtk_tab_init(struct gtk_scaffolding *gs);
void nsgtk_tab_add(struct gui_window *window, GtkWidget *tab_contents, bool background);
+
+/** set the tab title
+ *
+ * The tab title will be set to the parameter
+ *
+ * @note currently only called from gui_window_set_title()
+ * @param g the gui window to set tab title for.
+ * @param title The title text which may not be NULL.
+ */
void nsgtk_tab_set_title(struct gui_window *g, const char *title);
void nsgtk_tab_options_changed(GtkNotebook *notebook);
nserror nsgtk_tab_close_current(GtkNotebook *notebook);