Changeset 6cb2a945e0d4db91d47be1384bba73331dc6f8c2

Show
Ignore:
Timestamp:
10/12/08 00:52:19 (5 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
534b092abe789eaa49f7f356b43bd77538c62ef9
Children:
d759de258fc66ff7078cbf936bc5bae38e2db6c3
git-committer:
Armin Burgmeier <armin@arbur.net> / 2008-10-12T00:52:19Z+0200
Message:

Make tab label red on activity

2008-10-11 Armin Burgmeier <armin@…>

  • code/core/tablabel.hpp:
  • code/core/tablabel.cpp:
  • code/core/Makefile.am: Added TabLabel? to this extra source file, make color of tab label red on activity, and grey when the document is being synchronized or the connection has been lost.
  • code/core/tablabel.cpp: Removed the TabLabel? class in the anonymous namespace, use the one introduced above instead.
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r534b092 r6cb2a94  
     12008-10-11  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * code/core/tablabel.hpp: 
     4        * code/core/tablabel.cpp: 
     5        * code/core/Makefile.am: Added TabLabel to this extra source file, 
     6        make color of tab label red on activity, and grey when the document is 
     7        being synchronized or the connection has been lost. 
     8 
     9        * code/core/tablabel.cpp: Removed the TabLabel class in the anonymous 
     10        namespace, use the one introduced above instead. 
     11 
    1122008-10-10  Armin Burgmeier  <armin@arbur.net> 
    213 
  • code/core/Makefile.am

    rbd34be3 r6cb2a94  
    1515        preferences.cpp \ 
    1616        statusbar.cpp \ 
     17        tablabel.cpp \ 
    1718        userlist.cpp 
    1819 
     
    3132        preferences.hpp \ 
    3233        statusbar.hpp \ 
     34        tablabel.hpp \ 
    3335        userlist.hpp 
    3436 
  • code/core/folder.cpp

    rbd34be3 r6cb2a94  
    1818 
    1919#include "core/folder.hpp" 
     20#include "core/tablabel.hpp" 
    2021#include "util/closebutton.hpp" 
    2122#include "util/file.hpp" 
    2223 
    23 #include <gtkmm/box.h> 
    24 #include <gtkmm/stock.h> 
    2524#include <gdk/gdkkeysyms.h> 
    2625#include <stdexcept> 
     
    6261        }; 
    6362 
    64         /* TODO: Put TabLabel into an extra source file */ 
    65         class TabLabel: public Gtk::HBox 
    66         { 
    67         public: 
    68                 typedef Glib::SignalProxy0<void> SignalCloseRequest; 
    69  
    70                 TabLabel(Gobby::DocWindow& document, 
    71                          const Glib::ustring& title): 
    72                         Gtk::HBox(false, 4), m_document(document), 
    73                         m_title(title), m_label(title) 
    74                 { 
    75                         update_icon(); 
    76                         m_icon.show(); 
    77  
    78                         m_notify_editable_handle = g_signal_connect( 
    79                                 document.get_text_view(), "notify::editable", 
    80                                 G_CALLBACK(on_notify_editable_static), this); 
    81                         m_notify_status_handle = g_signal_connect( 
    82                                 document.get_session(), "notify::status", 
    83                                 G_CALLBACK(on_notify_status_static), this); 
    84                         m_notify_subscription_group_handle = g_signal_connect( 
    85                                 document.get_session(), 
    86                                 "notify::subscription-group", 
    87                                 G_CALLBACK( 
    88                                         on_notify_subscription_group_static), 
    89                                 this); 
    90  
    91                         //m_label.set_ellipsize(Pango::ELLIPSIZE_END); 
    92                         m_label.show(); 
    93                         m_button.show(); 
    94  
    95                         pack_start(m_icon, Gtk::PACK_SHRINK); 
    96                         pack_start(m_label, Gtk::PACK_EXPAND_WIDGET); 
    97                         pack_start(m_button, Gtk::PACK_SHRINK); 
    98                 } 
    99  
    100                 ~TabLabel() 
    101                 { 
    102                         g_signal_handler_disconnect( 
    103                                 m_document.get_text_view(), 
    104                                 m_notify_editable_handle); 
    105                         g_signal_handler_disconnect( 
    106                                 m_document.get_session(), 
    107                                 m_notify_status_handle); 
    108                         g_signal_handler_disconnect( 
    109                                 m_document.get_session(), 
    110                                 m_notify_subscription_group_handle); 
    111                 } 
    112  
    113                 SignalCloseRequest signal_close_request() { 
    114                         return m_button.signal_clicked(); 
    115                 } 
    116  
    117         private: 
    118                 static void on_notify_editable_static(GObject* object, 
    119                                                       GParamSpec* pspec, 
    120                                                       gpointer user_data) 
    121                 { 
    122                         static_cast<TabLabel*>(user_data)->update_icon(); 
    123                 } 
    124  
    125                 static void on_notify_status_static(GObject* object, 
    126                                                     GParamSpec* pspec, 
    127                                                     gpointer user_data) 
    128                 { 
    129                         static_cast<TabLabel*>(user_data)->update_icon(); 
    130                 } 
    131  
    132                 static void on_notify_subscription_group_static(GObject* obj, 
    133                                                                 GParamSpec* p, 
    134                                                                 gpointer data) 
    135                 { 
    136                         static_cast<TabLabel*>(data)->update_icon(); 
    137                 } 
    138  
    139                 void update_icon() 
    140                 { 
    141                         InfTextSession* session = m_document.get_session(); 
    142                         GtkTextView* view = 
    143                                 GTK_TEXT_VIEW(m_document.get_text_view()); 
    144  
    145                         if(inf_session_get_subscription_group( 
    146                                 INF_SESSION(session)) == NULL) 
    147                         { 
    148                                 m_icon.set(Gtk::Stock::DISCONNECT, 
    149                                            Gtk::ICON_SIZE_MENU); 
    150                                 return; 
    151                         } 
    152  
    153                         switch(inf_session_get_status(INF_SESSION(session))) 
    154                         { 
    155                         case INF_SESSION_SYNCHRONIZING: 
    156                                 m_icon.set(Gtk::Stock::EXECUTE, 
    157                                            Gtk::ICON_SIZE_MENU); 
    158                                 break; 
    159                         case INF_SESSION_RUNNING: 
    160                                 if(gtk_text_view_get_editable(view)) 
    161                                 { 
    162                                         m_icon.set(Gtk::Stock::EDIT, 
    163                                                    Gtk::ICON_SIZE_MENU); 
    164                                 } 
    165                                 else 
    166                                 { 
    167                                         m_icon.set(Gtk::Stock::FILE, 
    168                                                    Gtk::ICON_SIZE_MENU); 
    169                                 } 
    170  
    171                                 break; 
    172                         case INF_SESSION_CLOSED: 
    173                                 m_icon.set(Gtk::Stock::STOP, 
    174                                            Gtk::ICON_SIZE_MENU); 
    175                                 break; 
    176                         } 
    177                 } 
    178  
    179                 Gobby::DocWindow& m_document; 
    180                 Glib::ustring m_title; 
    181  
    182                 Gtk::Image m_icon; 
    183                 Gtk::Label m_label; 
    184                 Gobby::CloseButton m_button; 
    185  
    186                 gulong m_notify_editable_handle; 
    187                 gulong m_notify_status_handle; 
    188                 gulong m_notify_subscription_group_handle; 
    189         }; 
    190  
    19163        void record(InfTextSession* session, const Glib::ustring& title) 
    19264        { 
     
    254126        m_signal_document_added.emit(*window); 
    255127 
    256         TabLabel* tablabel = Gtk::manage(new TabLabel(*window, title)); 
     128        TabLabel* tablabel = Gtk::manage(new TabLabel(*this, *window)); 
    257129        tablabel->signal_close_request().connect( 
    258130                sigc::bind(