PIPS
gtk_log.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "genC.h"
#include "misc.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "database.h"
#include "pipsdbm.h"
#include "top-level.h"
#include "properties.h"
#include <gtk/gtk.h>
#include "gpips.h"
+ Include dependency graph for gtk_log.c:

Go to the source code of this file.

Macros

#define MAXARGS   100
 

Functions

void prompt_user (string a_printf_format,...)
 
static void insert_something_in_the_gpips_log_window (char *a_message)
 
void gpips_user_error_message (char error_buffer[])
 
void gpips_user_warning_message (char warning_buffer[])
 
void gpips_user_log (const char *fmt, va_list *args)
 
void open_log_subwindow (GtkWidget *widget, gpointer data)
 
void clear_log_subwindow (GtkWidget *widget, gpointer data)
 
void close_log_subwindow (GtkWidget *widget, gpointer data)
 
void create_log_menu ()
 
void create_log_window ()
 This works but it is cleaner to use textsw_reset() instead... More...
 

Variables

static GtkWidget * log_text_view
 xview/newgen interaction More...
 
static GtkWidget * open_or_front_menu_item
 
static GtkWidget * clear_menu_item
 
static GtkWidget * close_menu_item
 
static GtkWidget * scrolled_window_vadjustment
 

Macro Definition Documentation

◆ MAXARGS

#define MAXARGS   100

Definition at line 134 of file gtk_log.c.

Function Documentation

◆ clear_log_subwindow()

void clear_log_subwindow ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 161 of file gtk_log.c.

161  {
162  GtkTextIter start, end;
163  GtkTextBuffer * buffer;
164  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(log_text_view));
165  gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(buffer), &start);
166  gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(buffer), &end);
167  gtk_text_buffer_delete(GTK_TEXT_BUFFER(buffer), &start, &end);
168 
169  gtk_widget_set_sensitive(clear_menu_item, FALSE);
170 }
static char start[1024]
The name of the variable from which to start counting domain numbers.
Definition: genLisp.c:55
static GtkWidget * clear_menu_item
Definition: gtk_log.c:63
static GtkWidget * log_text_view
xview/newgen interaction
Definition: gtk_log.c:62
char end
Definition: gtk_status.c:82
static string buffer
Definition: string.c:113

References buffer, clear_menu_item, end, log_text_view, and start.

Referenced by create_log_menu().

+ Here is the caller graph for this function:

◆ close_log_subwindow()

void close_log_subwindow ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 172 of file gtk_log.c.

172  {
174  gtk_widget_set_sensitive(close_menu_item, FALSE);
175  hide_window(log_window, NULL, NULL);
176 }
GtkWidget * log_window
Definition: gpips-local.h:36
static GtkWidget * close_menu_item
Definition: gtk_log.c:63
static GtkWidget * open_or_front_menu_item
Definition: gtk_log.c:63
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89
void gpips_gtk_menu_item_set_label(GtkWidget *w, gchar *text)
Definition: gtk_utils.c:64

References close_menu_item, gpips_gtk_menu_item_set_label(), hide_window(), log_window, and open_or_front_menu_item.

Referenced by create_frames(), and create_log_menu().

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

◆ create_log_menu()

void create_log_menu ( )

Definition at line 178 of file gtk_log.c.

178  {
179  GtkWidget * log_menu;
180  GtkWidget * log_menu_item;
181 
182  log_menu = gtk_menu_new();
183  log_menu_item = gtk_menu_item_new_with_label("Log");
184  gtk_menu_item_set_submenu(GTK_MENU_ITEM(log_menu_item), log_menu);
185 
186  open_or_front_menu_item = gtk_menu_item_new_with_label("Open");
187  g_signal_connect(G_OBJECT(open_or_front_menu_item), "activate", G_CALLBACK(
188  open_log_subwindow), NULL);
189  gtk_menu_append(GTK_MENU(log_menu), open_or_front_menu_item);
190 
191  clear_menu_item = gtk_menu_item_new_with_label("Clear");
192  g_signal_connect(G_OBJECT(clear_menu_item), "activate", G_CALLBACK(
193  clear_log_subwindow), NULL);
194  gtk_menu_append(GTK_MENU(log_menu), clear_menu_item);
195 
196  close_menu_item = gtk_menu_item_new_with_label("Close");
197  g_signal_connect(G_OBJECT(close_menu_item), "activate", G_CALLBACK(
198  close_log_subwindow), NULL);
199  gtk_menu_append(GTK_MENU(log_menu), close_menu_item);
200 
201  gtk_widget_show(log_menu_item);
202  gtk_widget_show_all(log_menu);
203  gtk_menu_bar_append(GTK_MENU_BAR(main_window_menu_bar), log_menu_item);
204 }
GtkWidget * main_window_menu_bar
Definition: gpips.c:62
void clear_log_subwindow(GtkWidget *widget, gpointer data)
Definition: gtk_log.c:161
void open_log_subwindow(GtkWidget *widget, gpointer data)
Definition: gtk_log.c:155
void close_log_subwindow(GtkWidget *widget, gpointer data)
Definition: gtk_log.c:172

