threads example from Erik Mouw. New question on GtkLabel background

Sat Nov 13 22:30:29 GMT 1999 Tony Gale  <gale@gtk.org>

        * docs/gtkfaq.sgml: threads example from Erik Mouw.
        New question on GtkLabel background colors.

        * docs/gtk_tut.sgml:
          - Correct the example code callback
            function definitions.
          - Update the gtkdial example code, from Frans van Schaik.
          - Update setselection.c to current API.

        * examples/Makefile examples/*/*.c: Update to code
        listed in tutorial.
This commit is contained in:
GMT 1999 Tony Gale
1999-11-13 23:06:46 +00:00
committed by Tony Gale
parent e4df9fa95b
commit ee3d137660
49 changed files with 2379 additions and 681 deletions

View File

@@ -2,13 +2,13 @@
#include <gtk/gtk.h>
void selection_received (GtkWidget *widget,
GtkSelectionData *selection_data,
gpointer data);
void selection_received( GtkWidget *widget,
GtkSelectionData *selection_data,
gpointer data );
/* Signal handler invoked when user clicks on the "Get Targets" button */
void
get_targets (GtkWidget *widget, gpointer data)
void get_targets( GtkWidget *widget,
gpointer data )
{
static GdkAtom targets_atom = GDK_NONE;
@@ -22,9 +22,9 @@ get_targets (GtkWidget *widget, gpointer data)
}
/* Signal handler called when the selections owner returns the data */
void
selection_received (GtkWidget *widget, GtkSelectionData *selection_data,
gpointer data)
void selection_received( GtkWidget *widget,
GtkSelectionData *selection_data,
gpointer data )
{
GdkAtom *atoms;
GList *item_list;
@@ -60,8 +60,8 @@ selection_received (GtkWidget *widget, GtkSelectionData *selection_data,
return;
}
int
main (int argc, char *argv[])
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *button;

View File

@@ -4,8 +4,8 @@
#include <time.h>
/* Callback when the user toggles the selection */
void
selection_toggled (GtkWidget *widget, gint *have_selection)
void selection_toggled( GtkWidget *widget,
gint *have_selection )
{
if (GTK_TOGGLE_BUTTON(widget)->active)
{
@@ -32,9 +32,9 @@ selection_toggled (GtkWidget *widget, gint *have_selection)
}
/* Called when another application claims the selection */
gint
selection_clear (GtkWidget *widget, GdkEventSelection *event,
gint *have_selection)
gint selection_clear( GtkWidget *widget,
GdkEventSelection *event,
gint *have_selection )
{
*have_selection = FALSE;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), FALSE);
@@ -43,15 +43,16 @@ selection_clear (GtkWidget *widget, GdkEventSelection *event,
}
/* Supplies the current time as the selection. */
void
selection_handle (GtkWidget *widget,
GtkSelectionData *selection_data,
gpointer data)
void selection_handle( GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time_stamp,
gpointer data )
{
gchar *timestr;
time_t current_time;
current_time = time (NULL);
current_time = time(NULL);
timestr = asctime (localtime(&current_time));
/* When we return a single string, it should not be null terminated.
That will be done for us */
@@ -60,11 +61,10 @@ selection_handle (GtkWidget *widget,
8, timestr, strlen(timestr));
}
int
main (int argc, char *argv[])
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *selection_button;
static int have_selection = FALSE;
@@ -91,9 +91,12 @@ main (int argc, char *argv[])
gtk_signal_connect (GTK_OBJECT(selection_button), "selection_clear_event",
GTK_SIGNAL_FUNC (selection_clear), &have_selection);
gtk_selection_add_handler (selection_button, GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING,
selection_handle, NULL);
gtk_selection_add_target (selection_button,
GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING,
1);
gtk_signal_connect (GTK_OBJECT(selection_button), "selection_get",
GTK_SIGNAL_FUNC (selection_handle), &have_selection);
gtk_widget_show (selection_button);
gtk_widget_show (window);