Franklin Franklin - 1 year ago 41
C Question

Making discordian gtk calendar widget - how to change the headers to extract gtkcalendar.c to my own directory?

I'm planing to make a discordian calendar widget for gtk. Discordian calendar was by default in Linux since 70ties. Now it's in most of the distributions. You might check it by typing "ddate" in terminal. :)

So I want to make gtk widget just by changing existing calendar widget code. To experiment on it I'd like to have it in separate, working directory.

I've found example of using a regular gtkcalendar.c and gtkcalendar.h and it's very simple, just like that:

#include <gtk/gtk.h>


I'd like to have gtkdiscocalendar.c in the same working directory as my example.c to include it like that:

#include "gtkdiscocalendar.c"
#include "gtkdiscocalendar.h"


How to extract this files properly from gtk/gtk? Their headers look like that:

(gtkcalendar.c)

#include "config.h"

#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
#include <langinfo.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <glib.h>

#ifdef G_OS_WIN32
#include <windows.h>
#endif

#include "gtkcalendar.h"
#include "gtkdnd.h"
#include "gtkdragdest.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtktooltip.h"
#include "gtkprivate.h"
#include "gtkrendericonprivate.h"
#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"


(gtkcalendar.h)

#include <gtk/gtkwidget.h>


Is my approach even right? Or maybe I should make my own clone of the whole gtk, than modify it and install it on my pc? This is my first time with gtk at all so i don't want to mess my system up. Also, I'm not trained programmer so maybe those are all basic questions. I'd be very grateful for the answer :)

Answer Source

gtkcalendar.c is a widget provided with/by the framework, the includes will differ from those subclassing GtkWidget/GObject or derivatives for own purposes.

Subclassing GObject or GtkWidgets, in C, is very verbose and error prone for newcomers. You may want to try other language bindings such as Vala, Python or even Javascript.

Custom Widgets in:

There is a lot of information on GNOME Developer website

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download