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/button.cmod

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

#include 

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

#include "gtk2.h"

/* Global variables
 */

/*! @module GUI */
/*! @module GTK2 */
/*! @class Button
 *!   
 *! A widget that creates a signal when clicked on.
 *!
 *! @b{ Object Hierarchy @}
 *!
 *! @[Object] -> @[Widget] -> @[Container] -> @[Bin]
 *! -> Button
 *!
 *! 
 *! @b{ Signal Prototypes @}
 *!
 *! @i{"activate"@} void user_function (Button dialog, mixed user_data)
 *!
 *! The "activate" signal on GtkButton is an action signal and emitting
 *! it causes the button to animate press then release. Applications should
 *! never connect to this signal, but use the "clicked" signal.
 *!
 *! @i{"clicked"@} void user_function (Button dialog, mixed user_data)
 *!
 *! Emitted when a button clicked on by the mouse and the cursor stays on
 *! the button. If the cursor is not on the button when the mouse button
 *! is released, the signal is not emitted.
 *!
 *! @i{"enter"@} void user_function (Button dialog, mixed user_data)
 *!
 *! Emitted when the mouse cursor enters the region of the button.
 *!
 *! @i{"leave"@} void user_function (Button dialog, mixed user_data)
 *!
 *! Emitted when the mouse cursor leaves the region of the button.
 *!
 *! @i{"pressed"@} void user_function (Button dialog, mixed user_data)
 *!
 *! Emitted when the button is initially pressed.
 *!
 *! @i{"released"@} void user_function (Button dialog, mixed user_data)
 *!
 *! Emitted when a button which is pressed is released, no matter where
 *! the mouse cursor is.
 */

PIKECLASS Button
 program_flags PROGRAM_USES_PARENT;
{
  INHERIT Bin;

  /*! @decl void create()
   *! @decl void create(string label)
   *! @decl void create(string label, int(0..1) mnemonic)
   *!
   *! create() creates a plain button to which you can add other Widgets using add(Widget w)
   *! create(string label) creates a button with the given text
   *!
   *! @param label
   *!    the text on the button
   *! @param mnemonic
   *!    whether the character after an underscore ('_') should be interpreted as a mnemonic
   */
  PIKEFUN void create(void|string label,void|int(0..1) mnemonic)
  {
    gchar* str;

    /* if there are 2 args push string to be on top of the stack */
    if (args==2)
      push_string(label);

    /* if there are 0 args no conversions are needed */
    if (args>0)
    {
      f_string_to_utf8(1);
      str=Pike_sp[-1].u.string->str;
    }

    /* clean up stack if changes were made previously */
    if (args==2)	
      pop_stack();
    

    if (args==0)
      /* new button without label */
      GTK2_LOW=(void *)gtk_button_new();

    /* if there is only one argument or two arguments with the second
       one being a "false" flag */
    else if (args==1 || (args==2 && Pike_sp[2-args].u.integer<1))
      /* new button with label */
      GTK2_LOW=(void*)gtk_button_new_with_label(str);

    /* if there are two arguments and the second one triggers true */
    else if (args ==2 && Pike_sp[2-args].u.integer>0)
      /* new button with label and mnemonic */
      GTK2_LOW=(void*)gtk_button_new_with_mnemonic(str);

    pop_n_elems(args);
  }

  /*! @decl void set_label(string label)
   *!
   *! Sets the label of the button
   *!
   *! @param label
   *!   the new label
   */
  PIKEFUN void set_label(string label)
  {
    f_string_to_utf8(1);
    gtk_button_set_label(GTK_BUTTON(GTK2_LOW),label->str);
  }

  /*! @decl string get_label()
   *!
   *! Returns the current label of the button, or 0 if not set
   */
  PIKEFUN string get_label()
  {
    const gchar* str=gtk_button_get_label(GTK_BUTTON(GTK2_LOW));
    if (str==NULL)
    {
      push_int(0);
    }
    else
    {
      push_string(make_shared_binary_string(str,strlen(str)));
      f_utf8_to_string(1);
    }
  }

  INIT
  {
  }

  EXIT
  { 
  }
}

/*! @endclass */
/*! @endmodule */
/*! @endmodule */

void pike_init_gtk2_button(void)
{
  INIT
}

void pike_exit_gtk2_button(void)
{
  EXIT
}


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