References clear_log_subwindow(), clear_menu_item, close_log_subwindow(), close_menu_item, main_window_menu_bar, open_log_subwindow(), and open_or_front_menu_item.

Referenced by create_menus().

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

◆ create_log_window()

void create_log_window ( )

This works but it is cleaner to use textsw_reset() instead...

void recreate_log_window() { xv_destroy(log_textsw); log_textsw = (Xv_Window) xv_create(log_frame, TEXTSW, 0); }

Xv_Window window;

Definition at line 215 of file gtk_log.c.

215  {
216  /* Xv_Window window; */
217 
218  GtkWidget * frame = gtk_frame_new("Log");
219 
220  GtkWidget * scrolled_window;
221 
222  scrolled_window = gtk_scrolled_window_new(NULL, NULL);
223  scrolled_window_vadjustment = GTK_WIDGET(gtk_scrolled_window_get_vadjustment(
224  GTK_SCROLLED_WINDOW(scrolled_window)));
225  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
226  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
227 
228  log_text_view = gtk_text_view_new();
229 
230  gtk_container_add(GTK_CONTAINER(log_window), frame);
231  gtk_container_add(GTK_CONTAINER(frame), scrolled_window);
232  gtk_container_add(GTK_CONTAINER(scrolled_window), log_text_view);
233 
234  gtk_widget_show_all(frame);
235 }
static GtkWidget * scrolled_window_vadjustment
Definition: gtk_log.c:64

References log_text_view, log_window, and scrolled_window_vadjustment.

Referenced by gpips_main(), and wpips_main().

+ Here is the caller graph for this function:

◆ gpips_user_error_message()

void gpips_user_error_message ( char  error_buffer[])

prompt_user("Something went wrong. Check the log window");

terminate PIPS request

Definition at line 104 of file gtk_log.c.

104  {
105  log_on_file(error_buffer);
106 
108 
109  show_message(error_buffer);
110  gtk_widget_show(log_window);
111 
112  /* prompt_user("Something went wrong. Check the log window"); */
113 
114  /* terminate PIPS request */
115  if (get_bool_property("ABORT_ON_USER_ERROR"))
116  abort();
117 
119 
120  (void) exit(1);
121 }
void log_on_file(const char *desc)
Definition: message.c:190
@ user_exception_error
#define THROW(what)
void show_message(char *fmt,...)
ARARGS0.
Definition: dialogue.c:46
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static void insert_something_in_the_gpips_log_window(char *a_message)
Definition: gtk_log.c:81
#define exit(code)
Definition: misc-local.h:54
#define abort()
Definition: misc-local.h:53

References abort, exit, get_bool_property(), insert_something_in_the_gpips_log_window(), log_on_file(), log_window, show_message(), THROW, and user_exception_error.

+ Here is the call graph for this function:

◆ gpips_user_log()

void gpips_user_log ( const char *  fmt,
va_list *  args 
)

Display the "Message:" line in the main window

Definition at line 136 of file gtk_log.c.

137 {
138  static char log_buffer[SMALL_BUFFER_LENGTH];
139 
140  va_list acpy;
141  va_copy(acpy, *args);
142  vsprintf(log_buffer, fmt, acpy);
143  va_end(acpy);
144 
145  log_on_file(log_buffer);
146 
147  if (get_bool_property("USER_LOG_P") == FALSE)
148  return;
149 
151  /* Display the "Message:" line in the main window */
152  show_message(log_buffer);
153 }
#define SMALL_BUFFER_LENGTH
Definition: gpips-local.h:24

References get_bool_property(), insert_something_in_the_gpips_log_window(), log_on_file(), show_message(), and SMALL_BUFFER_LENGTH.

Referenced by gpips_main().

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

◆ gpips_user_warning_message()

void gpips_user_warning_message ( char  warning_buffer[])

François said a warning is not important enough... gtk_widget_show(log_window);

Definition at line 123 of file gtk_log.c.

