aboutsummaryrefslogtreecommitdiff
path: root/src/helper.h
blob: 3bf65f11164e23d4cddd5f0fdad1aa1dff40f1f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
     This file is part of GNUnet

     GNUnet 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, or (at your
     option) any later version.

     GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
*/

/**
 * @file src/helper.h
 * @author Igor Wronsky 
 */

#ifndef GTKUI_HELPER_H
#define GTKUI_HELPER_H

#include "platform.h"
#include <GNUnet/gnunet_util.h>

/* for GTK 2 */
#define GTK_ENABLE_BROKEN

#include <gtk/gtk.h>
#include <gtk/gtktext.h>

typedef struct {
  Semaphore *sem;
  void *args;
  GtkFunction func;
} SaveCall;

typedef struct {
  int doPopup;
  gchar *note;
} InfoMessage;      

typedef struct {
  const char *labelName;
  GtkWidget *frame;
} AddNotebook;


/* callback: window close: close the window */
gint deleteEvent(GtkWidget * widget,
		 GdkEvent * event,
		 gpointer data);

/**
 * A callback to destroy any widget given as second argument
 *
 */
void destroyWidget(GtkWidget * dummy, GtkWidget * widget);

/**
 * Displays an informative message to the user
 */
void guiMessage(const char * format, ...);

/**
 * Appends a message to the info window 
 */
void infoMessage(int doPopup, const char * format, ...);

/** 
 * Appends a log entry to the info window
 *
 * @param txt the log entry
 *
 */
void addLogEntry(const char *txt);

/**
 * A function for numeric comparisons of strings
 */
gint numericComp(GtkCList *clist,
                 gconstpointer ptr1,
                 gconstpointer ptr2);

/**
 * A function for case-insensitive text comparisons
 */
gint alphaComp(GtkCList *clist,
               gconstpointer ptr1,
               gconstpointer ptr2);

/**
 * A function for comparisons of percentages
 */
gint percentComp(GtkCList *clist,
                 gconstpointer ptr1,
                 gconstpointer ptr2);

/**
 * A general right-button popup menu callback
 */
gboolean popupCallback(GtkWidget *widget,
                       GdkEvent *event,
		       GtkWidget *menu );
		       
/**
 * Call a callback function from the mainloop/main thread ("SaveCall").
 * Since GTK doesn't work with multi-threaded applications under Windows,
 * all GTK operations have to be done in the main thread
 */
void gtkSaveCall(GtkFunction func, void *args);

/**
 * Initialize "SaveCalls"
 */
void gtkInitSaveCalls();

void gtkDoneSaveCalls();

int gtkRunSomeSaveCalls();
 
/**
 * Called from a "SaveCall"-function to indicate that it is done
 */
void gtkSaveCallDone(Semaphore *sem);

/**
 * Destroy a widget. Called from threads other than the main thread
 */
gint doDestroyWidget(SaveCall *call);

extern GtkWidget * infoWindow;

#endif