Changeset 36fa5fe45a5f19487d82bff9bb2c33e39175041a

Show
Ignore:
Timestamp:
04/12/08 20:07:45 (5 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
6eef44e8de0bbc7a63172c7ad06877a8dda58917
Children:
b5b6b61caca9af9f79824bc52bcfaee7c585d287
git-committer:
Armin Burgmeier <armin@arbur.net> / 2008-04-12T20:07:45Z+0200
Message:

Dropped dependency on net6 and obby

2008-04-12 Armin Burgmeier <armin@…>

  • contrib/gobby-0.0.20050522.ebuild:
  • contrib/artwork/chat.svg:
  • test/test_document.cpp: Removed, these are outdated.
  • inc/default_accumulator.hpp:
  • inc/serialize.hpp:
  • src/serialize.cpp: Added. These are basically copies from net6, but in the Gobby namespace.
  • inc/i18n.hpp:
  • src/i18n.cpp: Moved from inc/common.hpp or src/common.cpp, respectively.
  • inc/application_state.hpp:
  • inc/buffer_def.hpp:
  • inc/chat.hpp:
  • inc/colorsel.hpp:
  • inc/historyentry.hpp:
  • inc/document.hpp:
  • inc/document_settings.hpp:
  • inc/entrydialog.hpp:
  • inc/fileentry.hpp:
  • inc/gselector.hpp:
  • inc/hostdialog.hpp:
  • inc/hostprogressdialog.hpp:
  • inc/ipc.hpp:
  • inc/joindialog.hpp:
  • inc/joinprogressdialog.hpp:
  • inc/logview.hpp:
  • inc/passworddialog.hpp:
  • inc/progressdialog.hpp:
  • inc/regex.hpp:
  • inc/togglewindow.hpp:
  • inc/unix.hpp:
  • src/application_state.cpp:
  • src/buffer_def.cpp:
  • src/chat.cpp:
  • src/colorsel.cpp:
  • src/document.cpp:
  • src/document_settings.cpp:
  • src/entrydialog.cpp:
  • src/fileentry.cpp:
  • src/gselector.cpp:
  • src/historyentry.cpp:
  • src/hostdialog.cpp:
  • src/hostprogressdialog.cpp:
  • src/ipc.cpp:
  • src/joindialog.cpp:
  • src/joinprogressdialog.cpp:
  • src/logview.cpp:
  • src/passworddialog.cpp:
  • src/preferencesdialog.cpp:
  • src/progressdialog.cpp:
  • src/regex.cpp:
  • src/togglewindow.cpp:
  • src/unix.cpp: Removed. They are no longer required for infinote, or at least not in a such way that a complete rewrite would not be easier anyway.
  • inc/config.hpp:
  • inc/dragdrop.hpp:
  • inc/encoding.hpp:
  • inc/finddialog.hpp:
  • inc/folder.hpp:
  • inc/statusbar.hpp:
  • inc/window.hpp:
  • src/browser.cpp:
  • src/config.cpp:
  • src/dragdrop.cpp:
  • src/encoding.cpp:
  • src/encoding_selector.cpp:
  • src/finddialog.cpp:
  • src/folder.cpp:
  • src/gotodialog.cpp:
  • src/header.cpp:
  • src/icon.cpp:
  • src/initialdialog.cpp:
  • src/main.cpp:
  • src/resolv.cpp:
  • src/statusbar.cpp:
  • src/window.cpp: Removed any occurences of net6/obby stuff, replaced by equivalent functionlity if possible.
  • po/POTFILES.in: Removed source files, added a TODO comment to readd them as soon as the required files are ready.
  • Makefile.am:
  • contrib/Makefile.am:
  • contrib/artwork/Makefile.am:
  • inc/Makefile.am:
  • pixmaps/Makefile.am:
  • src/Makefile.am:
  • win32/Makefile.am: Hierarchical build instead of only a top-level Makefile.am, so that each Makefile.am is smaller and easier to use.
  • configure.ac: Remove dependency on net6 and obby.
Files:
9 added
44 removed
29 modified
3 moved

Legend:

Unmodified
Added
Removed
  • .gitignore

    rc623d52 r36fa5fe  
    1616autom4te.cache 
    1717.deps 
     18compile 
  • ChangeLog

    r6eef44e r36fa5fe  
     12008-04-12  Armin Burgmeier  <armin@0x539.de> 
     2 
     3        * contrib/gobby-0.0.20050522.ebuild: 
     4        * contrib/artwork/chat.svg: 
     5        * test/test_document.cpp: Removed, these are outdated. 
     6 
     7        * inc/default_accumulator.hpp: 
     8        * inc/serialize.hpp: 
     9        * src/serialize.cpp: Added. These are basically copies from net6, but 
     10        in the Gobby namespace. 
     11 
     12        * inc/i18n.hpp: 
     13        * src/i18n.cpp: Moved from inc/common.hpp or src/common.cpp, 
     14        respectively. 
     15 
     16        * inc/application_state.hpp: 
     17        * inc/buffer_def.hpp: 
     18        * inc/chat.hpp: 
     19        * inc/colorsel.hpp: 
     20        * inc/historyentry.hpp: 
     21        * inc/document.hpp: 
     22        * inc/document_settings.hpp: 
     23        * inc/entrydialog.hpp: 
     24        * inc/fileentry.hpp: 
     25        * inc/gselector.hpp: 
     26        * inc/hostdialog.hpp: 
     27        * inc/hostprogressdialog.hpp: 
     28        * inc/ipc.hpp: 
     29        * inc/joindialog.hpp: 
     30        * inc/joinprogressdialog.hpp: 
     31        * inc/logview.hpp: 
     32        * inc/passworddialog.hpp: 
     33        * inc/progressdialog.hpp: 
     34        * inc/regex.hpp: 
     35        * inc/togglewindow.hpp: 
     36        * inc/unix.hpp: 
     37        * src/application_state.cpp: 
     38        * src/buffer_def.cpp: 
     39        * src/chat.cpp: 
     40        * src/colorsel.cpp: 
     41        * src/document.cpp: 
     42        * src/document_settings.cpp: 
     43        * src/entrydialog.cpp: 
     44        * src/fileentry.cpp: 
     45        * src/gselector.cpp: 
     46        * src/historyentry.cpp: 
     47        * src/hostdialog.cpp: 
     48        * src/hostprogressdialog.cpp: 
     49        * src/ipc.cpp: 
     50        * src/joindialog.cpp: 
     51        * src/joinprogressdialog.cpp: 
     52        * src/logview.cpp: 
     53        * src/passworddialog.cpp: 
     54        * src/preferencesdialog.cpp: 
     55        * src/progressdialog.cpp: 
     56        * src/regex.cpp: 
     57        * src/togglewindow.cpp: 
     58        * src/unix.cpp: Removed. They are no longer required for infinote, or 
     59        at least not in a such way that a complete rewrite would not be easier 
     60        anyway. 
     61 
     62        * inc/config.hpp: 
     63        * inc/dragdrop.hpp: 
     64        * inc/encoding.hpp: 
     65        * inc/finddialog.hpp: 
     66        * inc/folder.hpp: 
     67        * inc/statusbar.hpp: 
     68        * inc/window.hpp: 
     69        * src/browser.cpp: 
     70        * src/config.cpp: 
     71        * src/dragdrop.cpp: 
     72        * src/encoding.cpp: 
     73        * src/encoding_selector.cpp: 
     74        * src/finddialog.cpp: 
     75        * src/folder.cpp: 
     76        * src/gotodialog.cpp: 
     77        * src/header.cpp: 
     78        * src/icon.cpp: 
     79        * src/initialdialog.cpp: 
     80        * src/main.cpp: 
     81        * src/resolv.cpp: 
     82        * src/statusbar.cpp: 
     83        * src/window.cpp: Removed any occurences of net6/obby stuff, replaced 
     84        by equivalent functionlity if possible. 
     85 
     86        * po/POTFILES.in: Removed source files, added a TODO comment to readd 
     87        them as soon as the required files are ready. 
     88 
     89        * Makefile.am: 
     90        * contrib/Makefile.am: 
     91        * contrib/artwork/Makefile.am: 
     92        * inc/Makefile.am: 
     93        * pixmaps/Makefile.am: 
     94        * src/Makefile.am: 
     95        * win32/Makefile.am: Hierarchical build instead of only a top-level 
     96        Makefile.am, so that each Makefile.am is smaller and easier to use. 
     97 
     98        * configure.ac: Remove dependency on net6 and obby. 
     99 
    11002008-04-12  Armin Burgmeier  <armin@0x539.de> 
    2101 
  • Makefile.am

    r00f0fd0 r36fa5fe  
    1 SUBDIRS = m4 . po 
     1SUBDIRS = m4 contrib pixmaps win32 inc src . po 
    22 
    33# Tell aclocal where to find `.m4' files. 
     
    88bin_PROGRAMS = gobby 
    99 
    10 gobby_LDADD     = $(gobby_LIBS) $(gtksourceview_LIBS) 
    11 gobby_CPPFLAGS  = $(gobby_CFLAGS) $(gtksourceview_CFLAGS) 
    12 gobby_CPPFLAGS += -I../inc/ -DLOCALE_DIR=\""$(datadir)/locale"\" 
    13  
    14 if WITH_AVAHI 
    15 gobby_LDADD += $(avahi_LIBS) 
    16 gobby_CPPFLAGS += $(avahi_CFLAGS) 
     10if WIN32 
     11gobby_LDADD = $(gobby_LIBS) src/libgobby.a -lole32 -luuid 
     12gobby_LDFLAGS = -Wl,--enable-runtime-pseudo-reloc -mwindows win32/gobby.res 
     13else 
     14gobby_LDADD = $(gobby_LIBS) src/libgobby.a 
    1715endif 
    1816 
    19 if WITH_GNOME 
    20 gobby_LDADD += $(gnome_LIBS) 
    21 gobby_CPPFLAGS += $(gnome_CFLAGS) 
    22 endif 
    23  
    24 if WIN32 
    25 gobby_LDADD += -lole32 -luuid 
    26 gobby_LDFLAGS = -Wl,--enable-runtime-pseudo-reloc -mwindows win32/gobby.res 
    27 endif 
    28  
    29 noinst_HEADERS = inc/icon.hpp 
    30 if WIN32 
    31 else 
    32 noinst_HEADERS += inc/unix.hpp 
    33 endif 
    34 noinst_HEADERS += inc/gselector.hpp 
    35 noinst_HEADERS += inc/browser.hpp 
    36 noinst_HEADERS += inc/ipc.hpp 
    37 noinst_HEADERS += inc/colorutil.hpp 
    38 noinst_HEADERS += inc/config.hpp 
    39 noinst_HEADERS += inc/common.hpp 
    40 noinst_HEADERS += inc/encoding.hpp 
    41 noinst_HEADERS += inc/resolv.hpp 
    42 noinst_HEADERS += inc/regex.hpp 
    43 noinst_HEADERS += inc/application_state.hpp 
    44 noinst_HEADERS += inc/encoding_selector.hpp 
    45 noinst_HEADERS += inc/historyentry.hpp 
    46 noinst_HEADERS += inc/fileentry.hpp 
    47 noinst_HEADERS += inc/logview.hpp 
    48 noinst_HEADERS += inc/colorsel.hpp 
    49 noinst_HEADERS += inc/preferences.hpp 
    50 noinst_HEADERS += inc/toolwindow.hpp 
    51 noinst_HEADERS += inc/togglewindow.hpp 
    52 noinst_HEADERS += inc/header.hpp 
    53 noinst_HEADERS += inc/statusbar.hpp 
    54 noinst_HEADERS += inc/document.hpp 
    55 noinst_HEADERS += inc/buffer_def.hpp 
    56 noinst_HEADERS += inc/docwindow.hpp 
    57 noinst_HEADERS += inc/folder.hpp 
    58 noinst_HEADERS += inc/document_settings.hpp 
    59 noinst_HEADERS += inc/chat.hpp 
    60 noinst_HEADERS += inc/preferencesdialog.hpp 
    61 noinst_HEADERS += inc/initialdialog.hpp 
    62 noinst_HEADERS += inc/passworddialog.hpp 
    63 noinst_HEADERS += inc/hostdialog.hpp 
    64 noinst_HEADERS += inc/joindialog.hpp 
    65 noinst_HEADERS += inc/progressdialog.hpp 
    66 noinst_HEADERS += inc/joinprogressdialog.hpp 
    67 noinst_HEADERS += inc/hostprogressdialog.hpp 
    68 noinst_HEADERS += inc/entrydialog.hpp 
    69 noinst_HEADERS += inc/finddialog.hpp 
    70 noinst_HEADERS += inc/gotodialog.hpp 
    71 noinst_HEADERS += inc/dragdrop.hpp 
    72 noinst_HEADERS += inc/window.hpp  
    73  
    74 if WIN32 
    75 win32/gobby.res: win32/gobby.rc 
    76         $(WINDRES) -i win32/gobby.rc --input-format=rc -o win32/gobby.res -O coff 
    77 BUILT_SOURCES = win32/gobby.res 
    78 endif 
    79  
    80 gobby_SOURCES = src/icon.cpp 
    81 if WIN32 
    82 else 
    83 gobby_SOURCES += src/unix.cpp 
    84 endif 
    85 gobby_SOURCES += src/gselector.cpp 
    86 gobby_SOURCES += src/browser.cpp 
    87 gobby_SOURCES += src/ipc.cpp 
    88 gobby_SOURCES += src/colorutil.cpp 
    89 gobby_SOURCES += src/config.cpp 
    90 gobby_SOURCES += src/common.cpp 
    91 gobby_SOURCES += src/encoding.cpp 
    92 gobby_SOURCES += src/resolv.cpp 
    93 gobby_SOURCES += src/regex.cpp 
    94 gobby_SOURCES += src/application_state.cpp 
    95 gobby_SOURCES += src/encoding_selector.cpp 
    96 gobby_SOURCES += src/historyentry.cpp 
    97 gobby_SOURCES += src/fileentry.cpp 
    98 gobby_SOURCES += src/logview.cpp 
    99 gobby_SOURCES += src/colorsel.cpp 
    100 gobby_SOURCES += src/preferences.cpp 
    101 gobby_SOURCES += src/toolwindow.cpp 
    102 gobby_SOURCES += src/togglewindow.cpp 
    103 gobby_SOURCES += src/header.cpp 
    104 gobby_SOURCES += src/statusbar.cpp 
    105 gobby_SOURCES += src/document.cpp 
    106 gobby_SOURCES += src/buffer_def.cpp 
    107 gobby_SOURCES += src/docwindow.cpp 
    108 gobby_SOURCES += src/folder.cpp 
    109 gobby_SOURCES += src/document_settings.cpp 
    110 gobby_SOURCES += src/chat.cpp 
    111 gobby_SOURCES += src/preferencesdialog.cpp 
    112 gobby_SOURCES += src/initialdialog.cpp 
    113 gobby_SOURCES += src/passworddialog.cpp 
    114 gobby_SOURCES += src/hostdialog.cpp 
    115 gobby_SOURCES += src/joindialog.cpp 
    116 gobby_SOURCES += src/progressdialog.cpp 
    117 gobby_SOURCES += src/joinprogressdialog.cpp 
    118 gobby_SOURCES += src/hostprogressdialog.cpp 
    119 gobby_SOURCES += src/entrydialog.cpp 
    120 gobby_SOURCES += src/finddialog.cpp 
    121 gobby_SOURCES += src/gotodialog.cpp 
    122 gobby_SOURCES += src/dragdrop.cpp 
    123 gobby_SOURCES += src/window.cpp 
    124 gobby_SOURCES += src/main.cpp 
    125  
    126 appicondir        = $(datadir)/pixmaps 
    127 pixmapdir         = $(datadir)/pixmaps/gobby 
    128 gobby_CPPFLAGS   += -DAPPICON_DIR=\""$(appicondir)"\" 
    129 gobby_CPPFLAGS   += -DPIXMAPS_DIR=\""$(pixmapdir)"\" 
    130 dist_appicon_DATA = pixmaps/gobby.png 
    131 dist_pixmap_DATA  = pixmaps/userlist.png 
    132 dist_pixmap_DATA += pixmaps/doclist.png 
    133 dist_pixmap_DATA += pixmaps/chat.png 
    134  
    135 if WITH_GNOME 
    136 # GNOME-specific installation. 
    137 desktopdir = $(datadir)/applications 
    138 desktop_DATA = contrib/gobby.desktop 
    139 endif 
    140  
    141 EXTRA_DIST =  contrib/artwork/CREDITS 
    142 EXTRA_DIST += contrib/artwork/gobby.svg 
    143 EXTRA_DIST += contrib/artwork/gobby.xpm.gz 
    144 EXTRA_DIST += contrib/gobby.desktop 
    145 EXTRA_DIST += win32/gobby.ico 
    146 EXTRA_DIST += win32/gobby.rc 
    147  
    148 check_PROGRAMS = document 
    149 TESTS = document 
    150  
    151 document_SOURCES  = test/test_document.cpp 
    152 document_SOURCES += src/document.cpp 
    153 document_SOURCES += src/gselector.cpp 
    154 document_LDADD    = $(gobby_LIBS) $(gtksourceview_LIBS) 
    155 document_CPPFLAGS = $(gobby_CFLAGS) $(gtksourceview_CFLAGS) 
    156  
     17gobby_SOURCES =  
  • configure.ac

    r1f3ebdc r36fa5fe  
    1919AC_PROG_LN_S 
    2020AC_PROG_MAKE_SET 
     21AC_PROG_RANLIB 
     22AM_PROG_CC_C_O 
    2123AC_CACHE_SAVE 
    2224 
     
    3537AM_CONDITIONAL(WIN32, test x$win32 = xtrue) 
    3638 
    37 required_libs="libxml++-2.6 gtkmm-2.4 >= 2.12.0 gthread-2.0 net6-1.3 obby-0.4 >= 0.4.5 gtksourceview-2.0 libinfinity-1.0 libinftext-1.0 libinfgtk-1.0 libinftextgtk-1.0" 
     39required_libs="libxml++-2.6 glibmm-2.4 >= 2.16.0 gtkmm-2.4 >= 2.12.0 gthread-2.0 gtksourceview-2.0 libinfinity-1.0 libinftext-1.0 libinfgtk-1.0 libinftextgtk-1.0" 
    3840 
    3941# Checks for libraries. 
     
    5759AC_CACHE_SAVE 
    5860 
    59 # Check for Zeroconf support in obby. 
    60 PKG_CHECK_MODULES([obby], [obby-0.4]) 
    61 AC_CHECK_LIB(obby, obby_has_zeroconf, [obby_has_zeroconf=yes], 
    62              [obby_has_zeroconf=no], [$pkg_cv_obby_LIBS]) 
    63 if test "x$ac_cv_lib_obby_obby_has_zeroconf" = "xyes" ; then 
    64         # obby's pkg-config script takes care of any additional dependencies 
    65         AC_DEFINE([WITH_ZEROCONF], 1, [Define whether to use Zeroconf]) 
    66 fi 
    67 AM_CONDITIONAL(WITH_ZEROCONF, test x$ac_cv_lib_obby_obby_has_zeroconf = xyes) 
    68  
    69 # Check for a specific Zeroconf support in obby, namely Avahi. 
    70 AC_CHECK_LIB(obby, obby_has_avahi, [obby_has_avahi=yes], 
    71              [obby_has_avahi=no], [$pkg_cv_obby_LIBS]) 
    72 if test "x$ac_cv_lib_obby_obby_has_avahi" = "xyes" ; then 
    73         AC_DEFINE([WITH_AVAHI], 1, 
    74                   [Define whether to use Avahi as Zeroconf backend]) 
    75         PKG_CHECK_MODULES([avahi], [avahi-glib]) 
    76 fi 
    77 AM_CONDITIONAL(WITH_AVAHI, test x$ac_cv_lib_obby_obby_has_avahi = xyes) 
    78  
    79 # Check if we are running on OS X, for special link handling. 
    80 if test "x$build_vendor" = "xapple" ; then 
    81   AC_DEFINE([OSX], 1, [Define whether we are running on Mac OS X.]) 
    82 fi 
    83 AC_CACHE_SAVE 
    84  
    8561# Glib i18n/gettext support. 
    8662ALL_LINGUAS="ca de es fr ko it pl pt pt_BR ru sv zh_CN" 
     
    9167AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["${GETTEXT_PACKAGE}"], [gettext domain]) 
    9268 
    93 AC_CONFIG_FILES([Makefile]) 
    94 AC_OUTPUT([po/Makefile.in m4/Makefile]) 
     69AC_OUTPUT([ 
     70        Makefile 
     71                m4/Makefile 
     72                po/Makefile.in 
    9573 
     74                inc/Makefile 
     75                src/Makefile 
     76 
     77                contrib/Makefile 
     78                        contrib/artwork/Makefile 
     79                pixmaps/Makefile 
     80                win32/Makefile 
     81]) 
     82 
  • inc/.gitignore

    rc623d52 r36fa5fe  
    11features.hpp 
    22features.hpp.in 
     3features.hpp.in~ 
    34stamp-h1 
  • inc/config.hpp

    r54c07dd r36fa5fe  
    2020#define _GOBBY_CONFIG_HPP_ 
    2121 
     22#include "serialize.hpp" 
     23 
    2224#include <map> 
    2325#include <memory> 
    24 #include <net6/non_copyable.hpp> 
    25 #include <net6/serialise.hpp> 
    2626#include <glibmm/error.h> 
    2727#include <glibmm/ustring.h> 
     
    3535{ 
    3636 
    37 class Config: private net6::non_copyable 
     37class Config 
    3838{ 
    3939public: 
     
    5151        /** @brief Abstract base class for configuration file entries. 
    5252         */ 
    53         class Entry: private net6::non_copyable 
     53        class Entry 
    5454        { 
    5555        public: 
     
    8080                        const Glib::ustring& name, 
    8181                        const DataType& value, 
    82                         const serialise::context_base_to<DataType>& ctx = 
    83                                 serialise::default_context_to<DataType>() 
     82                        const serialize::context_base_to<DataType>& ctx = 
     83                                serialize::default_context_to<DataType>() 
    8484                ); 
    8585 
     
    8989                template<typename DataType> 
    9090                DataType get( 
    91                         const serialise::context_base_from<DataType>& ctx = 
    92                         serialise::default_context_from<DataType>() 
     91                        const serialize::context_base_from<DataType>& ctx = 
     92                        serialize::default_context_from<DataType>() 
    9393                ) const; 
    9494 
    9595        protected: 
    96                 serialise::data m_data; 
     96                serialize::data m_data; 
    9797        }; 
    9898 
     
    110110                        const Glib::ustring& name, 
    111111                        const DataType& value, 
    112                         const serialise::context_base_to<DataType>& ctx = 
    113                                 serialise::default_context_to<DataType>() 
     112                        const serialize::context_base_to<DataType>& ctx = 
     113                                serialize::default_context_to<DataType>() 
    114114                ); 
    115115 
     
    223223                        const Glib::ustring& name, 
    224224                        const DataType& default_value = DataType(), 
    225                         const serialise::context_base_from<DataType>& ctx = 
    226                                 serialise::default_context_from<DataType>() 
     225                        const serialize::context_base_from<DataType>& ctx = 
     226                                serialize::default_context_from<DataType>() 
    227227                ) const; 
    228228 
     
    238238                        const Glib::ustring& name, 
    239239                        const DataType& default_value = DataType(), 
    240                         const serialise::context_base_from<DataType>& ctx_from = 
    241                                 serialise::default_context_from<DataType>(), 
    242                         const serialise::context_base_to<DataType>& ctx_to = 
    243                                 serialise::default_context_to<DataType>() 
     240                        const serialize::context_base_from<DataType>& ctx_from = 
     241                                serialize::default_context_from<DataType>(), 
     242                        const serialize::context_base_to<DataType>& ctx_to = 
     243                                serialize::default_context_to<DataType>() 
    244244                ); 
    245245 
     
    254254                        const Glib::ustring& name, 
    255255                        const DataType& value, 
    256                         const serialise::context_base_to<DataType>& ctx = 
    257                                 serialise::default_context_to<DataType>() 
     256                        const serialize::context_base_to<DataType>& ctx = 
     257                                serialize::default_context_to<DataType>() 
    258258                ); 
    259259 
     
    311311        ValueEntry(const Glib::ustring& name, 
    312312                   const DataType& value, 
    313                    const serialise::context_base_to<DataType>& ctx): 
     313                   const serialize::context_base_to<DataType>& ctx): 
    314314        Entry(name), m_data(value, ctx) 
    315315{ 
     
    318318template<typename DataType> 
    319319DataType Config::ValueEntry:: 
    320         get(const serialise::context_base_from<DataType>& from) const 
    321 { 
    322         return m_data.::serialise::data::as<DataType>(from); 
     320        get(const serialize::context_base_from<DataType>& from) const 
     321{ 
     322        return m_data.Gobby::serialize::data::as<DataType>(from); 
    323323} 
    324324 
     
    327327        TypedValueEntry(const Glib::ustring& name, 
    328328                        const DataType& value, 
    329                         const serialise::context_base_to<DataType>& ctx): 
     329                        const serialize::context_base_to<DataType>& ctx): 
    330330        ValueEntry(name, value, ctx) 
    331331{ 
     
    341341void Config::TypedValueEntry<DataType>::save(xmlpp::Element& elem) const 
    342342{ 
    343         elem.set_child_text(m_data.serialised() ); 
     343        elem.set_child_text(m_data.serialized() ); 
    344344} 
    345345 
     
    400400        get_value(const Glib::ustring& name, 
    401401                  const DataType& default_value, 
    402                   const serialise::context_base_from<DataType>& ctx) const 
     402                  const serialize::context_base_from<DataType>& ctx) const 
    403403{ 
    404404        const ValueEntry* entry = get_value_child(name); 
     
    411411        supply_value(const Glib::ustring& name, 
    412412                     const DataType& default_value, 
    413                      const serialise::context_base_from<DataType>& ctx_from, 
    414                      const serialise::context_base_to<DataType>& ctx_to) 
     413                     const serialize::context_base_from<DataType>& ctx_from, 
     414                     const serialize::context_base_to<DataType>& ctx_to) 
    415415{ 
    416416        ValueEntry* entry = get_value_child(name); 
     
    425425        set_value(const Glib::ustring& name, 
    426426                  const DataType& value, 
    427                   const serialise::context_base_to<DataType>& ctx) 
     427                  const serialize::context_base_to<DataType>& ctx) 
    428428{ 
    429429        Entry* entry = get_child(name); 
     
    433433} 
    434434 
    435 } // namespace Gobby 
    436  
    437 namespace serialise 
     435namespace serialize 
    438436{ 
    439437 
     
    479477}; 
    480478 
    481 } // namespace serialise 
     479} // namespace serialize 
     480 
     481} // namespace Gobby 
    482482 
    483483#endif // _GOBBY_CONFIG_HPP_ 
  • inc/default_accumulator.hpp

    rbfb82f7 r36fa5fe  
    11/* gobby - A GTKmm driven libobby client 
    2  * Copyright (C) 2005 0x539 dev group 
     2 * Copyright (C) 2005 - 2008 0x539 dev group 
    33 * 
    44 * This program is free software; you can redistribute it and/or 
     
    1717 */ 
    1818 
    19 #ifndef _GOBBY_HISTORYENTRY_HPP_ 
    20 #define _GOBBY_HISTORYENTRY_HPP_ 
    21  
    22 #include <list> 
    23 #include <gtkmm/entry.h> 
     19#ifndef _GOBBY_DEFAULT_ACCUMULATOR_HPP_ 
     20#define _GOBBY_DEFAULT_ACCUMULATOR_HPP_ 
    2421 
    2522namespace Gobby 
    2623{ 
    2724 
    28 /** Entry field which allows to scroll in history using up and down arrows keys. 
     25/** Accumulator for signals with return type that defaults to a value if no 
     26 * signal handler is connected. 
    2927 */ 
    3028 
    31 class HistoryEntry : public Gtk::Entry 
    32 { 
     29template<typename return_type, return_type default_return> 
     30class default_accumulator { 
    3331public: 
    34         HistoryEntry(); 
    35         virtual ~HistoryEntry(); 
     32        typedef return_type result_type; 
    3633 
    37         void clear_history(); 
    38  
    39 protected: 
    40         virtual void on_activate(); 
    41         virtual bool on_key_press_event(GdkEventKey* event); 
    42  
    43         void scroll_down(); 
    44         void scroll_up(); 
    45  
    46         std::list<Glib::ustring> m_history; 
    47         std::list<Glib::ustring>::iterator m_pos; 
     34        template<typename iterator> 
     35        result_type operator()(iterator begin, iterator end) const { 
     36                return_type result = default_return; 
     37                for(; begin != end; ++ begin) 
     38                        result = *begin; 
     39                return result; 
     40        } 
    4841}; 
    4942 
    50 } 
    51          
    52 #endif // _GOBBY_HISTORYENTRY_HPP_ 
     43} // namespace Gobby 
     44 
     45#endif // _GOBBY_DEFAULT_ACCUMULATOR_HPP_ 
  • inc/dragdrop.hpp

    r3e869ac r36fa5fe  
    2121 
    2222#include <sigc++/trackable.h> 
    23 #include <net6/non_copyable.hpp> 
    2423 
    2524namespace Gobby 
     
    3130 */ 
    3231 
    33 class DragDrop: public sigc::trackable, private net6::non_copyable 
     32class DragDrop: public sigc::trackable 
    3433{ 
    3534public: 
  • inc/encoding.hpp

    rfe534f33 r36fa5fe  
    2020#define _GOBBY_ENCODING_HPP_ 
    2121 
    22 #include <list> 
    23 #include <gtkmm/textview.h> 
     22#include <glibmm/ustring.h> 
     23 
     24#include <vector> 
     25#include <string> 
    2426 
    2527namespace Gobby 
  • inc/finddialog.hpp

    rc2b92c8 r36fa5fe  
    2020#define _GOBBY_FINDDIALOG_HPP_ 
    2121 
     22#include "docwindow.hpp" 
     23#include "toolwindow.hpp" 
     24 
    2225#include <gtkmm/window.h> 
    2326#include <gtkmm/separator.h> 
     
    2932#include <gtkmm/radiobutton.h> 
    3033#include <gtkmm/frame.h> 
    31  
    32 #include "toolwindow.hpp" 
    33 #include "regex.hpp" 
    3434 
    3535namespace Gobby 
     
    8484                         Gtk::TextIter& match_end); 
    8585 
    86         void update_regex(); 
    87         void compile_regex(); 
    88  
    8986        Gobby::Window& m_gobby; 
    9087 
     
    106103        Gtk::CheckButton m_check_whole_word; 
    107104        Gtk::CheckButton m_check_case; 
    108         Gtk::CheckButton m_check_regex; 
    109105 
    110106        Gtk::Frame m_frame_direction; 
     
    118114        Gtk::Button m_btn_replace_all; 
    119115        Gtk::Button m_btn_close; 
    120  
    121         regex m_regex; 
    122         bool m_regex_changed; 
    123116}; 
    124117 
  • inc/folder.hpp

    r6eef44e r36fa5fe  
    2121 
    2222#include <sigc++/signal.h> 
    23 #include <net6/default_accumulator.hpp> 
    2423#include <gtksourceview/gtksourcelanguagemanager.h> 
    2524#include <gtkmm/notebook.h> 
    2625 
     26#include "docwindow.hpp" 
    2727#include "preferences.hpp" 
    28 #include "docwindow.hpp" 
     28#include "default_accumulator.hpp" 
    2929 
    3030namespace Gobby 
     
    3939 
    4040        typedef sigc::signal<bool, DocWindow&>:: 
    41                 accumulated<net6::default_accumulator<bool, true> > 
     41                accumulated<default_accumulator<bool, true> > 
    4242                        SignalDocumentCloseRequest; 
    4343 
  • inc/i18n.hpp

    rc603f7c r36fa5fe  
    1717 */ 
    1818 
    19 #ifndef _GOBBY_COMMON_HPP_ 
    20 #define _GOBBY_COMMON_HPP_ 
    21  
    22 #include "net6/gettext_package.hpp" 
     19#ifndef _GOBBY_I18N_HPP_ 
     20#define _GOBBY_I18N_HPP_ 
    2321 
    2422namespace Gobby 
    2523{ 
    26  
    27 /** Initalises gettext for usage with Gobby. Translations a looked up in the 
    28  * given catalog. 
    29  */ 
    30 void init_gettext(net6::gettext_package& package); 
    3124 
    3225/** Translates a message from the gobby catalog. 
     
    3427const char* _(const char* msgid); 
    3528 
    36 /** Translate pluralised message from the gobby catalog. 
     29/** Translate pluralized message from the gobby catalog. 
    3730 */ 
    3831const char* ngettext(const char* msgid, 
     
    4235} 
    4336 
    44 #endif // _GOBBY_COMMON_HPP_ 
     37#endif // _GOBBY_I18N_HPP_ 
    4538 
  • inc/statusbar.hpp

    r6eef44e r36fa5fe  
    2020#define _GOBBY_STATUSBAR_HPP_ 
    2121 
     22#include "folder.hpp" 
     23 
     24#include <gtkmm/box.h> 
     25#include <gtkmm/statusbar.h> 
     26 
    2227#include <glibmm/ustring.h> 
    23 #include <gtkmm/box.h> 
    24 #include <gtkmm/label.h> 
    25 #include <gtkmm/frame.h> 
    26 #include <gtkmm/statusbar.h> 
    27 #include <obby/user.hpp> 
    28 #include "document.hpp" 
    29 #include "buffer_def.hpp" 
    30 #include "header.hpp" 
    31 #include "folder.hpp" 
    3228 
    3329namespace Gobby 
  • inc/window.hpp

    r6eef44e r36fa5fe  
    3232#include "icon.hpp" 
    3333#include "config.hpp" 
    34 #include "application_state.hpp" 
    35 #include "ipc.hpp" 
    3634#include "header.hpp" 
    3735#include "docwindow.hpp" 
    38 #include "buffer_def.hpp" 
    39 #include "hostdialog.hpp" 
    40 #include "joindialog.hpp" 
    4136#include "finddialog.hpp" 
    4237#include "gotodialog.hpp" 
     
    4439#include "initialdialog.hpp" 
    4540#include "folder.hpp" 
    46 #include "document_settings.hpp" 
    4741#include "browser.hpp" 
    4842#include "statusbar.hpp" 
    4943#include "dragdrop.hpp" 
    50 #ifdef WITH_ZEROCONF 
    51 #include <obby/zeroconf.hpp> 
    52 #endif 
    53 #ifdef WITH_AVAHI 
    54 #include <obby/zeroconf_avahi.hpp> 
    55 #include <avahi-glib/glib-watch.h> 
    56 #endif 
    5744 
    5845namespace Gobby 
     
    6552        ~Window(); 
    6653 
    67         /** Offers a pointer to the currently visible document. If the user 
    68          * is not subscribed to a document, NULL is returned. 
    69          */ 
    70         DocWindow* get_current_document(); 
     54        const Folder& get_folder() const { return m_folder; } 
     55        Folder& get_folder() { return m_folder; } 
    7156 
    72         /** @brief Opens a session with the current default settings. 
    73          * 
    74          * If initial_dialog is true a dialog to turn the host parameters is 
    75          * opened, otherwise the default settings are taken. 
    76          * 
    77          * If the session opening failed, a dialog appears where the user 
    78          * might adjust settings or abort. 
    79          * 
    80          * This function must not be called when a buffer is already open. 
    81          */ 
    82         bool session_open(bool initial_dialog); 
    83  
    84         /** @brief Joins a session with the current default settings. 
    85          * 
    86          * If initial_dialog is true a dialog to turn the join parameters is 
    87          * opened, otherwise the default settings are used. 
    88          * 
    89          * If the session join failed, a dialog appears where the user 
    90          * might adjust settings or abort. 
    91          * 
    92          * This function must not be called when a buffer is already open. 
    93          */ 
    94         bool session_join(bool initial_dialog); 
    95  
    96         /** Opens a document containing the content of a file mounted on the 
    97          * local filesystem. 
    98          */ 
    99         void open_local_file(const Glib::ustring& file, 
    100                              const std::string& encoding); 
    101  
    102         /** Saves an existing document to the given path. 
    103          */ 
    104         void save_local_file(DocWindow& doc, 
    105                              const Glib::ustring& file, 
    106                              const std::string& encoding); 
    10757protected: 
    10858        // Gtk::Window overrides 
     
    11363        void on_initial_dialog_hide(); 
    11464 
    115         // Start/End obby session 
    116         void obby_start(); 
    117         void obby_end(); 
    118  
    119         // Header UI handler 
    120         void on_session_create(); 
    121         void on_session_join(); 
    122         void on_session_save(); 
    123         void on_session_quit(); 
    124  
    125         void on_document_create(); 
    126         void on_document_open(); 
    127         void on_document_save(); 
    128         bool handle_document_save(); 
    129         void on_document_save_as(); 
    130         bool handle_document_save_as(); 
    131         void on_document_close(); 
    132  
    133         void on_edit_search(); 
    134         void on_edit_search_replace(); 
    135         void on_edit_goto_line(); 
    136         void on_edit_preferences(); 
    137  
    138         void on_user_set_password(); 
    139         void on_user_set_colour(); 
    140  
    141         void on_view_preferences(); 
    142         void on_view_language(GtkSourceLanguage* language); 
    143  
    144         void on_window_chat(); 
    145 #if 0 
    146         // Folder UI handler 
    147         void on_folder_document_add(DocWindow& window); 
    148         void on_folder_document_remove(DocWindow& window); 
    149         void on_folder_document_close_request(DocWindow& window); 
    150         void on_folder_tab_switched(DocWindow& window); 
    151 #endif 
    152         void on_settings_document_insert(LocalDocumentInfo& info); 
    153  
    154         void on_about(); 
    155         void on_quit(); 
    156  
    157         // Obby signal handlers 
    158         void on_obby_close(); 
    159  
    160         void on_obby_user_join(const obby::user& user); 
    161         void on_obby_user_part(const obby::user& user); 
    162         void on_obby_user_colour(const obby::user& user); 
    163         void on_obby_user_colour_failed(); 
    164         void on_obby_document_insert(DocumentInfo& document); 
    165         void on_obby_document_remove(DocumentInfo& document); 
    166  
    167         // IPC signal handlers 
    168         void on_ipc_file(const std::string& file); 
    169  
    170         // Helper functions 
    171         void apply_preferences(); 
    172         void update_title_bar(); 
    173         void close_document(DocWindow& doc); 
    174         void display_error(const Glib::ustring& message, 
    175                            const Gtk::MessageType type = Gtk::MESSAGE_ERROR); 
    176  
    177         bool session_join_impl(const Glib::ustring& host, 
    178                                unsigned int port, 
    179                                const Glib::ustring& name, 
    180                                const Gdk::Color& color); 
    181  
    182         bool session_open_impl(unsigned int port, 
    183                                const Glib::ustring& name, 
    184                                const Gdk::Color& color, 
    185                                const Glib::ustring& password, 
    186                                const Glib::ustring& session); 
    187  
    18865        // Config 
    18966        Config& m_config; 
     
    19168        Preferences m_preferences; 
    19269        const IconManager& m_icon_mgr; 
    193  
    194         // Paths 
    195         std::string m_last_path; 
    196         std::string m_prev_session; 
    197  
    198         std::string m_local_file_path; 
    199         std::string m_local_encoding; 
    20070 
    20171        // GUI 
     
    20676        Gtk::Frame m_frame_text; 
    20777 
    208         ApplicationState m_application_state; 
    209         DocumentSettings m_document_settings; 
    210  
    21178        Header m_header; 
    21279        Folder m_folder; 
     
    21481        Browser m_browser; 
    21582 
    216         std::auto_ptr<FindDialog> m_finddialog; 
    217         std::auto_ptr<GotoDialog> m_gotodialog; 
    218  
    219         sigc::connection m_conn_chat_realize; 
    220  
    221         /** Drag+Drop handler 
    222          */ 
     83        // TODO: Can't we use this directly now that the session is 
     84        // "always open"? 
    22385        std::auto_ptr<DragDrop> m_dnd; 
    224  
    225         /** Local IPC handler 
    226          */ 
    227         std::auto_ptr<Ipc::LocalInstance> m_ipc; 
    228         std::queue<std::string> m_file_queue; 
    22986 
    23087        // Dialogs 
    23188        std::auto_ptr<InitialDialog> m_initial_dlg; 
    23289        std::auto_ptr<PreferencesDialog> m_preferences_dlg; 
    233         std::auto_ptr<HostDialog> m_host_dlg; 
    234         std::auto_ptr<JoinDialog> m_join_dlg; 
    235  
    236         // obby 
    237         std::auto_ptr<LocalBuffer> m_buffer; 
    238 #ifdef WITH_ZEROCONF 
    239         std::auto_ptr<obby::zeroconf_base> m_zeroconf; 
    240 #endif 
    241 #ifdef WITH_AVAHI 
    242         AvahiGLibPoll* m_glib_poll; 
    243 #endif 
    244         sigc::connection m_timer_conn; 
     90        std::auto_ptr<FindDialog> m_finddialog; 
     91        std::auto_ptr<GotoDialog> m_gotodialog; 
    24592}; 
    24693 
  • po/POTFILES.in

    r492197d r36fa5fe  
    11# source files 
    22 
    3 src/application_state.cpp 
    4 src/buffer_def.cpp 
    5 src/chat.cpp 
    6 src/colorsel.cpp 
    7 src/common.cpp 
    8 src/config.cpp 
    9 src/document.cpp 
    10 src/documentlist.cpp 
    11 src/document_settings.cpp 
    12 src/docwindow.cpp 
    13 src/dragdrop.cpp 
    14 src/encoding.cpp 
    15 src/encoding_selector.cpp 
    16 src/entrydialog.cpp 
    17 src/fileentry.cpp 
    18 src/finddialog.cpp 
    19 src/folder.cpp 
    20 src/gotodialog.cpp 
    21 src/gselector.cpp 
    22 src/header.cpp 
    23 src/historyentry.cpp 
    24 src/hostdialog.cpp 
    25 src/hostprogressdialog.cpp 
    26 src/icon.cpp 
    27 src/ipc.cpp 
    28 src/joindialog.cpp 
    29 src/joinprogressdialog.cpp 
    30 src/logview.cpp 
    31 src/main.cpp 
    32 src/passworddialog.cpp 
    33 src/preferences.cpp 
    34 src/preferencesdialog.cpp 
    35 src/progressdialog.cpp 
    36 src/regex.cpp 
    37 src/statusbar.cpp 
    38 src/togglewindow.cpp 
    39 src/toolwindow.cpp 
    40 src/unix.cpp 
    41 src/userlist.cpp 
    42 src/window.cpp 
     3# TODO 
  • src/browser.cpp

    r6eef44e r36fa5fe  
    1818 
    1919#include "browser.hpp" 
    20 #include "common.hpp" 
    21  
    22 #include <obby/format_string.hpp> 
     20#include "i18n.hpp" 
     21 
    2322#include <libinfinity/inf-config.h> 
    2423#include <libinfinity/common/inf-discovery-avahi.h> 
     
    194193        // Translators: That's a Unicode horizontal ellipsis character, 
    195194        // not three dots. 
    196         obby::format_string status_str("Resolving %0%
"); 
    197         status_str << host; 
    198195        StatusBar::MessageHandle message_handle = 
    199                 m_status_bar.add_message(StatusBar::INFO, 
    200                                          status_str.str(), 0); 
     196                m_status_bar.add_message( 
     197                        StatusBar::INFO, Glib::ustring::compose( 
     198                                _("Resolving %0
"), host), 0); 
    201199 
    202200        m_resolv_map[resolv_handle].message_handle = message_handle; 
  • src/config.cpp

    r5bc7ec4 r36fa5fe  
    1717 */ 
    1818 
     19#include "config.hpp" 
     20#include "i18n.hpp" 
     21 
     22#include <glibmm/miscutils.h> 
     23#include <glibmm/fileutils.h> 
     24#include <glibmm/exception.h> 
     25#include <libxml++/parsers/domparser.h> 
     26#include <libxml++/exceptions/exception.h> 
     27 
    1928// For mkdir / CreateDirectory 
    2029#ifdef WIN32 
     
    2938#include <stdexcept> 
    3039 
    31 #include <glibmm/miscutils.h> 
    32 #include <glibmm/fileutils.h> 
    33 #include <glibmm/exception.h> 
    34 #include <libxml++/parsers/domparser.h> 
    35 #include <libxml++/exceptions/exception.h> 
    36  
    37 #include "config.hpp" 
    38  
    3940namespace 
    4041{ 
     
    4243        void create_directory(const char* path) 
    4344        { 
     45                using namespace Gobby; 
    4446#ifdef WIN32 
    4547                if(CreateDirectoryA(path, NULL) == FALSE) 
     
    6668                        throw Gobby::Config::Error( 
    6769                                Gobby::Config::Error::PATH_CREATION_FAILED, 
    68                                 "Could not create directory " + 
    69                                 std::string(path) + ": " + error_message 
    70                         ); 
     70                                Glib::ustring::compose( 
     71                                        _("Could not create directory " 
     72                                          "\"%1\": %2"), std::string(path), 
     73                                        error_message)); 
    7174                } 
    7275#else 
     
    7578                        throw Gobby::Config::Error( 
    7679                                Gobby::Config::Error::PATH_CREATION_FAILED, 
    77                                 "Could not create directory " + 
    78                                 std::string(path) + ": " + strerror(errno) 
    79                         ); 
     80                                Glib::ustring::compose( 
     81                                        _("Could not create directory " 
     82                                          "\"%1\": %2"), std::string(path), 
     83                                        strerror(errno))); 
    8084                } 
    8185#endif 
     
    338342} 
    339343 
    340 std::string serialise::default_context_to<Gdk::Color>:: 
     344std::string Gobby::serialize::default_context_to<Gdk::Color>:: 
    341345        to_string(const data_type& from) const 
    342346{ 
     
    350354} 
    351355 
    352 serialise::default_context_from<Gdk::Color>::data_type 
    353 serialise::default_context_from<Gdk::Color>:: 
     356Gobby::serialize::default_context_from<Gdk::Color>::data_type 
     357Gobby::serialize::default_context_from<Gdk::Color>:: 
    354358        from_string(const std::string& from) const 
    355359{ 
     
    372376} 
    373377 
    374 std::string serialise::default_context_to<Glib::ustring>:: 
     378std::string Gobby::serialize::default_context_to<Glib::ustring>:: 
    375379        to_string(const data_type& from) const 
    376380{ 
     
    378382} 
    379383 
    380 serialise::default_context_from<Glib::ustring>::data_type 
    381 serialise::default_context_from<Glib::ustring>:: 
     384Gobby::serialize::default_context_from<Glib::ustring>::data_type 
     385Gobby::serialize::default_context_from<Glib::ustring>:: 
    382386        from_string(const std::string& from) const 
    383387{ 
  • src/dragdrop.cpp

    rddc15e4 r36fa5fe  
    176176                        DragQueryFileA(drop, i, buf, size + 1); 
    177177 
    178                         m_window.open_local_file( 
     178                        // TODO: User still needs to select where to store 
     179                        // that file in the directory. 
     180                        /*m_window.open_local_file( 
    179181                                buf, 
    180182                                Gobby::EncodingSelector::AUTO_DETECT 
    181                         ); 
     183                        );*/ 
    182184 
    183185                        delete[] buf; 
     
    240242                        } 
    241243 
    242                         window.open_local_file( 
     244                        // TODO: User still needs to select where to store 
     245                        // that file in the directory. 
     246                        /*window.open_local_file( 
    243247                                filename, 
    244248                                Gobby::EncodingSelector::AUTO_DETECT 
    245                         ); 
     249                        );*/ 
    246250                } 
    247251        } 
  • src/encoding.cpp

    rfe534f33 r36fa5fe  
    1717 */ 
    1818 
    19 #include <cstdlib> 
    20 #include "common.hpp" 
    2119#include "encoding.hpp" 
     20#include "i18n.hpp" 
     21 
     22#include <glibmm/convert.h> 
    2223 
    2324namespace 
  • src/encoding_selector.cpp

    r38afe53 r36fa5fe  
    1717 */ 
    1818 
     19#include "encoding_selector.hpp" 
     20#include "encoding.hpp" 
     21#include "i18n.hpp" 
     22 
     23#include <gtkmm/liststore.h> 
    1924#include <stdexcept> 
    20 #include <gtkmm/liststore.h> 
    21  
    22 #include "common.hpp" 
    23 #include "encoding.hpp" 
    24 #include "encoding_selector.hpp" 
    2525 
    2626const std::string Gobby::EncodingSelector::AUTO_DETECT = "Auto Detect"; 
  • src/finddialog.cpp

    r6eef44e r36fa5fe  
    1717 */ 
    1818 
     19#include "finddialog.hpp" 
     20#include "window.hpp" 
     21#include "i18n.hpp" 
     22 
     23#include <gtkmm/messagedialog.h> 
     24#include <gtkmm/textbuffer.h> 
     25#include <gtkmm/stock.h> 
    1926#include <gtksourceview/gtksourceiter.h> 
    20 #include <gtkmm/stock.h> 
    21 #include <gtkmm/messagedialog.h> 
    22  
    23 #include "common.hpp" 
    24 #include "document.hpp" 
    25 #include "window.hpp" 
    26 #include "finddialog.hpp" 
    2727 
    2828namespace 
     
    4545        m_check_whole_word(_("Match whole word only")), 
    4646        m_check_case(_("Match case")), 
    47         m_check_regex(_("Match as regular expression")), 
    4847        m_frame_direction(_("Direction")), 
    4948        m_radio_up(m_group_direction, _("_Up"), true), 
     
    5251        m_btn_replace(_("_Replace") ), 
    5352        m_btn_replace_all(_("Replace _all") ), 
    54         m_btn_close(Gtk::Stock::CLOSE), 
    55         m_regex("") 
     53        m_btn_close(Gtk::Stock::CLOSE) 
    5654{ 
    5755        Gtk::Image* replace_img = Gtk::manage( 
     
    9795        m_box_options.pack_start(m_check_whole_word, Gtk::PACK_EXPAND_WIDGET); 
    9896        m_box_options.pack_start(m_check_case, Gtk::PACK_EXPAND_WIDGET); 
    99         m_box_options.pack_start(m_check_regex, Gtk::PACK_EXPAND_WIDGET); 
    10097 
    10198        m_frame_direction.add(m_box_direction); 
     
    109106        m_box_btns.pack_start(m_btn_replace_all, Gtk::PACK_EXPAND_PADDING); 
    110107        m_box_btns.pack_start(m_btn_close, Gtk::PACK_EXPAND_PADDING); 
    111  
    112         m_entry_find.signal_changed().connect( 
    113                 sigc::mem_fun(*this, &FindDialog::update_regex)); 
    114         m_check_case.signal_toggled().connect( 
    115                 sigc::mem_fun(*this, &FindDialog::update_regex)); 
    116         m_check_regex.signal_toggled().connect( 
    117                 sigc::mem_fun(*this, &FindDialog::update_regex)); 
    118108 
    119109        m_entry_find.signal_activate().connect( 
     
    142132        show_all_children(); 
    143133 
    144         m_check_regex.hide(); 
    145134        set_search_only(true); 
    146135} 
     
    167156void Gobby::FindDialog::on_find() 
    168157{ 
    169         if(m_check_regex.get_active() && m_regex_changed) 
    170                 compile_regex(); 
    171  
    172158        DocWindow* doc = get_document(); 
    173159        if(doc == NULL) return; 
     
    179165        if(!result) 
    180166        { 
    181                 obby::format_string str( 
    182                         _("\"%0%\" has not been found in the document.") 
    183                 ); 
    184  
    185                 str << m_entry_find.get_text(); 
     167                Glib::ustring str = Glib::ustring::compose( 
     168                        "\"%1\" has not been found in the document", 
     169                        m_entry_find.get_text()); 
    186170 
    187171                Gtk::MessageDialog dlg( 
    188172                        *this, 
    189                         str.str(), 
     173                        str, 
    190174                        false, 
    191175                        Gtk::MESSAGE_INFO, 
     
    200184void Gobby::FindDialog::on_replace() 
    201185{ 
    202         if(m_check_regex.get_active() && m_regex_changed) 
    203                 compile_regex(); 
    204  
    205186        DocWindow* doc = get_document(); 
    206187        if(doc == NULL) return; 
     
    239220void Gobby::FindDialog::on_replace_all() 
    240221{ 
    241         if(m_check_regex.get_active() && m_regex_changed) 
    242                 compile_regex(); 
    243  
    244222        DocWindow* doc = get_document(); 
    245223        if(doc == NULL) return; 
     
    267245        else 
    268246        { 
    269                 obby::format_string str( 
    270                         ngettext( 
    271                                 "%0% occurence has been replaced", 
    272                                 "%0% occurences have been replaced", 
    273                                 replace_count 
    274                         ) 
    275                 ); 
    276  
    277                 str << replace_count; 
    278                 msg = str.str(); 
     247                msg = Glib::ustring::compose( 
     248                        ngettext("%1 occurence has been replaced", 
     249                                 "%1 occurences have been replaced", 
     250                                 replace_count), replace_count); 
    279251        } 
    280252 
     
    293265Gobby::DocWindow* Gobby::FindDialog::get_document() 
    294266{ 
    295         DocWindow* doc = m_gobby.get_current_document(); 
     267        DocWindow* doc = m_gobby.get_folder().get_current_document(); 
    296268 
    297269        if(doc == NULL) 
     
    391363                                    Gtk::TextIter& match_end) 
    392364{ 
    393         if(m_check_regex.get_active() ) 
    394         { 
    395                 Glib::RefPtr<Gtk::TextBuffer> buf = from.get_buffer(); 
    396  
    397                 Gtk::TextIter start_pos, limit; 
    398                 if(m_radio_up.get_active() ) 
    399                 { 
    400                         limit = from; 
    401  
    402                         if(to == NULL) 
    403                                 start_pos = buf->begin(); 
    404                         else 
    405                                 start_pos = *to; 
    406                 } 
    407                 else if(m_radio_down.get_active() ) 
    408                 { 
    409                         start_pos = from; 
    410  
    411                         if(to == NULL) 
    412                                 limit = buf->end(); 
    413                         else 
    414                                 limit = *to; 
    415                 } 
    416  
    417                 Gtk::TextIter begin = buf->end(), end = buf->end(); 
    418                 Gtk::TextIter cur_line = start_pos, next_line = start_pos; 
    419                 for(;;) 
    420                 { 
    421                         next_line.forward_line(); 
    422  
    423                         // Get current line of text 
    424                         Glib::ustring line = cur_line.get_slice(next_line); 
    425  
    426                         // Trim trailing text after limit 
    427                         if(limit.get_line() == cur_line.get_line() ) 
    428                         { 
    429                                 if(!limit.ends_line() ) 
    430                                 { 
    431                                         line.erase( 
    432                                                 limit.get_line_offset() - 
    433                                                 cur_line.get_line_offset() 
    434                                         ); 
    435                                 } 
    436                         } 
    437  
    438                         regex::match_options options = 
    439                                 regex::match_options::NONE; 
    440  
    441                         if(!cur_line.starts_line() ) 
    442                                 options |= regex::match_options::NOT_BOL; 
    443  
    444                         if(cur_line.get_line() == limit.get_line() && 
    445                            !limit.ends_line() ) 
    446                                 options |= regex::match_options::NOT_EOL; 
    447  
    448                         std::pair<std::size_t, std::size_t> pos; 
    449                         bool result = m_regex.find( 
    450                                 line.c_str(), 
    451                                 pos, 
    452                                 options 
    453                         ); 
    454  
    455                         if(result == true) 
    456                         { 
    457                                 begin = end = cur_line; 
    458                                 begin.set_line_index( 
    459                                         begin.get_line_index() + pos.first 
    460                                 ); 
    461  
    462                                 end.set_line_index( 
    463                                         end.get_line_index() + pos.second 
    464                                 ); 
    465  
    466                                 // Match after limit 
    467                                 if(end > limit) break; 
    468  
    469                                 // First match is result if searching forward 
    470                                 if(m_radio_down.get_active() ) 
    471                                 { 
    472                                         match_start = begin; 
    473                                         match_end = end; 
    474  
    475                                         return true; 
    476                                 } 
    477                         } 
    478  
    479                         cur_line = next_line; 
    480                         if(cur_line > limit || cur_line == buf->end() ) 
    481                                 break; 
    482                 } 
    483  
    484                 if(m_radio_up.get_active() ) 
    485                 { 
    486                         // No match for backward search 
    487                         if(begin == buf->end() && end == buf->end() ) 
    488                                 return false; 
    489  
    490                         match_start = begin; 
    491                         match_end = end; 
    492  
    493                         return true; 
    494                 } 
    495  
    496                 // No match for forward search 
    497                 return false; 
    498         } 
    499         else 
    500         { 
    501                 GtkSourceSearchFlags flags = GtkSourceSearchFlags(0); 
    502                 if(!m_check_case.get_active() ) 
    503                         flags = GTK_SOURCE_SEARCH_CASE_INSENSITIVE; 
    504  
    505                 gtk_source_iter_search_func search_func = 
    506                         gtk_source_iter_forward_search; 
    507  
    508                 if(m_radio_up.get_active() ) 
    509                         search_func = gtk_source_iter_backward_search; 
    510  
    511                 Glib::ustring find_str = m_entry_find.get_text(); 
    512                 GtkTextIter match_start_gtk, match_end_gtk; 
    513                 gboolean result = search_func( 
    514                         from.gobj(), 
    515                         find_str.c_str(), 
    516                         flags, 
    517                         &match_start_gtk, 
    518                         &match_end_gtk, 
    519                         to != NULL ? to->gobj() : NULL 
    520                 ); 
    521  
    522                 if(result == TRUE) 
    523                 { 
    524                         match_start = Gtk::TextIter(&match_start_gtk); 
    525                         match_end = Gtk::TextIter(&match_end_gtk); 
    526  
    527                         return true; 
    528                 } 
    529  
    530                 return false; 
    531         } 
    532 } 
    533  
    534 void Gobby::FindDialog::update_regex() 
    535 { 
    536         if (m_check_regex.get_active()) 
    537                 m_regex_changed = true; 
    538         else 
    539                 m_regex_changed = false; 
    540 } 
    541  
    542 void Gobby::FindDialog::compile_regex() 
    543 { 
    544         if (m_check_case.get_active()) 
    545         { 
    546                 m_regex.reset( 
    547                         m_entry_find.get_text().c_str(), 
    548                         regex::compile_options::EXTENDED 
    549                 ); 
    550         } 
    551         else 
    552         { 
    553                 m_regex.reset( 
    554                         m_entry_find.get_text().c_str(), 
    555                         regex::compile_options::EXTENDED | 
    556                         regex::compile_options::IGNORE_CASE 
    557                 ); 
    558         } 
    559  
    560         m_regex_changed = false; 
    561 } 
    562  
     365        GtkSourceSearchFlags flags = GtkSourceSearchFlags(0); 
     366        if(!m_check_case.get_active() ) 
     367                flags = GTK_SOURCE_SEARCH_CASE_INSENSITIVE; 
     368 
     369        gtk_source_iter_search_func search_func = 
     370                gtk_source_iter_forward_search; 
     371 
     372        if(m_radio_up.get_active() ) 
     373                search_func = gtk_source_iter_backward_search; 
     374 
     375        Glib::ustring find_str = m_entry_find.get_text(); 
     376        GtkTextIter match_start_gtk, match_end_gtk; 
     377        gboolean result = search_func( 
     378                from.gobj(), 
     379                find_str.c_str(), 
     380                flags, 
     381                &match_start_gtk, 
     382                &match_end_gtk, 
     383                to != NULL ? to->gobj() : NULL 
     384        ); 
     385 
     386        if(result == TRUE) 
     387        { 
     388                match_start = Gtk::TextIter(&match_start_gtk); 
     389                match_end = Gtk::TextIter(&match_end_gtk); 
     390 
     391                return true; 
     392        } 
     393 
     394        return false; 
     395} 
  • src/folder.cpp

    r6eef44e r36fa5fe  
    1717 */ 
    1818 
    19 #include <stdexcept> 
    20 #include <gdk/gdkkeysyms.h> 
     19#include "folder.hpp" 
     20 
    2121#include <gtkmm/box.h> 
    2222#include <gtkmm/button.h> 
    2323#include <gtkmm/stock.h> 
    24  
    25 #include "document.hpp" 
    26 #include "folder.hpp" 
     24#include <gdk/gdkkeysyms.h> 
     25#include <stdexcept> 
    2726 
    2827namespace 
    2928{ 
    30         class KeyMap: private net6::non_copyable 
     29        class KeyMap 
    3130        { 
    3231        public: 
  • src/gotodialog.cpp

    r6eef44e r36fa5fe  
    1717 */ 
    1818 
    19 #include <gtkmm/stock.h> 
    20 #include <gtkmm/messagedialog.h> 
    21  
    22 #include "common.hpp" 
    23 #include "document.hpp" 
    2419#include "gotodialog.hpp" 
    2520#include "window.hpp" 
     21#include "i18n.hpp" 
     22 
     23#include <gtkmm/messagedialog.h> 
     24#include <gtkmm/textbuffer.h> 
     25#include <gtkmm/stock.h> 
    2626 
    2727Gobby::GotoDialog::GotoDialog(Gobby::Window& parent): 
     
    4141        m_btn_goto.set_image(*goto_img); 
    4242 
    43         // TODO: Change this value according to line count in current document? 
     43        // TODO: Change this value according to line count in current document! 
    4444        m_ent_line.set_range(1, 0x7fffffff); 
    4545        m_ent_line.set_increments(1, 10); 
     
    8484        m_ent_line.grab_focus(); 
    8585 
    86         Gobby::DocWindow* window = m_window.get_current_document(); 
     86        Gobby::DocWindow* window = 
     87                m_window.get_folder().get_current_document(); 
    8788        if(window != NULL) 
    8889        { 
    89     Glib::RefPtr<Gtk::TextBuffer> buffer = 
    90       Glib::wrap(GTK_TEXT_BUFFER(window->get_text_buffer()), true); 
     90                Glib::RefPtr<Gtk::TextBuffer> buffer = 
     91                        Glib::wrap(GTK_TEXT_BUFFER(window->get_text_buffer()), 
     92                                   true); 
    9193                Gtk::TextIter cursor = buffer->get_insert()->get_iter(); 
    9294 
     
    100102void Gobby::GotoDialog::on_goto() 
    101103{ 
    102         Gobby::DocWindow* window = m_window.get_current_document(); 
     104        Gobby::DocWindow* window = 
     105                m_window.get_folder().get_current_document(); 
    103106        if(window != NULL) 
    104107        { 
    105108                int value = m_ent_line.get_value_as_int(); 
    106     Glib::RefPtr<Gtk::TextBuffer> buffer = 
    107       Glib::wrap(GTK_TEXT_BUFFER(window->get_text_buffer()), true); 
     109                Glib::RefPtr<Gtk::TextBuffer> buffer = 
     110                        Glib::wrap(GTK_TEXT_BUFFER(window->get_text_buffer()), 
     111                                   true); 
    108112                Gtk::TextIter begin = buffer->get_iter_at_line(value - 1); 
    109113                window->set_selection(begin, begin); 
  • src/header.cpp

    r00f0fd0 r36fa5fe  
    1717 */ 
    1818 
    19 #include <gtkmm/stock.h> 
    20 #include <obby/format_string.hpp> 
    21  
    22 #include "common.hpp" 
    2319#include "header.hpp" 
    2420#include "icon.hpp" 
    25  
    26 #include <iostream> 
     21#include "i18n.hpp" 
     22 
     23#include <gtkmm/stock.h> 
     24 
    2725namespace { 
    2826        Glib::ustring ui_desc =  
  • src/i18n.cpp

    rc603f7c r36fa5fe  
    1717 */ 
    1818 
    19 #include "common.hpp" 
     19#include "i18n.hpp" 
     20#include "features.hpp" 
    2021 
    21 namespace 
    22 { 
    23         net6::gettext_package* local_package; 
    24 } 
    25  
    26 void Gobby::init_gettext(net6::gettext_package& package) 
    27 { 
    28         local_package = &package; 
    29 } 
     22#include <libintl.h> 
    3023 
    3124const char* Gobby::_(const char* msgid) 
    3225{ 
    33         return local_package->gettext(msgid); 
     26        return dgettext(GETTEXT_PACKAGE, msgid); 
    3427} 
    3528 
     
    3831                            unsigned long int n) 
    3932{ 
    40         return local_package->ngettext(msgid, msgid_plural, n); 
     33        return dngettext(GETTEXT_PACKAGE, msgid, msgid_plural, n); 
    4134} 
  • src/icon.cpp

    r7dac53b r36fa5fe  
    1 /* IconZZzzzzzzzzz */ 
     1/* gobby - A GTKmm driven libobby client 
     2 * Copyright (C) 2005, 2006 0x539 dev group 
     3 * 
     4 * This program is free software; you can redistribute it and/or 
     5 * modify it under the terms of the GNU General Public 
     6 * License as published by the Free Software Foundation; either 
     7 * version 2 of the License, or (at your option) any later version. 
     8 * 
     9 * This program is distributed in the hope that it will be useful, 
     10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12 * General Public License for more details. 
     13 * 
     14 * You should have received a copy of the GNU General Public 
     15 * License along with this program; if not, write to the Free 
     16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
     17 */ 
    218 
    319#include <glib/gtypes.h> 
    420#include <gtkmm/stockitem.h> 
    5 #include "common.hpp" 
     21#include "i18n.hpp" 
    622#include "icon.hpp" 
    723 
     
    7591        m_icon_factory->add_default(); 
    7692} 
    77  
  • src/initialdialog.cpp

    r1f3ebdc r36fa5fe  
    1717 */ 
    1818 
     19#include "initialdialog.hpp" 
     20#include "colorutil.hpp" 
     21#include "i18n.hpp" 
     22#include "features.hpp" 
     23 
    1924#include <gtkmm/stock.h> 
    2025#include <gtkmm/alignment.h> 
    21 #include "features.hpp" 
    22 #include "common.hpp" 
    23 #include "colorutil.hpp" 
    24 #include "initialdialog.hpp" 
    2526 
    2627namespace 
  • src/main.cpp

    r2270de3 r36fa5fe  
    1717 */ 
    1818 
    19 #include <iostream> 
     19#include "window.hpp" 
     20#include "config.hpp" 
     21#include "icon.hpp" 
     22#include "features.hpp" 
     23 
    2024#include <gtkmm/main.h> 
    2125#include <gtkmm/messagedialog.h> 
     
    2327#include <glibmm/optiongroup.h> 
    2428#include <glibmm/optioncontext.h> 
    25 #include "common.hpp" 
    26 #include "ipc.hpp" 
    27 #include "icon.hpp" 
    28 #include "config.hpp" 
    29 #include "encoding_selector.hpp" 
    30 #include "window.hpp" 
    31 #include "features.hpp" 
    3229 
    33 #ifdef WITH_GNOME 
    34 # include <libgnomevfs/gnome-vfs-init.h> 
    35 #endif 
     30#include <iostream> 
    3631 
    37 void handle_exception(const Glib::ustring& message) 
     32namespace 
    3833{ 
    39         Gtk::MessageDialog dlg("Unhandled exception: " + message, false, 
    40                 Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); 
    41         dlg.run(); 
    42         std::cerr << "Unhandled exception: " << message << std::endl; 
    43 } 
     34        void handle_exception(const Glib::ustring& message) 
     35        { 
     36                Gtk::MessageDialog dlg("Unhandled exception", false, 
     37                        Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); 
     38                dlg.set_secondary_text(message); 
     39                dlg.run(); 
    4440 
    45 std::auto_ptr<Gobby::Ipc::RemoteConnection> 
    46 open_files(Gobby::Window& wnd, 
    47            const std::vector<std::string>& files, 
    48            bool disable_ipc, 
    49            bool do_join) 
    50 { 
    51         std::auto_ptr<Gobby::Ipc::RemoteConnection> conn; 
    52  
    53         // Neither do NPC when we want to join a session 
    54         if(!disable_ipc && !do_join) 
    55         { 
    56                 try 
    57                 { 
    58                         // Try to connect to other gobby instance 
    59                         Gobby::Ipc::RemoteInstance instance; 
    60  
    61                         conn.reset( 
    62                                 new Gobby::Ipc::RemoteConnection(instance) 
    63                         ); 
    64                 } 
    65                 catch(Gobby::Ipc::Error& e) 
    66                 { 
    67                         if(e.code() != Gobby::Ipc::Error::NO_REMOTE_INSTANCE) 
    68                                 throw e; 
    69                 } 
     41                std::cerr << "Unhandled exception: " << message << std::endl; 
    7042        } 
    71  
    72         if(conn.get() != NULL) 
    73         { 
    74                 // Found one, send files. Finish from mainloop as soon as 
    75                 // all the files have been sent. 
    76                 conn->done_event().connect(sigc::ptr_fun(&Gtk::Main::quit)); 
    77  
    78                 for(std::vector<std::string>::const_iterator iter = 
    79                         files.begin(); 
    80                     iter != files.end(); 
    81                     ++ iter) 
    82                 { 
    83                         conn->send_file(iter->c_str() ); 
    84                 } 
    85         } 
    86         else 
    87         { 
    88                 // No other gobby found, so open the files locally 
    89                 wnd.show(); 
    90  
    91                 bool result = do_join ? 
    92                         wnd.session_join(false) : 
    93                         wnd.session_open(false); 
    94  
    95                 // First, open a session with default settings 
    96                 if(result) 
    97                 { 
    98                         // And pass files 
    99                         for(std::vector<std::string>::const_iterator iter = 
    100                                 files.begin(); 
    101                             iter != files.end(); 
    102                             ++ iter) 
    103                         { 
    104                                 wnd.open_local_file( 
    105                                         *iter, 
    106                                         Gobby::EncodingSelector::AUTO_DETECT 
    107                                 ); 
    108                         } 
    109                 } 
    110         } 
    111  
    112         return conn; 
    11343} 
    11444 
     
    11646{ 
    11747        g_thread_init(NULL); 
    118 //      if(!Glib::thread_supported()) 
    119 //              Glib::thread_init(); 
     48        gnutls_global_init(); 
    12049 
    12150        setlocale(LC_ALL, ""); 
    122         net6::gettext_package gobby_package(GETTEXT_PACKAGE, LOCALE_DIR); 
    123         Gobby::init_gettext(gobby_package); 
     51        bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); 
     52        bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); 
    12453 
    12554        bool new_instance = false; 
    12655        Glib::ustring join; 
    12756 
    128         Glib::OptionGroup opt_group_gobby("gobby", "Gobby options", "Options related directly to gobby"); 
    129         Glib::OptionEntry opt_new_instance; 
    130         opt_new_instance.set_short_name('n'); 
    131         opt_new_instance.set_long_name("new-instance"); 
    132         opt_new_instance.set_description( 
    133                 "Do not try to contact already running gobby instance" 
    134         ); 
    135  
    136         Glib::OptionEntry opt_join; 
    137         opt_join.set_short_name('j'); 
    138         opt_join.set_long_name("join"); 
    139         opt_join.set_arg_description("HOST:PORT"); 
    140         opt_join.set_description("Join a session on the given host"); 
    141  
    142         opt_group_gobby.add_entry(opt_new_instance, new_instance); 
    143         opt_group_gobby.add_entry(opt_join, join); 
    144  
    145         Glib::OptionContext opt_ctx("[file1] [file2] [...]"); 
     57        Glib::OptionContext opt_ctx; 
    14658        opt_ctx.set_help_enabled(true); 
    14759        opt_ctx.set_ignore_unknown_options(false); 
    148  
    149         opt_ctx.set_main_group(opt_group_gobby); 
    15060 
    15161        // I would rather like to have Gtk::Main on the stack, but I see 
     
    16474        } 
    16575 
    166         net6::main netkit; 
    167  
    168 #ifdef WITH_GNOME 
    169         gnome_vfs_init(); 
    170 #endif 
    171  
    172         // Get files to open 
    173         std::vector<std::string> files(argc - 1); 
    174         for(int i = 1; i < argc; ++ i) 
    175         { 
    176                 // Make absolute filenames to understand the files 
    177                 // from everywhere when we send them to another process 
    178                 if(!Glib::path_is_absolute(argv[i])) 
    179                 { 
    180                         files[i - 1] = Glib::build_filename( 
    181                                 Glib::get_current_dir(), 
    182                                 argv[i] 
    183                         ); 
    184                 } 
    185                 else 
    186                 { 
    187                         files[i - 1] = argv[i]; 
    188                 } 
    189         } 
    190  
    191         Gobby::IconManager icon_mgr; 
     76        Gobby::IconManager icon_manager; 
    19277 
    19378        // Set default icon 
    19479        std::list<Glib::RefPtr<Gdk::Pixbuf> > icon_list; 
    195         icon_list.push_back(icon_mgr.gobby); 
     80        icon_list.push_back(icon_manager.gobby); 
    19681        Gtk::Window::set_default_icon_list(icon_list); 
    19782 
     
    19984        Gobby::Config config(Glib::get_home_dir() + "/.gobby/config.xml"); 
    20085 
    201         // Set join parameters if we want to join a session 
    202         if(!join.empty()) 
    203         { 
    204                 Glib::ustring::size_type pos = join.rfind(':'); 
    205                 if(pos == std::string::npos) pos = join.length(); 
    206  
    207                 Gobby::Config::ParentEntry& entry = 
    208                         config.get_root()["session"]; 
    209  
    210                 entry.set_value("join_host", join.substr(0, pos)); 
    211                 if(pos < join.length()) 
    212                 { 
    213                         entry.set_value( 
    214                                 "join_port", 
    215                                 std::strtoul( 
    216                                         join.substr(pos + 1).c_str(), 
    217                                         NULL, 
    218                                         10 
    219                                 ) 
    220                         ); 
    221                 } 
    222         } 
    223  
    22486        // Create window 
    225         Gobby::Window wnd(icon_mgr, config); 
    226  
    227         // Open files passed by command line. Need to keep rem_conn, 
    228         // otherwise the connection would be dropped through 
    229         // Gobby::Ipc::RemoteConnection's destructor. 
    230         std::auto_ptr<Gobby::Ipc::RemoteConnection> rem_conn; 
    231         if(!files.empty() ) 
    232                 rem_conn = open_files(wnd, files, new_instance, !join.empty()); 
    233         else 
    234         { 
    235                 wnd.show(); 
    236  
    237                 if(!join.empty()) 
    238                         wnd.session_join(false); 
    239         } 
     87        Gobby::Window wnd(icon_manager, config); 
     88        wnd.show(); 
    24089 
    24190        // Cannot use just kit.run(wnd) since this would show wnd. If we 
     
    24392        // the window to be shown. 
    24493        wnd.signal_hide().connect(sigc::ptr_fun(&Gtk::Main::quit) ); 
    245  
    24694        kit->run(); 
    24795 
    248 #ifdef WITH_GNOME 
    249         //gnome_vfs_shutdown(); // Prints error messages. 
    250                                 // I don't know where they come from... 
    251 #endif 
    252  
     96        //gnutls_global_deinit(); 
    25397        return 0; 
    25498} 
  • src/preferencesdialog.cpp

    r00f0fd0 r36fa5fe  
    1717 */ 
    1818 
     19#include "preferencesdialog.hpp" 
     20#include "colorutil.hpp" 
     21#include "i18n.hpp" 
     22 
     23#include <gtkmm/messagedialog.h> 
     24#include <gtkmm/stock.h> 
    1925#include <stdexcept> 
    20 #include <gtkmm/stock.h> 
    21 #include <gtkmm/messagedialog.h> 
    22  
    23 #include <obby/format_string.hpp> 
    24  
    25 #include "common.hpp" 
    26 #include "colorutil.hpp" 
    27 #include "preferencesdialog.hpp" 
    2826 
    2927namespace 
  • src/resolv.cpp

    r6eef44e r36fa5fe  
    1818 
    1919#include "resolv.hpp" 
    20 #include "common.hpp" 
    2120 
    2221#include <glibmm/main.h> 
  • src/statusbar.cpp

    r6eef44e r36fa5fe  
    1919#include "statusbar.hpp" 
    2020 
     21#include <gtkmm/frame.h> 
    2122#include <gtkmm/stock.h> 
    2223 
  • src/window.cpp

    r6eef44e r36fa5fe  
    1717 */ 
    1818 
    19 #include <stdexcept> 
    20 #include <fstream> 
    21 #include <ostream> 
    22  
    23 #include <glibmm/miscutils.h> 
    24 #include <gtkmm/main.h> 
    25 #include <gtkmm/aboutdialog.h> 
    26 #include <gtkmm/messagedialog.h> 
    27 #include <gtkmm/filechooserdialog.h> 
    28 #include <gtkmm/stock.h> 
    29  
    30 #include <obby/format_string.hpp> 
    31 #include <obby/client_buffer.hpp> 
    32 #include <obby/host_buffer.hpp> 
    33  
    34 #include "common.hpp" 
    35 #include "encoding.hpp" 
    36 #include "encoding_selector.hpp" 
     19#include "window.hpp" 
    3720#include "docwindow.hpp" 
    38 #include "passworddialog.hpp" 
    39 #include "entrydialog.hpp" 
    40 #include "preferencesdialog.hpp" 
    41 #include "joinprogressdialog.hpp" 
    42 #include "hostprogressdialog.hpp" 
    43 #include "window.hpp" 
     21#include "icon.hpp" 
    4422#include "features.hpp" 
    45 #include "icon.hpp" 
    46 #include "colorsel.hpp" 
    4723 
    4824#include <libinftextgtk/inf-text-gtk-buffer.h> 
     
    7854Gobby::Window::Window(const IconManager& icon_mgr, Config& config): 
    7955        Gtk::Window(Gtk::WINDOW_TOPLEVEL), m_config(config), 
    80         m_lang_manager(gtk_source_language_manager_new()), 
     56        m_lang_manager(gtk_source_language_manager_get_default()), 
    8157        m_preferences(m_config), m_icon_mgr(icon_mgr), 
    82         m_application_state(APPLICATION_NONE), 
    83         m_document_settings(*this), 
    8458        m_header(m_preferences, m_lang_manager), 
    8559        m_folder(m_preferences, m_lang_manager), 
    8660        m_statusbar(m_folder), 
    8761        m_browser(*this, &TEXT_PLUGIN, m_statusbar, m_preferences) 
    88 #ifdef WITH_AVAHI 
    89         ,m_glib_poll(avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT)) 
    90 #endif 
    9162{ 
    92 #if 0 
    93         // Header 
    94         m_header.action_app_session_create->signal_activate().connect( 
    95                 sigc::mem_fun(*this, &Window::on_session_create) ); 
    96         m_header.action_app_session_join->signal_activate().connect( 
    97                 sigc::mem_fun(*this, &Window::on_session_join) ); 
    98         m_header.action_app_session_save->signal_activate().connect( 
    99                 sigc::mem_fun(*this, &Window::on_session_save) ); 
    100         m_header.action_app_session_quit->signal_activate().connect( 
    101                 sigc::mem_fun(*this, &Window::on_session_quit) ); 
    102         m_header.action_app_quit->signal_activate().connect( 
    103                 sigc::mem_fun(*this, &Window::on_quit) ); 
    104  
    105         m_header.action_session_document_create->signal_activate().connect( 
    106                 sigc::mem_fun(*this, &Window::on_document_create) ); 
    107         m_header.action_session_document_open->signal_activate().connect( 
    108                 sigc::mem_fun(*this, &Window::on_document_open) ); 
    109         m_header.action_session_document_save->signal_activate().connect( 
    110                 sigc::mem_fun(*this, &Window::on_document_save) ); 
    111         m_header.action_session_document_save_as->signal_activate().connect( 
    112                 sigc::mem_fun(*this, &Window::on_document_save_as) ); 
    113         m_header.action_session_document_close->signal_activate().connect( 
    114                 sigc::mem_fun(*this, &Window::on_document_close) ); 
    115  
    116         m_header.action_edit_search->signal_activate().connect( 
    117                 sigc::mem_fun(*this, &Window::on_edit_search) ); 
    118         m_header.action_edit_search_replace->signal_activate().connect( 
    119                 sigc::mem_fun(*this, &Window::on_edit_search_replace) ); 
    120         m_header.action_edit_goto_line->signal_activate().connect( 
    121                 sigc::mem_fun(*this, &Window::on_edit_goto_line) ); 
    122         m_header.action_edit_preferences->signal_activate().connect( 
    123                 sigc::mem_fun(*this, &Window::on_edit_preferences) ); 
    124  
    125         m_header.action_user_set_colour->signal_activate().connect( 
    126                 sigc::mem_fun(*this, &Window::on_user_set_colour) ); 
    127         m_header.action_user_set_password->signal_activate().connect( 
    128                 sigc::mem_fun(*this, &Window::on_user_set_password) ); 
    129  
    130         m_header.action_edit_document_preferences->signal_activate().connect( 
    131                 sigc::mem_fun(*this, &Window::on_view_preferences) ); 
    132  
    133         m_header.action_window_chat->signal_activate().connect( 
    134                 sigc::mem_fun(*this, &Window::on_window_chat) ); 
    135  
    136         m_header.action_help_about->signal_activate().connect( 
    137                 sigc::mem_fun(*this, &Window::on_about) ); 
    138 #endif 
    13963        m_browser.show(); 
    140  
    141 #if 0 
    142         // Folder 
    143         m_folder.document_add_event().connect( 
    144                 sigc::mem_fun(*this, &Window::on_folder_document_add) ); 
    145         m_folder.document_remove_event().connect( 
    146                 sigc::mem_fun(*this, &Window::on_folder_document_remove) ); 
    147         m_folder.document_close_request_event().connect( 
    148                 sigc::mem_fun(*this, &Window::on_folder_document_close_request) ); 
    149         m_folder.tab_switched_event().connect( 
    150                 sigc::mem_fun(*this, &Window::on_folder_tab_switched) ); 
    151 #endif 
    152         // Settings 
    153         m_document_settings.document_insert_event().connect( 
    154                 sigc::mem_fun(*this, &Window::on_settings_document_insert) ); 
    15564 
    15665        // Build UI 
     
    17281        add(m_mainbox); 
    17382 
    174         // Apply initial preferences 
    175         apply_preferences(); 
    176  
    177         Config::ParentEntry& windows = config.get_root()["windows"]; 
    178         m_application_state.modify(APPLICATION_INITIAL, APPLICATION_NONE); 
    179  
    18083        show_all_children(); 
    18184 
    18285        set_title("Gobby"); 
    18386        set_default_size(640, 480); 
    184  
    185 #ifdef WITH_ZEROCONF 
    186         // Initialise Zeroconf 
    187         try 
    188         { 
    189 #ifdef WITH_AVAHI 
    190                 m_zeroconf.reset(new obby::zeroconf_avahi(avahi_glib_poll_get(m_glib_poll))); 
    191 #else 
    192                 m_zeroconf.reset(new obby::zeroconf); 
    193                 // Periodically check for events when not using Avahi Glib Poll 
    194                 Glib::signal_timeout().connect(sigc::bind(sigc::mem_fun(*m_zeroconf.get(), &zeroconf_base::select), 0), 1500); 
    195 #endif 
    196         } 
    197         catch(std::runtime_error&) 
    198         { 
    199                 std::cerr << _("Zeroconf initialisation failed. Probably you " 
    200                         "need to run avahi-daemon or mDNSResponder, depending " 
    201                         "on the library you use, as root prior to Gobby. " 
    202                         "Zeroconf support is deactivated for this session."); 
    203                 std::cerr << std::endl; 
    204                 m_zeroconf.reset(); 
    205         } 
    206 #endif 
    20787} 
    20888 
    20989Gobby::Window::~Window() 
    21090{ 
    211         if(m_buffer.get() && m_buffer->is_open() ) 
    212                 obby_end(); 
    213  
    21491        // Serialise preferences into config 
    21592        m_preferences.serialise(m_config); 
    216  
    217         /* Free explictely to make sure that the avahi poll is no longer 
    218          * referenced when we free it */ 
    219 #ifdef WITH_ZEROCONF 
    220         m_zeroconf.reset(NULL); 
    221 #endif 
    222  
    223 #ifdef WITH_AVAHI 
    224         avahi_glib_poll_free(m_glib_poll); 
    225 #endif 
    22693} 
    22794 
    22895bool Gobby::Window::on_delete_event(GdkEventAny* event) 
    22996{ 
     97#if 0 
    23098        if(m_buffer.get() == NULL) return false; 
    23199        if(!m_buffer->is_open() ) return false; 
     
    253121 
    254122        return dlg.run() != Gtk::RESPONSE_YES; 
     123#endif 
     124        return false; 
    255125} 
    256126 
     
    260130 
    261131        m_paned.set_position(m_paned.get_width() * 2 / 5); 
    262  
    263         // Create new IPC instance 
    264         try 
    265         { 
    266                 m_ipc.reset(new Ipc::LocalInstance); 
    267                 m_ipc->file_event().connect( 
    268                         sigc::mem_fun(*this, &Window::on_ipc_file) 
    269                 ); 
    270         } 
    271         catch(net6::error& e) 
    272         { 
    273                 // Whatever... 
    274                 display_error(e.what() ); 
    275         } 
    276132} 
    277133 
     
    297153        m_config.get_root()["initial"].set_value("run", true); 
    298154} 
    299  
    300 void Gobby::Window::obby_start() 
    301 { 
    302         // Connect to obby events 
    303         m_buffer->user_join_event().connect( 
    304                 sigc::mem_fun(*this, &Window::on_obby_user_join) ); 
    305         m_buffer->user_part_event().connect( 
    306                 sigc::mem_fun(*this, &Window::on_obby_user_part) ); 
    307         m_buffer->user_colour_event().connect( 
    308                 sigc::mem_fun(*this, &Window::on_obby_user_colour) ); 
    309         m_buffer->user_colour_failed_event().connect( 
    310                 sigc::mem_fun(*this, &Window::on_obby_user_colour_failed) ); 
    311  
    312         m_buffer->document_insert_event().connect( 
    313                 sigc::mem_fun(*this, &Window::on_obby_document_insert) ); 
    314         m_buffer->document_remove_event().connect( 
    315                 sigc::mem_fun(*this, &Window::on_obby_document_remove) ); 
    316  
    317         // Accept drag and drop of files into the gobby window 
    318         m_dnd.reset(new DragDrop(*this) ); 
    319  
    320         // Delegate start of obby session 
    321         m_document_settings.obby_start(*m_buffer); 
    322  
    323         // Forward user joins 
    324         const obby::user_table& table = m_buffer->get_user_table(); 
    325         for(obby::user_table::iterator iter = 
    326                 table.begin(obby::user::flags::NONE, obby::user::flags::NONE); 
    327             iter != table.end(obby::user::flags::NONE, obby::user::flags::NONE); 
    328             ++ iter) 
    329         { 
    330                 on_obby_user_join(*iter); 
    331         } 
    332  
    333         // Send documents to components 
    334         Buffer::document_iterator iter = m_buffer->document_begin(); 
    335         for(; iter != m_buffer->document_end(); ++ iter) 
    336                 on_obby_document_insert(*iter); 
    337  
    338         // Set last page as active one because it is currently shown anyway. 
    339         //if(m_buffer->document_count() > 0) 
    340         //      m_folder.set_current_page(m_buffer->document_count() - 1); 
    341  
    342         // Clear location of previous session file, this is a new session 
    343         m_prev_session = ""; 
    344  
    345         // Current document has changed, update titlebar 
    346         update_title_bar(); 
    347  
    348         // Show up document list if obby buffer contains documents 
    349         if(m_buffer->document_count() > 0) 
    350         { 
    351         } 
    352  
    353         ApplicationFlags inc_flags = APPLICATION_SESSION; 
    354         ApplicationFlags exc_flags = APPLICATION_INITIAL | APPLICATION_DOCUMENT; 
    355  
    356         if(dynamic_cast<ClientBuffer*>(m_buffer.get()) != NULL) 
    357                 exc_flags |= APPLICATION_HOST; 
    358         else 
    359                 inc_flags |= APPLICATION_HOST; 
    360  
    361         m_application_state.modify(inc_flags, exc_flags); 
    362 } 
    363  
    364 void Gobby::Window::obby_end() 
    365 { 
    366         // Nothing to do if no buffer is open 
    367         if(m_buffer.get() == NULL) 
    368         { 
    369                 throw std::logic_error( 
    370                         "Gobby::Window::obby_end:\n" 
    371                         "Buffer not available" 
    372                 ); 
    373         } 
    374  
    375         m_application_state.modify(APPLICATION_NONE, APPLICATION_SESSION); 
    376  
    377         if(m_buffer->is_open() ) 
    378         { 
    379                 // TODO: Virtual close call in obby? 
    380                 ClientBuffer* client_buf = 
    381                         dynamic_cast<ClientBuffer*>(m_buffer.get()); 
    382                 HostBuffer* host_buf = 
    383                         dynamic_cast<HostBuffer*>(m_buffer.get()); 
    384  
    385                 if(client_buf != NULL) client_buf->disconnect(); 
    386                 if(host_buf != NULL) host_buf->close(); 
    387         } 
    388  
    389         // Remove DND handler 
    390         m_dnd.reset(NULL); 
    391  
    392         // Tell GUI components that the session ended 
    393         m_document_settings.obby_end(); 
    394  
    395 #ifdef WITH_ZEROCONF 
    396         if(m_zeroconf.get() ) 
    397                 m_zeroconf->unpublish_all(); 
    398 #endif 
    399 } 
    400  
    401 void Gobby::Window::on_session_create() 
    402 { 
    403         session_open(true); 
    404 } 
    405  
    406 void Gobby::Window::on_session_join() 
    407 { 
    408         session_join(true); 
    409 } 
    410  
    411 void Gobby::Window::on_session_save() 
    412 { 
    413         Gtk::CheckButton m_chk_default_ext( 
    414                 _("Use default .obby extension if none is given") 
    415         ); 
    416  
    417         Gtk::FileChooserDialog dlg( 
    418                 *this, 
    419                 _("Save obby session"), 
    420                 Gtk::FILE_CHOOSER_ACTION_SAVE 
    421         ); 
    422  
    423         m_chk_default_ext.set_active(true); 
    424         dlg.get_vbox()->pack_start(m_chk_default_ext, Gtk::PACK_SHRINK); 
    425         // This option confuses the overwrite confirmation :/ 
    426         //m_chk_default_ext.show(); 
    427  
    428 #ifdef GTKMM_GEQ_28 
    429         dlg.set_do_overwrite_confirmation(true); 
    430 #endif 
    431  
    432         // Use the location of a previously saved session, if any 
    433         if(!m_prev_session.empty() ) 
    434         { 
    435                 dlg.set_filename(m_prev_session); 
    436         } 
    437         else 
    438         { 
    439                 // Use the last used path for this dialog, if we have any 
    440                 if(!m_last_path.empty() ) 
    441                         dlg.set_current_folder(m_last_path); 
    442         } 
    443  
    444         dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 
    445         dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); 
    446  
    447         if(dlg.run() == Gtk::RESPONSE_OK) 
    448         { 
    449                 // Use current folder as standard folder for other dialogs 
    450                 m_last_path = dlg.get_current_folder(); 
    451                 // Get selected filename 
    452                 std::string filename = dlg.get_filename(); 
    453  
    454                 // Append .obby extension if none is given 
    455                 /*if(m_chk_default_ext.get_active() ) 
    456                         if(filename.find('.') == std::string::npos) 
    457                                 filename += ".obby";*/ 
    458  
    459                 // Save document 
    460                 try 
    461                 { 
    462                         m_buffer->serialise(filename); 
    463                         m_prev_session = filename; 
    464                 } 
    465                 catch(std::exception& e) 
    466                 { 
    467                         display_error(e.what() ); 
    468                 } 
    469         } 
    470 } 
    471  
    472 void Gobby::Window::on_session_quit() 
    473 { 
    474         obby_end(); 
    475 } 
    476  
    477 void Gobby::Window::on_about() 
    478 { 
    479         Gtk::AboutDialog dlg; 
    480         dlg.set_name("Gobby"); 
    481         dlg.set_version(PACKAGE_VERSION); 
    482         dlg.set_comments(_("A collaborative text editor")); 
    483  
    484         dlg.set_copyright( 
    485                 "Copyright (C) 2005-2007 0x539 dev group <crew@0x539.de>" 
    486         ); 
    487  
    488         dlg.set_logo(m_icon_mgr.gobby); 
    489  
    490         std::deque<Glib::ustring> authors; 
    491         authors.push_back("Developers:"); 
    492         authors.push_back("  Armin Burgmeier <armin@0x539.de>"); 
    493         authors.push_back("  Philipp Kern <phil@0x539.de>"); 
    494         authors.push_back(""); 
    495         authors.push_back("Contributors:"); 
    496         authors.push_back("  Benjamin Herr <ben@0x539.de>"); 
    497          
    498         std::deque<Glib::ustring> artists; 
    499         artists.push_back("Logo:"); 
    500         artists.push_back("  Thomas Glatt <tom@0x539.de>"); 
    501         artists.push_back(""); 
    502         artists.push_back("Additional artwork:"); 
    503         artists.push_back("  Thomas Glatt <tom@0x539.de>"); 
    504         artists.push_back("  Benjamin Herr <ben@0x539.de>"); 
    505  
    506         dlg.set_authors(authors); 
    507         dlg.set_artists(artists); 
    508  
    509         dlg.set_translator_credits( 
    510                 "French translation:\n" 
    511                 "  Peer Janssen <peer@baden-online.de>\n" 
    512                 "  Mohammed Adnene Trojette <adn@diwi.org>\n" 
    513                 "\n" 
    514                 "Spanish translation:\n" 
    515                 "  Mario Palomo Torrero <mpalomo@ihman.com>\n" 
    516                 "\n" 
    517                 "Swedish translation:\n" 
    518                 "  Daniel Nylander <po@danielnylander.se>\n" 
    519                 "\n" 
    520                 "German translation:\n" 
    521                 "  Philipp Kern <phil@0x539.de>\n" 
    522                 "  Armin Burgmeier <armin@0x539.de>\n" 
    523                 "  Thomas Glatt <tom@0x539.de>\n" 
    524                 ); 
    525  
    526         dlg.set_license( 
    527                 "This program is free software; you can redistribute it\n" 
    528                 "and/or modify it under the terms of the GNU General Public\n" 
    529                 "License as published by the Free Software Foundation; either\n" 
    530                 "version 2 of the License, or (at your option) any later\n" 
    531                 "version.\n" 
    532                 "\n" 
    533                 "This program is distributed in the hope that it will be\n" 
    534                 "useful, but WITHOUT ANY WARRANTY; without even the implied\n" 
    535                 "warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" 
    536                 "PURPOSE.  See the GNU General Public License for more details." 
    537         ); 
    538         dlg.run(); 
    539 } 
    540  
    541 #if 0 
    542 void Gobby::Window::on_folder_document_add(DocWindow& window) 
    543 { 
    544         // Select newly created page if not automatically opened 
    545         if(!m_document_settings.get_automatically_opened(window.get_info() )) 
    546         { 
    547                 m_folder.set_current_page(m_folder.page_num(window) ); 
    548                 window.grab_focus(); 
    549         } 
    550  
    551         // Unset modifified flag when locally opened 
    552         if(!m_local_file_path.empty()) 
    553         { 
    554                 gtk_text_buffer_set_modified( 
    555                         GTK_TEXT_BUFFER(window.get_document().get_buffer()), FALSE); 
    556         } 
    557  
    558         if(m_folder.get_n_pages() == 1) 
    559         { 
    560                 // There have not been any documents before 
    561                 m_application_state.modify( 
    562                         APPLICATION_DOCUMENT, 
    563                         APPLICATION_NONE 
    564                 ); 
    565  
    566                 m_folder.set_show_tabs(false); 
    567         } 
    568         else 
    569         { 
    570                 m_folder.set_show_tabs(true); 
    571         } 
    572 } 
    573  
    574 void Gobby::Window::on_folder_document_remove(DocWindow& window) 
    575 { 
    576         // Update title bar if there are no more documents left 
    577         // (folder_tab_switched is not emitted in this case) 
    578         if(m_folder.get_n_pages() == 0) 
    579         { 
    580                 update_title_bar(); 
    581  
    582                 m_application_state.modify( 
    583                         APPLICATION_NONE, 
    584                         APPLICATION_DOCUMENT 
    585                 ); 
    586         } 
    587         else if(m_folder.get_n_pages() == 1) 
    588         { 
    589                 m_folder.set_show_tabs(false); 
    590         } 
    591 } 
    592  
    593 void Gobby::Window::on_folder_document_close_request(DocWindow& window) 
    594 { 
    595         close_document(window); 
    596 } 
    597  
    598 void Gobby::Window::on_folder_tab_switched(DocWindow& window) 
    599 { 
    600         // Update title bar 
    601         update_title_bar(); 
    602 } 
    603 #endif 
    604  
    605 void Gobby::Window::on_settings_document_insert(LocalDocumentInfo& info) 
    606 { 
    607         // Set the path from which this document was opened, 
    608         // if we opened that file. 
    609         if(info.get_owner() == &m_buffer->get_self() && 
    610            !m_local_file_path.empty() ) 
    611         { 
    612                 // " " is newly created, so we do not need a path 
    613                 if(m_local_file_path != " ") 
    614                 { 
    615                         m_document_settings.set_path(info, m_local_file_path); 
    616                 } 
    617  
    618                 m_document_settings.set_original_encoding( 
    619                         info, 
    620                         m_local_encoding 
    621                 ); 
    622         } 
    623         else 
    624         { 
    625                 // File was opened remotely, so we do not know anything 
    626                 // about the original encoding, so assume it's UTF-8. 
    627                 m_document_settings.set_original_encoding(info, "UTF-8"); 
    628         } 
    629 } 
    630  
    631 void Gobby::Window::on_document_create() 
    632 { 
    633         EntryDialog dlg(*this, _("Create document"), _("Enter document name")); 
    634         dlg.set_check_valid_entry(true); 
    635  
    636         if(dlg.run() == Gtk::RESPONSE_OK) 
    637         { 
    638                 // " " means a newly created file 
    639                 m_local_file_path = " "; 
    640                 m_local_encoding = "UTF-8"; 
    641                 // Create new document 
    642                 m_buffer->document_create(dlg.get_text(), "UTF-8", ""); 
    643  
    644                 // Clear local path 
    645                 m_local_file_path.clear(); 
    646                 m_local_encoding.clear(); 
    647         } 
    648 } 
    649  
    650 void Gobby::Window::on_document_open() 
    651 { 
    652         // Create FileChooser 
    653         EncodingFileChooserDialog dlg( 
    654                 *this, 
    655                 _("Open new document"), 
    656                 Gtk::FILE_CHOOSER_ACTION_OPEN 
    657         ); 
    658  
    659         dlg.get_selector().set_encoding(EncodingSelector::AUTO_DETECT); 
    660  
    661         // Use the last used path for this dialog, if we have any 
    662         if(!m_last_path.empty() ) 
    663                 dlg.set_current_folder(m_last_path); 
    664  
    665         // Create buttons to close it 
    666         dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 
    667         dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); 
    668  
    669         // Allow multi selection 
    670         dlg.set_select_multiple(true); 
    671  
    672         // Show FileChooser 
    673         if(dlg.run() == Gtk::RESPONSE_OK) 
    674         { 
    675                 // Use current folder as standard folder for later dialogs 
    676                 m_last_path = dlg.get_current_folder(); 
    677                 // Open chosen files 
    678                 std::list<Glib::ustring> list = dlg.get_filenames(); 
    679                 for(std::list<Glib::ustring>::iterator iter = list.begin(); 
    680                     iter != list.end(); 
    681                     ++ iter) 
    682                 { 
    683                         open_local_file( 
    684                                 *iter, 
    685                                 dlg.get_selector().get_encoding() 
    686                         ); 
    687                 } 
    688         } 
    689 } 
    690  
    691 void Gobby::Window::on_document_save() 
    692 { 
    693         handle_document_save(); 
    694 } 
    695  
    696 bool Gobby::Window::handle_document_save() 
    697 { 
    698         // Get page 
    699         DocWindow* doc = get_current_document(); 
    700         if(doc == NULL) 
    701         { 
    702                 throw std::logic_error( 
    703                         "Gobby::Window::on_document_save:\n" 
    704                         "No document opened" 
    705                 ); 
    706         } 
    707 #if 0 
    708         // Is there already a path for this document? 
    709         std::string path = m_document_settings.get_path(doc->get_info() ); 
    710         if(!path.empty() ) 
    711         { 
    712                 // Yes, so save the document there 
    713                 save_local_file( 
    714                         *doc, 
    715                         path, 
    716                         m_document_settings.get_original_encoding( 
    717                                 doc->get_info() 
    718                         ) 
    719                 ); 
    720                 return true; 
    721         } 
    722         else 
    723         { 
    724                 // Open save as dialog otherwise 
    725                 return handle_document_save_as(); 
    726         } 
    727 #endif 
    728 } 
    729  
    730 void Gobby::Window::on_document_save_as() 
    731 { 
    732         handle_document_save_as(); 
    733 } 
    734  
    735 bool Gobby::Window::handle_document_save_as() 
    736 { 
    737         // Get page 
    738         DocWindow* doc = get_current_document(); 
    739         if(doc == NULL) 
    740         { 
    741                 throw std::logic_error( 
    742                         "Gobby::Window::on_document_save_as:\n" 
    743                         "No document opened" 
    744                 ); 
    745         } 
    746  
    747         // Setup dialog 
    748         EncodingFileChooserDialog dlg( 
    749                 *this, 
    750                 _("Save current document"), 
    751                 Gtk::FILE_CHOOSER_ACTION_SAVE 
    752         ); 
    753  
    754 #if 0 
    755         // TODO: Preselect document's encoding 
    756         dlg.get_selector().set_encoding( 
    757                 m_document_settings.get_original_encoding(doc->get_info()) 
    758         ); 
    759  
    760 #ifdef GTKMM_GEQ_28 
    761         dlg.set_do_overwrite_confirmation(true); 
    762 #endif 
    763  
    764         std::string path = m_document_settings.get_path(doc->get_info() ); 
    765  
    766         // Does the document have already a path? 
    767         if(!path.empty() ) 
    768         { 
    769                 // Yes, so set it as filename 
    770                 dlg.set_filename(path); 
    771         } 
    772         else 
    773         { 
    774                 // No, so use the last path a filesel dialog was closed with 
    775                 if(!m_last_path.empty() ) 
    776                         dlg.set_current_folder(m_last_path); 
    777  
    778                 // Set current title as proposed file name 
    779                 dlg.set_current_name(doc->get_info().get_title() ); 
    780         } 
    781  
    782         // Add buttons to close the dialog 
    783         dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 
    784         dlg.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); 
    785         dlg.set_default_response(Gtk::RESPONSE_OK); 
    786  
    787         if(dlg.run() == Gtk::RESPONSE_OK) 
    788         { 
    789                 // Use current folder as standard folder for other dialogs 
    790                 m_last_path = dlg.get_current_folder(); 
    791                 // Save document 
    792                 save_local_file( 
    793                         *doc, 
    794                         dlg.get_filename(), 
    795                         dlg.get_selector().get_encoding() 
    796                 ); 
    797                 return true; 
    798         } 
    799         return false; 
    800 #endif 
    801 } 
    802  
    803 void Gobby::Window::on_document_close() 
    804 { 
    805         // Get current page 
    806         Widget* page = m_folder.get_nth_page(m_folder.get_current_page() ); 
    807         // Close it 
    808         close_document(*static_cast<DocWindow*>(page) ); 
    809 } 
    810  
    811 void Gobby::Window::on_edit_search() 
    812 { 
    813         if(m_finddialog.get() == NULL) 
    814                 m_finddialog.reset(new FindDialog(*this)); 
    815  
    816         m_finddialog->set_search_only(true); 
    817         m_finddialog->present(); 
    818 } 
    819  
    820 void Gobby::Window::on_edit_search_replace() 
    821 { 
    822         if(m_finddialog.get() == NULL) 
    823                 m_finddialog.reset(new FindDialog(*this)); 
    824  
    825         m_finddialog->set_search_only(false); 
    826         m_finddialog->present(); 
    827 } 
    828  
    829 void Gobby::Window::on_edit_goto_line() 
    830 { 
    831         if(m_gotodialog.get() == NULL) 
    832                 m_gotodialog.reset(new GotoDialog(*this)); 
    833  
    834         m_gotodialog->present(); 
    835 } 
    836  
    837 void Gobby::Window::on_edit_preferences() 
    838 { 
    839         if(m_preferences_dlg.get() == NULL) 
    840                 m_preferences_dlg.reset( 
    841                         new PreferencesDialog(*this, m_preferences)); 
    842  
    843         m_preferences_dlg->present(); 
    844 } 
    845  
    846 void Gobby::Window::on_user_set_password() 
    847 { 
    848         // Build password dialog with info 
    849         PasswordDialog dlg(*this, _("Set user password") ); 
    850         dlg.set_info(_( 
    851                 "Set a user password for your user account. When you try to " 
    852                 "login next time with this user, you will be prompted for your " 
    853                 "password." 
    854         ) ); 
    855  
    856         // Run it 
    857         if(dlg.run() == Gtk::RESPONSE_OK) 
    858         { 
    859                 dynamic_cast<ClientBuffer*>( 
    860                         m_buffer.get() )->set_password(dlg.get_password() ); 
    861         } 
    862 } 
    863  
    864 void Gobby::Window::on_user_set_colour() 
    865 { 
    866         // Simple ColorSelectionDialog 
    867         ColorSelectionDialog dlg(m_config.get_root() ); 
    868         const obby::user& user = m_buffer->get_self(); 
    869         Gdk::Color color; 
    870  
    871         color.set_red(user.get_colour().get_red() * 65535 / 255); 
    872         color.set_green(user.get_colour().get_green() * 65535 / 255); 
    873         color.set_blue(user.get_colour().get_blue() * 65535 / 255); 
    874         dlg.get_colorsel()->set_current_color(color); 
    875  
    876         // Run it 
    877         if(dlg.run() == Gtk::RESPONSE_OK) 
    878         { 
    879                 // Convert GDK color to obby color, set new color 
    880                 Gdk::Color color = dlg.get_colorsel()->get_current_color(); 
    881                 m_buffer->set_colour( 
    882                         obby::colour( 
    883                                 color.get_red() * 255 / 65535, 
    884                                 color.get_green() * 255 / 65535, 
    885                                 color.get_blue() * 255 / 65535 
    886                         ) 
    887                 ); 
    888         } 
    889 } 
    890  
    891 void Gobby::Window::on_view_preferences() 
    892 { 
    893 #if 0 
    894         // Get current page 
    895         DocWindow* doc = get_current_document(); 
    896         if(doc == NULL) 
    897         { 
    898                 throw std::logic_error( 
    899                         "Gobby::Window::on_view_preferences:\n" 
    900                         "No window opened" 
    901                 ); 
    902         } 
    903  
    904         // Add preferences dialog 
    905         PreferencesDialog dlg(*this, 
    906                 doc->get_preferences(), 
    907                 m_lang_manager, 
    908                 true 
    909         ); 
    910  
    911         // Label text 
    912         obby::format_string str(_( 
    913                 "These preferences affect only the currently active document " 
    914                 "\"%0%\". If you want to change global preferences, use the " 
    915                 "preferences menu item in the \"Edit\" menu." 
    916         ) ); 
    917  
    918         // Get title 
    919         str << doc->get_info().get_suffixed_title(); 
    920  
    921         // Info label 
    922         Gtk::Label lbl_info(str.str() ); 
    923  
    924         // TODO: How to get the label to use all available space? 
    925         lbl_info.set_line_wrap(true); 
    926         lbl_info.set_alignment(Gtk::ALIGN_LEFT); 
    927  
    928         // Add it into the dialog 
    929         dlg.get_vbox()->pack_start(lbl_info, Gtk::PACK_SHRINK); 
    930         dlg.get_vbox()->reorder_child(lbl_info, 0); // Push to top of dialog 
    931         lbl_info.show(); 
    932  
    933         // Show the dialog 
    934         if(dlg.run() == Gtk::RESPONSE_OK) 
    935         { 
    936                 // Apply new preferences to the document 
    937                 Preferences prefs; 
    938                 dlg.set(prefs); 
    939                 doc->set_preferences(prefs); 
    940         } 
    941 #endif 
    942 } 
    943  
    944 void 
    945 Gobby::Window::on_view_language(GtkSourceLanguage* language) 
    946 { 
    947         // Set language of current document 
    948         DocWindow* doc = get_current_document(); 
    949         if(doc == NULL) 
    950         { 
    951                 throw std::logic_error( 
    952                         "Gobby::Window::on_view_language:\n" 
    953                         "No window opened" 
    954                 ); 
    955         } 
    956  
    957         doc->set_language(language); 
    958 } 
    959  
    960 void Gobby::Window::on_window_chat() 
    961 { 
    962 } 
    963  
    964 void Gobby::Window::on_quit() 
    965 { 
    966         if(on_delete_event(NULL) == false) 
    967         { 
    968                 // Quit session 
    969                 if(m_buffer.get() != NULL && m_buffer->is_open() ) 
    970                         obby_end(); 
    971                 // End program 
    972                 Gtk::Main::quit(); 
    973         } 
    974 } 
    975  
    976 void Gobby::Window::on_obby_close() 
    977 { 
    978         display_error(_("Connection lost")); 
    979         on_session_quit(); 
    980 } 
    981  
    982 /*void Gobby::Window::on_obby_encrypted() 
    983 { 
    984         display_error("Connection now encrypted"); 
    985 }*/ 
    986  
    987 void Gobby::Window::on_obby_user_join(const obby::user& user) 
    988 { 
    989         // Tell user join to components 
    990         //m_folder.obby_user_join(user); 
    991 } 
    992  
    993 void Gobby::Window::on_obby_user_part(const obby::user& user) 
    994 { 
    995         // Tell user part to components 
    996         //m_folder.obby_user_part(user); 
    997 } 
    998  
    999 void Gobby::Window::on_obby_user_colour(const obby::user& user) 
    1000 { 
    1001         //m_folder.obby_user_colour(user); 
    1002 } 
    1003  
    1004 void Gobby::Window::on_obby_user_colour_failed() 
    1005 { 
    1006         display_error(_("Colour change failed: Colour already in use") ); 
    1007 } 
    1008  
    1009 void Gobby::Window::on_obby_document_insert(DocumentInfo& document) 
    1010 { 
    1011         LocalDocumentInfo& local_doc = 
    1012                 dynamic_cast<LocalDocumentInfo&>(document); 
    1013  
    1014         //m_folder.obby_document_insert(local_doc); 
    1015 } 
    1016  
    1017 void Gobby::Window::on_obby_document_remove(DocumentInfo& document) 
    1018 { 
    1019         LocalDocumentInfo& local_doc = 
    1020                 dynamic_cast<LocalDocumentInfo&>(document); 
    1021  
    1022         //m_folder.obby_document_remove(local_doc); 
    1023 } 
    1024  
    1025 void Gobby::Window::on_ipc_file(const std::string& file) 
    1026 { 
    1027         // Open local file directly if buffer is open 
    1028         if(m_buffer.get() != NULL && m_buffer->is_open() ) 
    1029         { 
    1030                 open_local_file(file, EncodingSelector::AUTO_DETECT); 
    1031                 return; 
    1032         } 
    1033  
    1034         // Otherwise, push the file back into the file queue. 
    1035         bool was_empty = m_file_queue.empty(); 
    1036         m_file_queue.push(file); 
    1037  
    1038         // If the file queue is empty, open a new session. The queue will 
    1039         // be cleared either if the session has finished (either with success 
    1040         // or not). 
    1041  
    1042         // TODO: Find a better condition for when the session is currently 
    1043         // being opened. Checking whether the file queue is empty is not 
    1044         // good because the user might manually open a session while an 
    1045         // IPC file request comes in... 
    1046         if(was_empty) 
    1047         { 
    1048                 session_open(false); 
    1049         } 
    1050 } 
    1051  
    1052 Gobby::DocWindow* Gobby::Window::get_current_document() 
    1053 { 
    1054         if(m_folder.get_n_pages() == 0) return NULL; 
    1055  
    1056         Widget* page = m_folder.get_nth_page(m_folder.get_current_page() ); 
    1057         return static_cast<DocWindow*>(page); 
    1058 } 
    1059  
    1060 void Gobby::Window::apply_preferences() 
    1061 { 
    1062 } 
    1063  
    1064 void Gobby::Window::update_title_bar() 
    1065 { 
    1066         // No document 
    1067         if(m_folder.get_n_pages() == 0) 
    1068         { 
    1069                 set_title("Gobby"); 
    1070                 return; 
    1071         } 
    1072  
    1073         // Get currently active document 
    1074         const DocWindow& window = *get_current_document(); 
    1075         // Get title of current document 
    1076         const Glib::ustring& file = window.get_title(); 
    1077         // Get path of current document 
    1078         Glib::ustring path;// = m_document_settings.get_path(window.get_info() ); 
    1079  
    1080         // Show path in title, if we know it 
    1081         if(!path.empty() ) 
    1082         { 
    1083                 // Replace home dir by ~ 
    1084                 Glib::ustring home = Glib::get_home_dir(); 
    1085                 if(path.compare(0, home.length(), home) == 0) 
    1086                         path.replace(0, home.length(), "~"); 
    1087  
    1088                 // Set title with file and path 
    1089                 obby::format_string title_str("%0% (%1%)"); 
    1090                 title_str << file << Glib::path_get_dirname(path); 
    1091                 set_title(title_str.str() ); 
    1092         } 
    1093         else 
    1094         { 
    1095                 // Path not known: Set title with file only 
    1096                 obby::format_string title_str("%0%"); 
    1097                 title_str << file; 
    1098                 set_title(title_str.str() ); 
    1099         } 
    1100 } 
    1101  
    1102 namespace 
    1103 { 
    1104         // convert2unix converts a given string from any special line endings 
    1105         // (DOS or old-style Macintosh) to Unix line endings. It does no 
    1106         // book-keeping about the encountered endings but ensures that no 
    1107         // CR characters are left in the string. 
    1108         void convert2unix(std::string& str) 
    1109         { 
    1110                 for(std::string::size_type i = 0; i < str.length(); ++ i) 
    1111                         // Convert DOS CRLF to a single LF 
    1112                         if(i < str.length() - 1 && 
    1113                            str[i] == '\r' && str[i+1] == '\n') 
    1114                                 str.erase(i, 1); 
    1115                         // Convert Macintosh CR to LF 
    1116                         else if(str[i] == '\r') 
    1117                                 str[i] = '\n'; 
    1118         } 
    1119 } 
    1120  
    1121 bool Gobby::Window::session_join(bool initial_dialog) 
    1122 { 
    1123         if(m_buffer.get() && m_buffer->is_open() ) 
    1124         { 
    1125                 throw std::logic_error( 
    1126                         "Gobby::Window::session_join:\n" 
    1127                         "Buffer is already open" 
    1128                 ); 
    1129         } 
    1130  
    1131         if(m_join_dlg.get() == NULL) 
    1132         { 
    1133 #ifndef WITH_ZEROCONF 
    1134                 m_join_dlg.reset( 
    1135                         new JoinDialog(*this, m_config.get_root()["session"]) 
    1136                 ); 
    1137 #else 
    1138                 m_join_dlg.reset( 
    1139                         new JoinDialog( 
    1140                                 *this, 
    1141                                 m_config.get_root()["session"], 
    1142                                 m_zeroconf.get() 
    1143                         ) 
    1144                 ); 
    1145 #endif 
    1146         } 
    1147  
    1148         int response = Gtk::RESPONSE_OK; 
    1149         if(initial_dialog) response = m_join_dlg->run(); 
    1150  
    1151         while(response == Gtk::RESPONSE_OK) 
    1152         { 
    1153                 // Read settings 
    1154                 Glib::ustring host = m_join_dlg->get_host(); 
    1155                 unsigned int port = m_join_dlg->get_port(); 
    1156                 Glib::ustring name = m_join_dlg->get_name(); 
    1157                 Gdk::Color color = m_join_dlg->get_color(); 
    1158  
    1159                 if(session_join_impl(host, port, name, color) ) 
    1160                         break; 
    1161                 else 
    1162                         response = m_join_dlg->run(); 
    1163         } 
    1164  
    1165         m_join_dlg->hide(); 
    1166         return (m_buffer.get() && m_buffer->is_open() ); 
    1167 } 
    1168  
    1169 bool Gobby::Window::session_open(bool initial_dialog) 
    1170 { 
    1171         if(m_buffer.get() && m_buffer->is_open() ) 
    1172         { 
    1173                 throw std::logic_error( 
    1174                         "Gobby::Window::session_open:\n" 
    1175                         "Buffer is already open" 
    1176                 ); 
    1177         } 
    1178  
    1179         if(m_host_dlg.get() == NULL) 
    1180         { 
    1181                 m_host_dlg.reset( 
    1182                         new HostDialog(*this, m_config.get_root()["session"]) 
    1183                 ); 
    1184         } 
    1185  
    1186         int response = Gtk::RESPONSE_OK; 
    1187         if(initial_dialog) response = m_host_dlg->run(); 
    1188  
    1189         while(response == Gtk::RESPONSE_OK) 
    1190         { 
    1191                 // Read setting 
    1192                 unsigned int port = m_host_dlg->get_port(); 
    1193                 Glib::ustring name = m_host_dlg->get_name(); 
    1194                 Gdk::Color color = m_host_dlg->get_color(); 
    1195                 Glib::ustring password = m_host_dlg->get_password(); 
    1196                 Glib::ustring session = m_host_dlg->get_session(); 
    1197  
    1198                 if(session_open_impl(port, name, color, password, session) ) 
    1199                         break; 
    1200                 else 
    1201                         response = m_host_dlg->run(); 
    1202         } 
    1203  
    1204         // Process file queue (files that have been queued for opening 
    1205         // after session creation). 
    1206         m_host_dlg->hide(); 
    1207         while(!m_file_queue.empty() ) 
    1208         { 
    1209                 std::string str = m_file_queue.front(); 
    1210                 m_file_queue.pop(); 
    1211  
    1212                 if(m_buffer.get() && m_buffer->is_open() ) 
    1213                         open_local_file(str, EncodingSelector::AUTO_DETECT); 
    1214         } 
    1215  
    1216         return (m_buffer.get() && m_buffer->is_open() ); 
    1217 } 
    1218  
    1219 bool Gobby::Window::session_join_impl(const Glib::ustring& host, 
    1220                                       unsigned int port, 
    1221                                       const Glib::ustring& name, 
    1222                                       const Gdk::Color& color) 
    1223 { 
    1224         JoinProgressDialog prgdlg( 
    1225                 *this, 
    1226                 m_config.get_root()["session"], 
    1227                 host, 
    1228                 port, 
    1229                 name, 
    1230                 color 
    1231         ); 
    1232  
    1233         if(prgdlg.run() == Gtk::RESPONSE_OK) 
    1234         { 
    1235                 prgdlg.hide(); 
    1236  
    1237                 // Get buffer 
    1238                 std::auto_ptr<ClientBuffer> buffer = prgdlg.get_buffer(); 
    1239  
    1240                 buffer->set_enable_keepalives(true); 
    1241  
    1242                 buffer->close_event().connect( 
    1243                         sigc::mem_fun(*this, &Window::on_obby_close) ); 
    1244  
    1245                 obby::format_string str(_("Connected to %0%:%1%") ); 
    1246                 str << host << port; 
    1247  
    1248                 // Start session 
    1249                 m_buffer = buffer; 
    1250                 obby_start(); 
    1251  
    1252                 // Session is open, no need to reshow join dialog 
    1253                 return true; 
    1254         } 
    1255         else 
    1256         { 
    1257                 return false; 
    1258         } 
    1259 } 
    1260  
    1261 bool Gobby::Window::session_open_impl(unsigned int port, 
    1262                                       const Glib::ustring& name, 
    1263                                       const Gdk::Color& color, 
    1264                                       const Glib::ustring& password, 
    1265                                       const Glib::ustring& session) 
    1266 { 
    1267         // Set up host with hostprogressdialog 
    1268         HostProgressDialog prgdlg(*this, m_config, port, name, color, session); 
    1269  
    1270         if(prgdlg.run() == Gtk::RESPONSE_OK) 
    1271         { 
    1272                 prgdlg.hide(); 
    1273  
    1274                 // Get buffer 
    1275                 std::auto_ptr<HostBuffer> buffer = 
    1276                         prgdlg.get_buffer(); 
    1277  
    1278                 // Set password 
    1279                 buffer->set_global_password(password); 
    1280                 buffer->set_enable_keepalives(true); 
    1281 #ifdef WITH_ZEROCONF 
    1282                 // Publish the newly created session via Zeroconf 
    1283                 // if Howl is not deactivated 
    1284                 if(m_zeroconf.get() ) 
    1285                         m_zeroconf->publish(name, port); 
    1286 #endif 
    1287  
    1288                 obby::format_string str(_("Serving on port %0%") ); 
    1289                 str << port; 
    1290  
    1291                 m_buffer = buffer; 
    1292  
    1293                 // Start session 
    1294                 obby_start(); 
    1295                 // Remember session file 
    1296                 m_prev_session = Glib::filename_from_utf8(session); 
    1297                 // Session is open, no need to reshow host dialog 
    1298                 return true; 
    1299         } 
    1300         else 
    1301         { 
    1302                 // Session opening did not succeed 
    1303                 return false; 
    1304         } 
    1305 } 
    1306  
    1307 void Gobby::Window::open_local_file(const Glib::ustring& file, 
    1308                                     const std::string& encoding) 
    1309 { 
    1310 #if 0 
    1311         try 
    1312         { 
    1313                 // Set local file path for the document_insert callback 
    1314                 m_local_file_path = file; 
    1315                 m_local_encoding = encoding; 
    1316  
    1317                 std::string utf8_content; 
    1318                 if(encoding == EncodingSelector::AUTO_DETECT) 
    1319                 { 
    1320                         std::string detected_encoding; 
    1321  
    1322                         utf8_content = Encoding::convert_to_utf8( 
    1323                                         Glib::file_get_contents(file), 
    1324                                         detected_encoding 
    1325                         ); 
    1326  
    1327                         m_local_encoding = detected_encoding; 
    1328                 } 
    1329                 else 
    1330                 { 
    1331                         utf8_content = Glib::convert( 
    1332                                 Glib::file_get_contents(file), 
    1333                                 "UTF-8", 
    1334                                 encoding 
    1335                         ); 
    1336                 } 
    1337  
    1338                 convert2unix(utf8_content); 
    1339  
    1340                 m_buffer->document_create( 
    1341                         Glib::path_get_basename(file), "UTF-8", utf8_content 
    1342                 ); 
    1343  
    1344                 // Clear local path 
    1345                 m_local_file_path.clear(); 
    1346                 m_local_encoding.clear(); 
    1347         } 
    1348         catch(Glib::Exception& e) 
    1349         { 
    1350                 // Show errors while opening the file (e.g. if it doesn't exist) 
    1351                 display_error(e.what() ); 
    1352         } 
    1353 #endif 
    1354 } 
    1355  
    1356 void Gobby::Window::save_local_file(DocWindow& doc, 
    1357                                     const Glib::ustring& file, 
    1358                                     const std::string& encoding) 
    1359 { 
    1360 #if 0 
    1361         try 
    1362         { 
    1363                 Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_file(file, "w"); 
    1364                 channel->set_encoding(""); 
    1365  
    1366                 // Save content into file 
    1367                 std::string conv_content = doc.get_content().raw(); 
    1368                 if(encoding != "UTF-8") 
    1369                 { 
    1370                         conv_content = Glib::convert( 
    1371                                 conv_content, 
    1372                                 encoding, 
    1373                                 "UTF-8" 
    1374                         ); 
    1375                 } 
    1376  
    1377                 channel->write(conv_content); 
    1378                 channel->close(); 
    1379  
    1380                 m_document_settings.set_path(doc.get_info(), file); 
    1381  
    1382                 m_document_settings.set_original_encoding( 
    1383                         doc.get_info(), 
    1384                         encoding 
    1385                 ); 
    1386  
    1387                 // Update title bar according to new path 
    1388                 update_title_bar(); 
    1389                 // Unset modifified flag 
    1390                 gtk_text_buffer_set_modified( 
    1391                         GTK_TEXT_BUFFER(doc.get_text_buffer()), 
    1392                         FALSE); 
    1393         } 
    1394         catch(Glib::Error& e) 
    1395         { 
    1396                 display_error(e.what() ); 
    1397         } 
    1398         catch(std::exception& e) 
    1399         { 
    1400                 display_error(e.what() ); 
    1401         } 
    1402 #endif 
    1403 } 
    1404  
    1405 void Gobby::Window::close_document(DocWindow& window) 
    1406 { 
    1407 #if 0 
    1408         /* Cannot unsubscribe when not subscribed (e.g. unsubscription request 
    1409          * has already been sent. */ 
    1410         if(window.get_info().get_subscription_state() != 
    1411            Gobby::LocalDocumentInfo::SUBSCRIBED) 
    1412         { 
    1413                 return; 
    1414         } 
    1415  
    1416         // Check for the document being modified 
    1417         if(window.get_modified() ) 
    1418         { 
    1419                 // Setup confirmation strings 
    1420                 obby::format_string primary_str( 
    1421                         _("Save changes to document \"%0%\" before closing?") 
    1422                 ); 
    1423  
    1424                 // TODO: Tell that resubscription is not possible when the 
    1425                 // session is closed (unless you are host). 
    1426  
    1427                 std::string secondary_str; 
    1428                 if(m_buffer.get() != NULL && m_buffer->is_open() ) 
    1429                 { 
    1430                         secondary_str = _( 
    1431                                 "If you don't save, changes will be " 
    1432                                 "discarded, but may still be retrieved if " 
    1433                                 "you re-subscribe to the document as long " 
    1434                                 "as the session remains open." 
    1435                         ); 
    1436                 } 
    1437                 else 
    1438                 { 
    1439                         secondary_str = _( 
    1440                                 "If you don't save, changes will be " 
    1441                                 "discarded." 
    1442                         ); 
    1443                 } 
    1444  
    1445                 primary_str << window.get_info().get_suffixed_title(); 
    1446  
    1447                 // Setup dialog 
    1448                 Gtk::MessageDialog dlg(*this, primary_str.str(), false, 
    1449                         Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true); 
    1450  
    1451                 // Set secondary text 
    1452                 dlg.set_secondary_text(secondary_str); 
    1453  
    1454                 // Add button to allow the user to save the dialog 
    1455                 dlg.add_button(_("Close without saving"), Gtk::RESPONSE_REJECT); 
    1456                 dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 
    1457                 dlg.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT)-> 
    1458                         grab_focus(); 
    1459  
    1460                 // Show the dialog 
    1461                 int result = dlg.run(); 
    1462                 // Hide it because we cannot back up to it if a later dialog 
    1463                 // is cancelled. 
    1464                 dlg.hide(); 
    1465  
    1466                 switch(result) 
    1467                 { 
    1468                 case Gtk::RESPONSE_REJECT: 
    1469                         /* Close the document */ 
    1470                         break; 
    1471                 case Gtk::RESPONSE_ACCEPT: 
    1472                         /* Save the document before closing it */ 
    1473                         m_folder.set_current_page(m_folder.page_num(window) ); 
    1474                         if(!handle_document_save() ) 
    1475                                 return; 
    1476                         break; 
    1477                 case Gtk::RESPONSE_CANCEL: 
    1478                 case Gtk::RESPONSE_DELETE_EVENT: 
    1479                         /* Do not close the document */ 
    1480                         return; 
    1481                         break; 
    1482                 default: 
    1483                         throw std::logic_error("Gobby::Window::close_document"); 
    1484                         break; 
    1485                 } 
    1486         } 
    1487  
    1488         window.get_info().unsubscribe(); 
    1489 #endif 
    1490 } 
    1491  
    1492 void Gobby::Window::display_error(const Glib::ustring& message, 
    1493                                   const Gtk::MessageType type) 
    1494 { 
    1495         Gtk::MessageDialog dlg(*this, message, false, type, 
    1496                                Gtk::BUTTONS_OK, true); 
    1497         dlg.run(); 
    1498 }