PIPS
gtk_query.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "genC.h"
#include "misc.h"
#include <gtk/gtk.h>
#include "gpips.h"
+ Include dependency graph for gtk_query.c:

Go to the source code of this file.

Functions

void start_query (char *window_title, char *query_title, char *help_topic, success(*ok_func)(const char *), void(*cancel_func)(GtkWidget *, gpointer))
 
void end_query_notify (GtkWidget *widget, gpointer data)
 
void help_query_notify (GtkWidget *widget, gpointer data)
 
void cancel_query_notify (GtkWidget *widget, gpointer data)
 hides a window... More...
 
void cancel_user_request_notify (GtkWidget *widget, gpointer data)
 Cancel clear the string value and return: More...
 
success end_user_request_notify (const char *the_answer)
 
string gpips_user_request (const char *a_printf_format, va_list *args)
 
void create_query_window ()
 

Variables

static GtkWidget * query_entry
 
static GtkWidget * query_entry_label
 
static GtkWidget * query_cancel_button
 
static char * query_help_topic
 
static success(* apply_on_query )(const char *)
 

Function Documentation

◆ cancel_query_notify()

void cancel_query_notify ( GtkWidget *  widget,
gpointer  data 
)

hides a window...

Definition at line 118 of file gtk_query.c.

118  {
119  hide_window(query_dialog, NULL, NULL);
120 }
GtkWidget * query_dialog
Definition: gpips-local.h:37
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89

References hide_window(), and query_dialog.

Referenced by cancel_create_workspace_notify(), and start_directory_notify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel_user_request_notify()

void cancel_user_request_notify ( GtkWidget *  widget,
gpointer  data 
)

Cancel clear the string value and return:

Just return the "":

Definition at line 123 of file gtk_query.c.

123  {
124  gtk_entry_set_text(GTK_ENTRY(query_entry), "");
125  hide_window(query_dialog, NULL, NULL);
126  /* Just return the "": */
127  gtk_dialog_response(GTK_DIALOG(query_dialog), 1);
128 }
static GtkWidget * query_entry
Definition: gtk_query.c:41

References hide_window(), query_dialog, and query_entry.

Referenced by gpips_user_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_query_window()

void create_query_window ( )

seems it has no use. RK, 9/11/93.

Definition at line 163 of file gtk_query.c.

163  {
164  GtkWidget *help_button, *ok_button;
165  //GtkWidget *action_area;
166  GtkWidget *content_area;
167 
168  /* seems it has no use. RK, 9/11/93. */
169  // xv_set(canvas_paint_window(query_panel), WIN_CONSUME_EVENT, LOC_WINENTER,
170  // NULL,
171  // /* WIN_IGNORE_X_EVENT_MASK, KeyReleaseMask, */
172  // WIN_EVENT_PROC, query_canvas_event_proc, NULL);
173 
174  //action_area = gtk_dialog_get_action_area(query_dialog);
175  content_area = gpips_gtk_dialog_get_content_area(GTK_DIALOG(query_dialog));
176 
177  GtkWidget * hbox = gtk_hbox_new(FALSE,0);
178  query_entry_label = gtk_label_new(NULL);
179  query_entry = gtk_entry_new_with_max_length(128);
180  gtk_box_pack_start(GTK_BOX(hbox), query_entry_label, FALSE, FALSE, 5);
181  gtk_box_pack_start(GTK_BOX(hbox), query_entry, FALSE, FALSE, 5);
182  gtk_container_add(GTK_CONTAINER(content_area), hbox);
183  gtk_widget_show_all(hbox);
184 
185  ok_button = gtk_button_new_with_label("OK");
186  gtk_dialog_add_action_widget(GTK_DIALOG(query_dialog), ok_button, GTK_RESPONSE_OK);
187  gtk_signal_connect(GTK_OBJECT(ok_button), "clicked", GTK_SIGNAL_FUNC(
188  end_query_notify), NULL);
189  gtk_window_set_default(GTK_WINDOW(query_dialog), ok_button);
190  //gtk_container_add(GTK_CONTAINER(action_area), ok_button);
191 
192  help_button = gtk_button_new_with_label("Help");
193  gtk_dialog_add_action_widget(GTK_DIALOG(query_dialog), help_button, GTK_RESPONSE_HELP);
194  gtk_signal_connect(GTK_OBJECT(help_button), "clicked", GTK_SIGNAL_FUNC(
195  help_query_notify), NULL);
196  //gtk_container_add(GTK_CONTAINER(action_area), help_button);
197 
198  query_cancel_button = gtk_button_new_with_label("Cancel");
199  gtk_dialog_add_action_widget(GTK_DIALOG(query_dialog), query_cancel_button, GTK_RESPONSE_CANCEL);
200  //gtk_container_add(GTK_CONTAINER(action_area), query_cancel_button);
201 
202  gtk_widget_show_all(query_dialog);
203  gtk_widget_hide(query_dialog);
204 }
static GtkWidget * ok_button
Definition: gtk_mchoose.c:43
static GtkWidget * help_button
Definition: gtk_mchoose.c:44
void help_query_notify(GtkWidget *widget, gpointer data)
Definition: gtk_query.c:113
void end_query_notify(GtkWidget *widget, gpointer data)
Definition: gtk_query.c:102
static GtkWidget * query_cancel_button
Definition: gtk_query.c:42
static GtkWidget * query_entry_label
Definition: gtk_query.c:41
GtkWidget * gpips_gtk_dialog_get_content_area(GtkDialog *dialog)
Definition: gtk_utils.c:79

