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

Go to the source code of this file.

Macros

#define QUICK_QUIT   "Quit without saving"
 
#define CLOSE_QUIT   "Close (save) the Workspace & Quit"
 
#define DELETE_QUIT   "Delete the Workspace & Quit"
 
#define CD_HACK_QUIT   "Change Directory (tcl/tk hack)"
 

Functions

void cd_notify (GtkWidget *widget, gpointer data)
 
void quit_notify (GtkWidget *widget, gpointer data)
 
void create_quit_button ()
 

Variables

GtkWidget * quit_menu_item
 

Macro Definition Documentation

◆ CD_HACK_QUIT

#define CD_HACK_QUIT   "Change Directory (tcl/tk hack)"

Definition at line 49 of file gtk_quit.c.

◆ CLOSE_QUIT

#define CLOSE_QUIT   "Close (save) the Workspace & Quit"

Definition at line 47 of file gtk_quit.c.

◆ DELETE_QUIT

#define DELETE_QUIT   "Delete the Workspace & Quit"

Definition at line 48 of file gtk_quit.c.

◆ QUICK_QUIT

#define QUICK_QUIT   "Quit without saving"

Definition at line 46 of file gtk_quit.c.

Function Documentation

◆ cd_notify()

void cd_notify ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 53 of file gtk_quit.c.

53  {
55 }
void direct_change_directory()
FC: uses an external wish script I do not know how to activate this function safely....
Definition: gtk_select.c:126

References direct_change_directory().

Referenced by create_quit_button().

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

◆ create_quit_button()

void create_quit_button ( )

Definition at line 108 of file gtk_quit.c.

108  {
109  GtkWidget * quit_menu;
110 
111  quit_menu = gtk_menu_new();
112  quit_menu_item = gtk_menu_item_new_with_label("Quit");
113  gtk_menu_item_set_submenu(GTK_MENU_ITEM(quit_menu_item), quit_menu);
114 
115  GtkWidget * menu_item;
116 
117  menu_item = gtk_menu_item_new_with_label(CLOSE_QUIT);
118  g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(quit_notify),
119  NULL);
120  gtk_menu_append(GTK_MENU(quit_menu), menu_item);
121 
122  menu_item = gtk_menu_item_new_with_label(QUICK_QUIT);
123  g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(quit_notify),
124  NULL);
125  gtk_menu_append(GTK_MENU(quit_menu), menu_item);
126 
127  menu_item = gtk_menu_item_new_with_label(DELETE_QUIT);
128  g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(quit_notify),
129  NULL);
130  gtk_menu_append(GTK_MENU(quit_menu), menu_item);
131 
132  menu_item = gtk_menu_item_new_with_label(CD_HACK_QUIT);
133  g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(cd_notify),
134  NULL);
135  gtk_menu_append(GTK_MENU(quit_menu), menu_item);
136 
137  gtk_widget_show(quit_menu_item);
138  gtk_widget_show_all(quit_menu);
139  gtk_menu_bar_append(GTK_MENU_BAR(main_window_menu_bar), quit_menu_item);
140 }
GtkWidget * main_window_menu_bar
Definition: gpips.c:62
#define CD_HACK_QUIT
Definition: gtk_quit.c:49
#define DELETE_QUIT
Definition: gtk_quit.c:48
void quit_notify(GtkWidget *widget, gpointer data)
Definition: gtk_quit.c:57
void cd_notify(GtkWidget *widget, gpointer data)
Definition: gtk_quit.c:53
#define QUICK_QUIT
Definition: gtk_quit.c:46
GtkWidget * quit_menu_item
Definition: gtk_quit.c:51
#define CLOSE_QUIT
Definition: gtk_quit.c:47

References CD_HACK_QUIT, cd_notify(), CLOSE_QUIT, DELETE_QUIT, main_window_menu_bar, QUICK_QUIT, quit_menu_item, and quit_notify().

Referenced by create_menus().

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

◆ quit_notify()

void quit_notify ( GtkWidget *  widget,
gpointer  data 
)

Destroy all the windows (close open files)

Clear the log window to avoid the message about the edited state: clear_log_subwindow(NULL, NULL); Does not work... Quit: xv_destroy[_safe](main_frame);

Exit xv_main_loop() at top level:

Definition at line 57 of file gtk_quit.c.

57  {
58  int result;
59  string pn;
60 
61  if ((pn = db_get_current_workspace_name())) {
62  string fmt = "Workspace %s not closed";
63  char str[SMALL_BUFFER_LENGTH];
64  string str1, str2;
65  const char *menu_string;
66 
67  str2 = "Do you really want to quit PIPS?";
68  menu_string = gpips_gtk_menu_item_get_label(widget);
69  if (strcmp(menu_string, CLOSE_QUIT) == 0)
70  str1 = " ";
71  else
72  str1 = "-=< Resources can get lost! >=-";
73 
74  sprintf(str, fmt, pn);
75 
76  GtkWidget * dialog = gtk_message_dialog_new(GTK_WINDOW(main_window),
77  GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO,
78  GTK_BUTTONS_YES_NO, "%s%s%s",str,str1,str2);
79  result = gtk_dialog_run(GTK_DIALOG(dialog));
80 
81  if (result == GTK_RESPONSE_NO)
82  return;
83  else if (strcmp(menu_string, CLOSE_QUIT) == 0)
84  close_workspace(TRUE);
85  else if (strcmp(menu_string, DELETE_QUIT) == 0) {
86  int win = 0;
87 
88  /* Destroy all the windows (close open files) */
89  for (win = 0; win < number_of_gpips_windows; win++)
90  gtk_widget_destroy(edit_window[win]);
91 
92  check_delete_workspace(pn, FALSE);
93  }
94 
95  }
96 
97  /* Clear the log window to avoid the message about the edited
98  state:
99  clear_log_subwindow(NULL, NULL);
100  Does not work...
101  Quit:
102  xv_destroy[_safe](main_frame);
103  */
104  /* Exit xv_main_loop() at top level: */
105  gtk_main_quit();
106 }
bool close_workspace(bool is_quit)
Definition: dbm.c:346
bool check_delete_workspace(const char *wname, bool check)
Definition: dbm.c:375
GtkWidget * edit_window[MAX_NUMBER_OF_GPIPS_WINDOWS]
Definition: gpips-local.h:37
GtkWidget * main_window
Definition: gpips.c:54
int number_of_gpips_windows
Definition: gtk_edit2.c:86
#define SMALL_BUFFER_LENGTH
Definition: gpips-local.h:24
const char * gpips_gtk_menu_item_get_label(GtkWidget *w)
Definition: gtk_utils.c:43
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82

References check_delete_workspace(), CLOSE_QUIT, close_workspace(), db_get_current_workspace_name(), DELETE_QUIT, edit_window, gpips_gtk_menu_item_get_label(), main_window, number_of_gpips_windows, and SMALL_BUFFER_LENGTH.

Referenced by create_quit_button(), and create_windows().

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

Variable Documentation

◆ quit_menu_item

GtkWidget* quit_menu_item

Definition at line 51 of file gtk_quit.c.

Referenced by create_quit_button().