]> err.no Git - libchamplain/commitdiff
the Gtk widget debutes
authorPierre-Luc Beaudoin <pierre-luc@squidy.info>
Tue, 12 Aug 2008 02:20:09 +0000 (22:20 -0400)
committerPierre-Luc Beaudoin <pierre-luc@squidy.info>
Tue, 12 Aug 2008 02:20:09 +0000 (22:20 -0400)
src/champlain_defines.h
src/champlain_widget.c
src/champlain_widget.h
src/launcher.c

index b0bdc317b52b3892338b6af67c5128dc91ccbf9b..7ff4216207644de4371b8efdc6a5b42f7b99ae97 100644 (file)
@@ -23,4 +23,7 @@
 #define CHAMPLAIN_API __attribute__((visibility("default")))
 #define CHAMPLAIN_OBSOLETE_API CHAMPLAIN_API __attribute__((deprecated))
 
+typedef struct _ChamplainWidget ChamplainWidget;
+typedef struct _ChamplainWidgetClass ChamplainWidgetClass;
+
 #endif
index 0d721f88a8399061d32204cd55028ecdd7bd7cda..8e09558cff6a872554075408f238e9d88e0c3be1 100644 (file)
@@ -40,14 +40,49 @@ enum {
 
 static guint champlain_widget_signals[LAST_SIGNAL] = { 0, };
 
+#define WEBKIT_WEB_FRAME_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate))
+
+struct _ChamplainWidgetPrivate {
+    gboolean temp;
+};
+
 G_DEFINE_TYPE(ChamplainWidget, champlain_widget, GTK_TYPE_CONTAINER)
 
 static void 
 champlain_widget_class_init(ChamplainWidgetClass* champlainWidgetClass)
 {
+/*
+    GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(champlainWidget);
+    widgetClass->realize = champlain_widget_realize;
+    widgetClass->expose_event = champlain_widget_expose_event;
+    widgetClass->key_press_event = champlain_widget_key_press_event;
+    widgetClass->key_release_event = champlain_widget_key_release_event;
+    widgetClass->button_press_event = champlain_widget_button_press_event;
+    widgetClass->button_release_event = champlain_widget_button_release_event;
+    widgetClass->motion_notify_event = champlain_widget_motion_event;
+    widgetClass->scroll_event = champlain_widget_scroll_event;
+    widgetClass->size_allocate = champlain_widget_size_allocate;
+    widgetClass->popup_menu = champlain_widget_popup_menu_handler;
+    widgetClass->focus_in_event = champlain_widget_focus_in_event;
+    widgetClass->focus_out_event = champlain_widget_focus_out_event;
+    widgetClass->get_accessible = champlain_widget_get_accessible;
+
+    GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(champlainWidget);
+    containerClass->add = champlain_widget_container_add;
+    containerClass->remove = champlain_widget_container_remove;
+    containerClass->forall = champlain_widget_container_forall;
+*/
+       g_type_class_add_private(champlainWidgetClass, sizeof(ChamplainWidgetPrivate));
+
 }
 
 static void champlain_widget_init(ChamplainWidget* champlainWidget)
 {
+}
+
+GtkWidget* champlain_widget_new()
+{    
+       ChamplainWidget* widget = CHAMPLAIN_WIDGET(g_object_new(CHAMPLAIN_TYPE_WIDGET, NULL));
 
+    return GTK_WIDGET(widget);
 }
index 9f4af93815fed8f326cf0495f2cf7a05f79a7e06..c481d518f083a10f5f177ae45bc67878c34ba5a6 100644 (file)
 G_BEGIN_DECLS
 
 #define CHAMPLAIN_TYPE_WIDGET     (champlain_widget_get_type())
-#define CHAMPLAIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_WIDGET, ChamplainWidget))
+#define CHAMPLAIN_WIDGET(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_WIDGET, ChamplainWidget))
 #define CHAMPLAIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  CHAMPLAIN_TYPE_WIDGET, ChamplainWidgetClass))
 #define CHAMPLAIN_IS_WIDGET(obj)  (G_TYPE_CHECK_INSTANCE_TYPE((obj), CHAMPLAIN_TYPE_WIDGET))
 #define CHAMPLAIN_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  CHAMPLAIN_TYPE_WIDGET))
 #define CHAMPLAIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  CHAMPLAIN_TYPE_WIDGET, ChamplainWidgetClass))
 
 typedef struct _ChamplainWidgetPrivate ChamplainWidgetPrivate;
-typedef struct _ChamplainWidget ChamplainWidget;
-typedef struct _ChamplainWidgetClass ChamplainWidgetClass;
 
 struct _ChamplainWidget {
     GtkContainer parent_instance;
@@ -61,7 +59,7 @@ struct _ChamplainWidgetClass {
 CHAMPLAIN_API GType
 champlain_widget_get_type (void);
 
-CHAMPLAIN_API ChamplainWidget *
+CHAMPLAIN_API GtkWidget *
 champlain_widget_new (void);
 
 #endif
index aee0ccfcff5817139acc3e62efdb436839efad00..f07c299ab2d91e3eb1c56cb58b07c5a196aa5784 100644 (file)
  * Boston, MA 02110-1301, USA.
  */
 
-#include <stdio.h>
+#include <config.h>
 
-int main(int argc, char* argv[])
+#include <gtk/gtk.h>
+
+#include <champlain.h>
+
+/*
+ * Terminate the main loop.
+ */
+static void
+on_destroy (GtkWidget * widget, gpointer data)
 {
-   printf("Hello, world!\n");
+    gtk_main_quit ();
+}
+
+int
+main (int argc, char *argv[])
+{
+    GtkWidget *window;
+    GtkWidget *widget;
+
+    gtk_init (&argc, &argv);
+
+    /* create the main, top level, window */
+    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+    /* give the window a 20px wide border */
+    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+
+    /* give it the title */
+    gtk_window_set_title (GTK_WINDOW (window), PACKAGE " " VERSION);
+
+    /* open it a bit wider so that both the label and title show up */
+    gtk_window_set_default_size (GTK_WINDOW (window), 200, 50);
+
+
+    /* Connect the destroy event of the window with our on_destroy function
+     * When the window is about to be destroyed we get a notificaiton and
+     * stop the main GTK loop
+     */
+    g_signal_connect (G_OBJECT (window), "destroy",
+                      G_CALLBACK (on_destroy), NULL);
+
+    /* Create the "Hello, World" label  */
+    widget = champlain_widget_new ();
+
+    /* and insert it into the main window  */
+    gtk_container_add (GTK_CONTAINER (window), widget);
+
+    /* make sure that everything, window and label, are visible */
+    gtk_widget_show_all (window);
+
+    /* start the main loop */
+    gtk_main ();
 
-   return 0;
+    return 0;
 }