[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
problems implementing own widget
- From: Mohammed Sameer <Uniball gmx net>
- To: GTK App Devel <gtk-app-devel-list gnome org>
- Subject: problems implementing own widget
- Date: Wed, 26 Feb 2003 20:36:59 +0200
Hi all,
As the subject says, I'm having problems implementing a widget for my text editor, Everything seems OK to me, but compiling & running the test program yields nothing, I'm sure I'm missing something here.
Can anyone kindly help me or point me to the correct way ??
Best regards,
--
----------------
-- Katoob Main Developer
Linux registered user # 224950
ICQ # 58475622
FIRST make it run, THEN make it run fast "Brian Kernighan".
#include <gtk/gtk.h>
#include "katoobdocument.h"
struct _KatoobDocumentPrivate {
GtkWidget *textview;
GtkWidget *scrolledwin;
gboolean textwrap;
gboolean readonly;
gint encoding;
gchar *file;
GList *UNDO;
GList *REDO;
};
enum {
CREATED,
DESTROYED,
LAST_SIGNAL
};
static void katoob_document_class_init (KatoobDocumentClass *class);
static void katoob_document_init (KatoobDocument *document);
static gint katoob_document_signals[LAST_SIGNAL] = { 0 };
static GtkTextViewClass *parent_class;
GType
katoob_document_get_type (void)
{
static GType document_type = 0;
if (!document_type)
{
static const GTypeInfo document_info =
{
sizeof (KatoobDocumentClass),
NULL,
NULL,
(GClassInitFunc) katoob_document_class_init,
NULL,
NULL,
sizeof (KatoobDocument),
0,
(GInstanceInitFunc) katoob_document_init,
};
document_type = g_type_register_static (GTK_TYPE_NOTEBOOK, "KatoobDocument", &document_info, 0);
}
return document_type;
}
static void katoob_document_class_init (KatoobDocumentClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
klass->created = NULL;
klass->destroyed = NULL;
katoob_document_signals[CREATED] = g_signal_new ("created",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (KatoobDocumentClass, created),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
katoob_document_signals[DESTROYED] = g_signal_new ("destroyed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (KatoobDocumentClass, destroyed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
static void
katoob_document_init (KatoobDocument *document)
{
document->priv = g_new0 (KatoobDocumentPrivate, 1);
document->priv->textwrap = TRUE;
document->priv->readonly = FALSE;
document->priv->encoding = 0;
document->priv->file = NULL;
document->priv->UNDO = NULL;
document->priv->REDO = NULL;
document->priv->textview = gtk_text_view_new();
}
KatoobDocument*
katoob_document_new ()
{
KatoobDocument *document;
document = KATOOB_DOCUMENT (g_object_new (KATOOB_TYPE_DOCUMENT, NULL));
g_return_val_if_fail (document->priv != NULL, NULL);
return document;
}
GtkTextBuffer *katoob_document_get_buffer(KatoobDocument *document)
{
return gtk_text_view_get_buffer(GTK_TEXT_VIEW(document->priv->textview));
}
/* Katoob
* Copyright (c) 2002 Arabeyes, Mohammed Sameer.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef KATOOBDOCUMENT_H
#define KATOOBDOCUMENT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <gtk/gtk.h>
#define KATOOB_TYPE_DOCUMENT (katoob_document_get_type ())
#define KATOOB_DOCUMENT(obj) (GTK_CHECK_CAST ((obj), KATOOB_TYPE_DOCUMENT, KatoobDocument))
#define KATOOB_DOCUMENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), KATOOB_TYPE_DOCUMENT, KatoobDocumentClass))
#define KATOOB_IS_DOCUMENT(obj) (GTK_CHECK_TYPE ((obj), KATOOB_TYPE_DOCUMENT))
#define KATOOB_IS_DOCUMENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), KATOOB_TYPE_DOCUMENT))
#define KATOOB_DOCUMENT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), KATOOB_TYPE_DOCUMENT, KatoobDocumentClass))
typedef struct _KatoobDocument KatoobDocument;
typedef struct _KatoobDocumentClass KatoobDocumentClass;
typedef struct _KatoobDocumentPrivate KatoobDocumentPrivate;
struct _KatoobDocument
{
GtkTextView view;
KatoobDocumentPrivate *priv;
};
struct _KatoobDocumentClass
{
GtkTextViewClass parent_class;
/* Signal handlers */
void (* created) (KatoobDocument *document);
void (* destroyed) (KatoobDocument *document);
};
GType katoob_document_get_type (void) G_GNUC_CONST;
KatoobDocument* katoob_document_new (void);
GtkWidget* katoob_document_new_from_file(gchar *file);
GtkTextBuffer *katoob_document_get_buffer(KatoobDocument *document);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* KATOOBDOCUMENT_H */
#include <gtk/gtk.h>
#include "katoobdocument.h"
int main(int argc, char *argv[])
{
GtkWidget *win;
KatoobDocument *doc;
gtk_init(&argc, &argv);
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
doc = katoob_document_new();
gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET(doc));
gtk_widget_show_all(win);
g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_main();
return 0;
}
PGP signature
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]