From: Pierre-Luc Beaudoin Date: Tue, 12 Aug 2008 02:20:09 +0000 (-0400) Subject: the Gtk widget debutes X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95598df474db9d6e0f7bf1adbeb5aa953f62f4e2;p=libchamplain the Gtk widget debutes --- diff --git a/src/champlain_defines.h b/src/champlain_defines.h index b0bdc31..7ff4216 100644 --- a/src/champlain_defines.h +++ b/src/champlain_defines.h @@ -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 diff --git a/src/champlain_widget.c b/src/champlain_widget.c index 0d721f8..8e09558 100644 --- a/src/champlain_widget.c +++ b/src/champlain_widget.c @@ -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); } diff --git a/src/champlain_widget.h b/src/champlain_widget.h index 9f4af93..c481d51 100644 --- a/src/champlain_widget.h +++ b/src/champlain_widget.h @@ -29,15 +29,13 @@ 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 diff --git a/src/launcher.c b/src/launcher.c index aee0ccf..f07c299 100644 --- a/src/launcher.c +++ b/src/launcher.c @@ -17,12 +17,61 @@ * Boston, MA 02110-1301, USA. */ -#include +#include -int main(int argc, char* argv[]) +#include + +#include + +/* + * 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; }