123  {
124  log_on_file(warning_buffer);
125 
127  /* François said a warning is not important enough...
128  gtk_widget_show(log_window);
129  */
130 
131  show_message(warning_buffer);
132 }

References insert_something_in_the_gpips_log_window(), log_on_file(), and show_message().

+ Here is the call graph for this function:

◆ insert_something_in_the_gpips_log_window()

static void insert_something_in_the_gpips_log_window ( char *  a_message)
static

insert at the end:

Definition at line 81 of file gtk_log.c.

81  {
82  GtkTextIter iter;
83  GtkTextBuffer * buffer;
84 
85  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(log_text_view));
86 
87  //int new_length;
88  int message_length = strlen(a_message);
89 
90  /* insert at the end: */
91  gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(buffer), &iter);
92  gtk_text_buffer_insert(GTK_TEXT_BUFFER(buffer), &iter, a_message,
93  message_length);
94 
95  gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(log_text_view), &iter, 0.0,
96  FALSE, 0.0, 0.0);
97  gtk_adjustment_set_value(GTK_ADJUSTMENT(scrolled_window_vadjustment),
98  gpips_gtk_adjustment_get_upper(GTK_ADJUSTMENT(
100 
101  gtk_widget_set_sensitive(clear_menu_item, TRUE);
102 }
gdouble gpips_gtk_adjustment_get_upper(GtkAdjustment *adjustment)
Definition: gtk_utils.c:84

References buffer, clear_menu_item, gpips_gtk_adjustment_get_upper(), log_text_view, and scrolled_window_vadjustment.

Referenced by gpips_user_error_message(), gpips_user_log(), and gpips_user_warning_message().

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

◆ open_log_subwindow()

void open_log_subwindow ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 155 of file gtk_log.c.

155  {
157  gtk_widget_set_sensitive(close_menu_item, TRUE);
158  gtk_widget_show(log_window);
159 }

References close_menu_item, gpips_gtk_menu_item_set_label(), log_window, and open_or_front_menu_item.

Referenced by create_log_menu().

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

◆ prompt_user()

void prompt_user ( string  a_printf_format,
  ... 
)

Definition at line 66 of file gtk_log.c.

66  {
67  va_list some_arguments;
68  static char message_buffer[SMALL_BUFFER_LENGTH];
69 
70  va_start(some_arguments, a_printf_format);
71 
72  (void) vsprintf(message_buffer, a_printf_format, some_arguments);
73 
74  GtkWidget * dialog = gtk_message_dialog_new(GTK_WINDOW(log_window),
75  GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
76  "%s", message_buffer);
77  gtk_dialog_run(GTK_DIALOG(dialog));
78  gtk_widget_destroy(dialog);
79 }

References log_window, and SMALL_BUFFER_LENGTH.

Referenced by analyze_notify(), continue_create_workspace_notify(), edit_close_notify(), edit_notify(), end_directory_notify(), end_select_module_callback(), end_select_module_notify(), epips_select_module(), gpips_execute_and_display_something(), gpips_execute_and_display_something_from_alias(), gpips_file_view(), gpips_view_marked_busy(), hpfc_notify(), mchoose_ok_notify(), open_workspace_notify(), options_select(), prompt_user_not_allowed_to_change_directory(), schoose_ok_notify(), select_module_from_menubar_callback(), select_module_notify(), start_delete_workspace_notify(), transform_notify(), user_prompt_not_a_valid_workspace_name(), wpips_execute_and_display_something(), wpips_execute_and_display_something_from_alias(), wpips_file_view(), and wpips_view_marked_busy().

+ Here is the caller graph for this function:

Variable Documentation

◆ clear_menu_item

GtkWidget * clear_menu_item
static

◆ close_menu_item

GtkWidget * close_menu_item
static

Definition at line 63 of file gtk_log.c.

Referenced by close_log_subwindow(), create_log_menu(), and open_log_subwindow().

◆ log_text_view

GtkWidget* log_text_view
static

xview/newgen interaction

Definition at line 62 of file gtk_log.c.

Referenced by clear_log_subwindow(), create_log_window(), and insert_something_in_the_gpips_log_window().

◆ open_or_front_menu_item

GtkWidget* open_or_front_menu_item
static

Definition at line 63 of file gtk_log.c.

Referenced by close_log_subwindow(), create_log_menu(), and open_log_subwindow().

◆ scrolled_window_vadjustment

GtkWidget* scrolled_window_vadjustment
static

Definition at line 64 of file gtk_log.c.

Referenced by create_log_window(), and insert_something_in_the_gpips_log_window().