GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

main.hh

Go to the documentation of this file.
00001 /* GFC-Core: GTK+ Foundation Classes (Core Library) 00002 * Copyright (C) 2003-2004 The GFC Development Team. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00023 00024 #ifndef GFC_G_MAIN_HH 00025 #define GFC_G_MAIN_HH 00026 00027 #ifndef GFC_OBJECT_HH 00028 #include <gfc/object.hh> 00029 #endif 00030 00031 #ifndef GFC_G_IOCHANNEL_HH 00032 #include <gfc/glib/iochannel.hh> 00033 #endif 00034 00035 #ifndef SIGCXX_SIGCXX_H 00036 #include <sigc++/sigc++.h> 00037 #endif 00038 00039 namespace GFC { 00040 00041 namespace G { 00042 00043 class TimeVal; 00044 00045 enum 00046 { 00047 PRIORITY_HIGH = G_PRIORITY_HIGH, 00049 00050 PRIORITY_DEFAULT = G_PRIORITY_DEFAULT, 00054 00055 PRIORITY_HIGH_IDLE = G_PRIORITY_HIGH_IDLE, 00061 00062 PRIORITY_DEFAULT_IDLE = G_PRIORITY_DEFAULT_IDLE, 00065 00066 PRIORITY_LOW = G_PRIORITY_LOW 00068 }; 00069 00072 00073 void get_current_time(TimeVal& timeval); 00076 00078 00083 00084 class MainContext : public GFC::Object 00085 { 00086 MainContext(const MainContext&); 00087 MainContext& operator=(const MainContext&); 00088 00089 GMainContext *context_; 00090 00091 public: 00094 00095 MainContext(); 00097 00098 explicit MainContext(GMainContext *context, bool owns_reference = true); 00105 00106 virtual ~MainContext(); 00108 00110 00111 static Pointer<MainContext> get_default(); 00116 00119 00120 GMainContext* g_main_context() const; 00122 00123 operator GMainContext* () const; 00125 00126 bool pending() const; 00129 00133 00134 virtual void ref(); 00136 00137 virtual void unref(); 00144 00145 bool iteration(bool may_block); 00155 00157 }; 00158 00188 00189 class MainLoop : public GFC::Object 00190 { 00191 MainLoop(const MainLoop&); 00192 MainLoop& operator=(const MainLoop&); 00193 00194 GMainLoop *loop_; 00195 00196 public: 00199 00200 MainLoop(bool is_running = false); 00206 00207 MainLoop(MainContext& context, bool is_running = false); 00214 00215 virtual ~MainLoop(); 00217 00221 00222 GMainLoop* g_main_loop() const; 00224 00225 operator GMainLoop* () const; 00227 00228 bool is_running() const; 00231 00232 Pointer<MainContext> get_context() const; 00235 00237 00238 static int depth(); 00246 00249 00250 virtual void ref(); 00252 00253 virtual void unref(); 00260 00261 void run(); 00265 00266 void quit(); 00268 00270 }; 00271 00274 00275 class Source : public Trackable 00276 { 00277 Source(const Source&); 00278 Source& operator=(const Source&); 00279 00280 GSource *source_; 00281 00282 public: 00285 00286 Source(GSource *source, bool owns_reference = true); 00293 00294 virtual ~Source(); 00296 00300 00301 GSource* g_source() const; 00303 00304 operator GSource* () const; 00306 00307 int get_priority() const; 00310 00311 bool get_can_recurse() const; 00314 00315 unsigned int get_id() const; 00318 00319 Pointer<MainContext> get_context() const; 00324 00325 void get_current_time(TimeVal& timeval); 00332 00333 bool is_attached(G::MainContext& context) const; 00336 00340 00341 virtual void ref(); 00343 00344 virtual void unref(); 00351 00352 unsigned int attach(MainContext *context = 0); 00356 00357 void destroy(); 00360 00361 void set_priority(int priority); 00368 00369 void set_can_recurse(bool can_recurse); 00376 00378 }; 00379 00382 00383 00384 class ChildWatchSource : public Source 00385 { 00386 ChildWatchSource(const ChildWatchSource&); 00387 ChildWatchSource& operator=(const ChildWatchSource&); 00388 00389 public: 00390 typedef sigc::slot<void, GPid, int> WatchSlot; 00398 00401 00402 ChildWatchSource(GPid pid); 00415 00416 ChildWatchSource(GPid pid, const WatchSlot& slot); 00427 00431 00432 void set_callback(const WatchSlot& slot); 00435 00437 }; 00438 00446 00447 class TimeoutSource : public Source 00448 { 00449 TimeoutSource(const TimeoutSource&); 00450 TimeoutSource& operator=(const TimeoutSource&); 00451 00452 public: 00453 typedef sigc::slot<bool> TimeoutSlot; 00460 00463 00464 TimeoutSource(unsigned int interval); 00471 00472 TimeoutSource(const TimeoutSlot& slot, unsigned int interval); 00479 00483 00484 void set_callback(const TimeoutSlot& slot); 00487 00489 }; 00490 00497 00498 class IdleSource : public Source 00499 { 00500 IdleSource(const IdleSource&); 00501 IdleSource& operator=(const IdleSource&); 00502 00503 public: 00504 typedef sigc::slot<bool> IdleSlot; 00511 00514 00515 IdleSource(); 00520 00521 IdleSource(const IdleSlot& slot); 00528 00532 00533 void set_callback(const IdleSlot& slot); 00536 00538 }; 00539 00547 00548 class IOSource : public Source 00549 { 00550 IOSource(const IOSource&); 00551 IOSource& operator=(const IOSource&); 00552 00553 public: 00554 typedef sigc::slot<bool, IOChannel&, IOConditionField> IOSlot; 00563 00566 00567 IOSource(G::IOChannel& channel, G::IOConditionField condition); 00575 00576 IOSource(G::IOChannel& channel, G::IOConditionField condition, const IOSlot& slot); 00584 00588 00589 void set_callback(const IOSlot& slot); 00592 00594 }; 00595 00598 00599 class ChildWatchSignal : public sigc::trackable 00600 { 00601 public: 00602 typedef sigc::slot<void, GPid, int> SlotType; 00604 00605 sigc::connection connect(const SlotType& slot, GPid pid, int priority = PRIORITY_DEFAULT); 00620 }; 00621 00623 00624 extern ChildWatchSignal child_watch_signal; 00625 00632 00633 class TimeoutSignal : public sigc::trackable 00634 { 00635 public: 00636 typedef sigc::slot<bool> SlotType; 00638 00639 sigc::connection connect(const SlotType& slot, unsigned int interval, int priority = PRIORITY_DEFAULT_IDLE); 00656 }; 00657 00659 00660 extern TimeoutSignal timeout_signal; 00661 00669 00670 class IdleSignal : public sigc::trackable 00671 { 00672 public: 00673 typedef sigc::slot<bool> SlotType; 00675 00676 sigc::connection connect(const SlotType& slot, int priority = PRIORITY_DEFAULT_IDLE); 00686 }; 00687 00689 00690 extern IdleSignal idle_signal; 00691 00698 00699 class IOSignal : public sigc::trackable 00700 { 00701 public: 00702 typedef sigc::slot<bool, IOChannel&, IOConditionField> SlotType; 00704 00705 sigc::connection connect(G::IOChannel& channel, G::IOConditionField condition, const SlotType& slot, int priority = PRIORITY_DEFAULT); 00712 }; 00713 00715 00716 extern IOSignal io_signal; 00717 00718 } // namespace G 00719 00720 } // namespace GFC 00721 00722 #include <gfc/glib/inline/main.inl> 00723 00724 #endif // GFC_G_MAIN_HH 00725

Generated on Tue Aug 24 00:04:56 2004 for GFC-Core by doxygen 1.3.8