changeset 1101:73a85563d3a9

Fix: don't update window title for background tabs
author Jorge Arellano Cid <jcid@dillo.org>
date Sat, 16 May 2009 13:16:09 -0400
parents 614b1d02e6c3
children c44c405a772f
files src/ui.cc src/ui.hh src/uicmd.cc
diffstat 3 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/ui.cc	Fri May 15 22:08:10 2009 -0400
+++ b/src/ui.cc	Sat May 16 13:16:09 2009 -0400
@@ -1059,17 +1059,15 @@
 /*
  * Set the window title
  */
-void UI::set_page_title(const char *label)
+void UI::set_tab_title(const char *label)
 {
    char title[128];
 
    dReturn_if_fail(label != NULL);
 
    snprintf(title, 128, "Dillo: %s", label);
-   this->window()->copy_label(title);
-   this->window()->redraw_label();
-
-   if (tabs() && *label) {
+   if (*label) {
+      // Make a label for this tab
       size_t tab_chars = 18;
       snprintf(title, tab_chars + 1, "%s", label);
       if (strlen(label) > tab_chars) {
--- a/src/ui.hh	Fri May 15 22:08:10 2009 -0400
+++ b/src/ui.hh	Sat May 16 13:16:09 2009 -0400
@@ -92,7 +92,7 @@
    void set_img_prog(int n_img, int t_img, int cmd);
    void set_bug_prog(int n_bug);
    void set_render_layout(Widget &nw);
-   void set_page_title(const char *label);
+   void set_tab_title(const char *label);
    void customize(int flags);
    void button_set_sens(UIButton btn, int sens);
    void paste_url();
--- a/src/uicmd.cc	Fri May 15 22:08:10 2009 -0400
+++ b/src/uicmd.cc	Sat May 16 13:16:09 2009 -0400
@@ -264,7 +264,7 @@
          // Update the window title
          BrowserWindow *bw = a_UIcmd_get_bw_by_widget(selected_child());
          const char *title = a_History_get_title(a_Nav_get_top_uidx(bw), 1);
-         BW2UI(bw)->set_page_title(title ? title : "");
+         a_UIcmd_set_page_title(bw, title ? title : "");
       } else if (e == MOVE) {
          CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager();
          if (event_inside(r) && children() > 1) {
@@ -1127,12 +1127,20 @@
 }
 
 /*
- * Set the page title.
- * now it goes to the window titlebar (maybe to TAB label in the future).
+ * Set the page title in the window titlebar and tab label.
+ * (Update window titlebar for the current tab only)
  */
 void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
 {
-   BW2UI(bw)->set_page_title(label);
+   char title[128];
+
+   if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->selected_child()) == bw) {
+      // This is the focused bw, set window title
+      snprintf(title, 128, "Dillo: %s", label);
+      BW2UI(bw)->window()->copy_label(title);
+      BW2UI(bw)->window()->redraw_label();
+   }
+   BW2UI(bw)->set_tab_title(label);
 }
 
 /*