Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Module Information
GUI.GTK2
Viewing contents of GUI_GTK2-0.1/gtk2.cmod

#include "global.h"
#include "svalue.h"
#include "interpret.h"
#include "stralloc.h"
#include "array.h"
#include 

/* All your includes here */
#include "constants.h"
#include "gtk2.h"

/* This must be included last! */
#include "module.h"


/* Global variables
 */
//static int count = 0;

static int initialized = 0;

void push_gtkobject(void* arg, struct program* prog)
{
  struct object* obj;
  obj=fast_clone_object(prog);
  ((struct Object_struct*)get_storage(obj, Object_program))->data=arg;
  push_object(obj);
}

void push_gvalue(const GValue* gval)
{
  switch (G_VALUE_TYPE(gval))
  {
    case G_TYPE_INT:
      push_int(g_value_get_int(gval));
      break;
    case G_TYPE_STRING:
      {
        gchar* str=g_strdup_value_contents(gval);
        push_string(make_shared_binary_string(str,strlen(str)));
        f_utf8_to_string();
      }
      break;
    default:
      {
        gpointer ptr=g_value_peek_pointer(gval);

        /* after a long discussion in an irc channel we found out
         * that using GQuarks is probably the best solution
         * for type-checking, since string-comparision produces
         * too much overhead and using GTK_TYPE_* initializes a GType
         * for every type
         */
        if(G_IS_OBJECT(ptr))
        {
          const gchar* name=G_OBJECT_TYPE_NAME(ptr);
          if (g_quark_try_string("GtkObject") == g_type_qname(G_VALUE_TYPE(gval)))
            push_gtkobject(ptr,Object_program);
          else if (g_quark_try_string("GtkButton") == g_type_qname(G_VALUE_TYPE(gval)))
            push_gtkobject(ptr,Button_program);
          else if (g_quark_try_string("GtkContainer") == g_type_qname(G_VALUE_TYPE(gval)))
            push_gtkobject(ptr,Container_program);
          else if (g_quark_try_string("GtkDialog") == g_type_qname(G_VALUE_TYPE(gval)))
            push_gtkobject(ptr,Dialog_program);
          else if (g_quark_try_string("GtkEntry") == g_type_qname(G_VALUE_TYPE(gval)))
            push_gtkobject(ptr,Button_program);
          else if (g_quark_try_string("GtkLabel") == g_type_qname(G_VALUE_TYPE(gval)))
            push_gtkobject(ptr,Label_program);
          else if (g_quark_try_string("GtkWidget") == g_type_qname(G_VALUE_TYPE(gval)))
            push_gtkobject(ptr,Widget_program);
          else
          {
            push_int(0);
            printf("cannot find widget-type to push on stack, please contact author\n");
          }
        }
        else
        {
          push_int(0);
          printf("cannot find type to push on stack, please contact author\n");
        }
      }
      break;
  }
}

void pgtk2_call_signal(GClosure     *closure,
                       GValue       *return_value,
                       guint         n_param_vals,
                       const GValue *param_vals,
                       gpointer      invocation_hint,
                       gpointer      sigdata)
{
  int i;
  for (i=0;iargc>0)
  {
    push_svalue(&((struct pgtk2_signal_data*)sigdata)->args);	
    apply_svalue(&((struct pgtk2_signal_data*)sigdata)->cb,1+n_param_vals);
  }
  else
  {
    apply_svalue(&((struct pgtk2_signal_data*)sigdata)->cb,n_param_vals);
  }
  return;
}

void pgtk2_destroy_signal(gpointer data,GClosure* closure)
{
  g_free(data);
}

/*! @module GUI
 *!
 *! All Graphical User Interfaces available for Pike are in this module
 */

/*! @module GTK2
 *!
 *! A GTK+-2.x module for Pike
 *!
 *! This is basically a wrapper around gtk functions. Only very@
 *! little code (like the module handling) is done apart from gtk code.
 */


//PIKEVAR constant __version="0.0.1";
//PIKEVAR constant __author="Sebastian Kaminski ";

/*! @decl void init(array argv)
 *!   Initializes everything needed to operate GTK
 *! @param argv
 *!   Command line arguments that might affect GTK
 *! @note
 *!   In contrary to the C gtk_init() function this one@
 *!   doesn't adjust argv to exclude GTK arguments
 */
PIKEFUN void init(array|void arg)
{
  int i,s;
  char** arr;
  struct svalue* items;

  if (args==1)
  {
    s=arg->size;
    arr=g_malloc(sizeof(char*) * s);

    for (i=0;istr );
      pop_stack();
    }

    gtk_init(&s,&arr);

    for (i=0;i

gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University