• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

GTKCommon.h

Go to the documentation of this file.
00001 /* some common code to make GTK+ less of a PITA.
00002  *
00003  * Copyright (C) 2011 AbiSource, Inc.
00004  * Copyright (C) 2011 Ben Martin
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 #ifndef ABI_GTK_COMMON_H
00022 #define ABI_GTK_COMMON_H
00023 
00024 #include <string>
00025 #include <list>
00026 #include <gtk/gtk.h>
00027 #include "xap_Gtk2Compat.h"
00028 #include "ut_types.h"
00029 
00030 std::string tostr( long v );
00031 std::string tostr( GtkTextView* tv );
00032 std::string tostr( GtkEntry* e );
00033 std::string getSelectedText( GtkTreeView* tv, int colnum = 0 );
00034 UT_uint32   getSelectedUInt( GtkTreeView* tv, int colnum = 0 );
00035 void selectNext( GtkTreeView* tv );
00036 void selectPrev( GtkTreeView* tv );
00037 void append( GtkComboBoxText* combo, const std::list< std::string >& data );
00038 std::string tostr( GtkComboBox* combo );
00039 void setEntry( GtkWidget* w, const std::string& v );
00040 void setEntry( GtkEntry* w, const std::string& v );
00041 void setEntry( GtkEntry* w, time_t v );
00042 void setEntry( GtkEntry* w, double v );
00043 
00044 typedef std::list< GtkTreeIter > list_gtktreeiter_t;
00049 list_gtktreeiter_t getIterList( GtkWidget* w_treeview, bool useSelection = false );
00050 
00051 void clearSelection( GtkTreeView* tv );
00052 void selectIter( GtkTreeView* tv, GtkTreeIter* iter );
00053 void scrollToIter( GtkTreeView* tv, GtkTreeIter* iter, int colnum = -1, gboolean start_editing = false );
00054 
00055 
00056 
00057 #include "xap_Dlg_FileOpenSaveAs.h"
00058 #include "ie_types.h"
00059 
00060 class UT_runDialog_AskForPathname
00061 {
00062 public:
00063 
00064     struct Filetype
00065     {
00066         std::string m_desc;
00067         std::string m_ext;
00068         UT_sint32   m_number;
00069         Filetype( std::string desc, std::string ext, UT_sint32 number )
00070         : m_desc(desc), m_ext(ext), m_number(number)
00071         {
00072         }
00073     };
00074     typedef std::list< Filetype > FiletypeList_t;
00075 
00076 
00077     UT_runDialog_AskForPathname( XAP_Dialog_Id id,
00078                                  const std::string& suggestedName = "" );
00079 
00080     int appendFiletype( const std::string desc,
00081                         const std::string ext,
00082                         UT_sint32 n = 0 );
00083     void setDefaultFiletype( const std::string desc,
00084                              const std::string ext = "" );
00085     bool run( XAP_Frame * pFrame = 0 );
00086 
00087     std::string getPath();
00088     IEFileType getType();
00089 
00090 
00091 
00092   private:
00093     std::string m_pathname;
00094     IEFileType m_ieft;
00095     XAP_Dialog_Id m_dialogId;
00096     bool m_saveAs;
00097     std::string m_suggestedName;
00098     FiletypeList_t m_filetypes;
00099     UT_sint32      m_defaultFiletype;
00100 
00101     std::string appendDefaultSuffixFunctor( std::string dialogFilename, UT_sint32 n );
00102 
00103 };
00104 
00105 
00106 #endif

Generated on Sat May 26 2012 for AbiWord by  doxygen 1.7.1