References end_query_notify(), gpips_gtk_dialog_get_content_area(), help_button, help_query_notify(), ok_button, query_cancel_button, query_dialog, query_entry, and query_entry_label.

Referenced by gpips_main(), and wpips_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end_query_notify()

void end_query_notify ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 102 of file gtk_query.c.

102  {
103  const char * s = gtk_entry_get_text(GTK_ENTRY(query_entry));
104  if (s == NULL)
105  s = strdup("");
106  else
107  s = strdup(s);
108 
109  if (apply_on_query(s))
110  hide_window(query_dialog, NULL, NULL);
111 }
static success(* apply_on_query)(const char *)
Definition: gtk_query.c:45
char * strdup()

References apply_on_query, hide_window(), query_dialog, query_entry, and strdup().

Referenced by create_query_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end_user_request_notify()

success end_user_request_notify ( const char *  the_answer)

Definition at line 130 of file gtk_query.c.

130  {
131  hide_window(query_dialog, NULL, NULL);
132  gtk_dialog_response(GTK_DIALOG(query_dialog), 1);
133  return TRUE;
134 }

References hide_window(), and query_dialog.

Referenced by gpips_user_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gpips_user_request()

string gpips_user_request ( const char *  a_printf_format,
va_list *  args 
)

char * the_answer;

Log the answer for possible rerun through tpips:

he_answer

Definition at line 136 of file gtk_query.c.

136  {
137 
138  /* char * the_answer; */
139 
140  static char message_buffer[SMALL_BUFFER_LENGTH];
141 
142  va_list acpy;
143  va_copy(acpy, *args);
144  vsprintf(message_buffer, a_printf_format, acpy);
145  va_end(acpy);
146 
147  start_query("User Query", message_buffer, "UserQuery",
149 
150  user_log("User Request...\n");
151 
152  gtk_widget_show(query_dialog);
153  gtk_window_set_modal(GTK_WINDOW(query_dialog), TRUE);
154  gtk_dialog_run(GTK_DIALOG(query_dialog)); // On force l'attente de la réponse
155  gtk_window_set_modal(GTK_WINDOW(query_dialog), FALSE);
156 
157  /* Log the answer for possible rerun through tpips: */
158  user_log("%s\n\"%s\"\nEnd User Request\n", message_buffer, "" /*the_answer*/);
159 
160  return strdup(gtk_entry_get_text(GTK_ENTRY(query_entry)));
161 }
void user_log(const char *format,...)
Definition: message.c:234
#define SMALL_BUFFER_LENGTH
Definition: gpips-local.h:24
void cancel_user_request_notify(GtkWidget *widget, gpointer data)
Cancel clear the string value and return:
Definition: gtk_query.c:123
void start_query(char *window_title, char *query_title, char *help_topic, success(*ok_func)(const char *), void(*cancel_func)(GtkWidget *, gpointer))
Definition: gtk_query.c:47
success end_user_request_notify(const char *the_answer)
Definition: gtk_query.c:130

References cancel_user_request_notify(), end_user_request_notify(), query_dialog, query_entry, SMALL_BUFFER_LENGTH, start_query(), strdup(), and user_log().

Referenced by gpips_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ help_query_notify()

void help_query_notify ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 113 of file gtk_query.c.

113  {
115 }
void display_help(char *topic)
Definition: gtk_help.c:50
static char * query_help_topic
Definition: gtk_query.c:44

References display_help(), and query_help_topic.

Referenced by create_query_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start_query()

void start_query ( char *  window_title,
char *  query_title,
char *  help_topic,
success(*)(const char *)  ok_func,
void(*)(GtkWidget *, gpointer)  cancel_func 
)

PANEL_NOTIFY_PROC, cancel_query_notify,

No cancel button requested:

Definition at line 47 of file gtk_query.c.

48  {
49 
50  gtk_window_set_title(GTK_WINDOW(query_dialog), window_title);
51 
52  /* PANEL_NOTIFY_PROC, cancel_query_notify, */
53  gtk_widget_set_sensitive(GTK_WIDGET(query_cancel_button), TRUE);
54  if (cancel_func == NULL)
55  /* No cancel button requested: */
56  gtk_widget_set_sensitive(GTK_WIDGET(query_cancel_button), FALSE);
57  else
58  gtk_signal_connect(GTK_OBJECT(query_cancel_button), "clicked",
59  GTK_SIGNAL_FUNC(cancel_func), NULL);
60 
61  gtk_label_set_text(GTK_LABEL(query_entry_label), query_title);
62  gtk_entry_set_text(GTK_ENTRY(query_entry), "");
63 
64  query_help_topic = help_topic;
65  apply_on_query = ok_func;
66 
67  gtk_widget_show_all(query_dialog);
68 }

References apply_on_query, query_cancel_button, query_dialog, query_entry, query_entry_label, and query_help_topic.

Referenced by gpips_user_request(), start_create_workspace_notify(), and start_directory_notify().

+ Here is the caller graph for this function:

Variable Documentation

◆ apply_on_query

success(* apply_on_query) (const char *) ( const char *  )
static

Definition at line 45 of file gtk_query.c.

Referenced by end_query_notify(), and start_query().

◆ query_cancel_button

GtkWidget* query_cancel_button
static

Definition at line 42 of file gtk_query.c.

Referenced by create_query_window(), and start_query().

◆ query_entry

GtkWidget* query_entry
static

◆ query_entry_label

GtkWidget * query_entry_label
static

Definition at line 41 of file gtk_query.c.

Referenced by create_query_window(), and start_query().

◆ query_help_topic

char* query_help_topic
static

Definition at line 44 of file gtk_query.c.

Referenced by help_query_notify(), and start_query().