"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "export_gui.c" between
jpilot-1.8.2.tar.gz and jpilot-2_0_1.tar.gz

About: J-Pilot is a desktop organizer application for Palm Pilot (PalmOS) devices. Ported to GTK3.

export_gui.c  (jpilot-1.8.2):export_gui.c  (jpilot-2_0_1)
skipping to change at line 42 skipping to change at line 42
#include "prefs.h" #include "prefs.h"
#include "export.h" #include "export.h"
/********************************* Constants **********************************/ /********************************* Constants **********************************/
#define NUM_CAT_ITEMS 16 #define NUM_CAT_ITEMS 16
#define BROWSE_OK 1 #define BROWSE_OK 1
#define BROWSE_CANCEL 2 #define BROWSE_CANCEL 2
/******************************* Global vars **********************************/ /******************************* Global vars **********************************/
static GtkWidget *export_clist; static GtkWidget *export_treeView;
static int export_category; static int export_category;
static int glob_export_browse_pressed; static int glob_export_browse_pressed;
static int glob_pref_export; static int glob_pref_export;
static GtkWidget *export_radio_type[10]; static GtkWidget *export_radio_type[10];
static int glob_export_type; static int glob_export_type;
static GtkWidget *save_as_entry; static GtkWidget *save_as_entry;
GtkWidget *category_menu;
/****************************** Prototypes ************************************/ /****************************** Prototypes ************************************/
static void (*glob_cb_export_menu)(GtkWidget *clist, int category); static void (*glob_cb_export_menu)(GtkWidget *treeView, int category);
static GtkWidget *(*glob_cb_init_menu)();
static void (*glob_cb_export_done)(GtkWidget *widget, const char *filename); static void (*glob_cb_export_done)(GtkWidget *widget, const char *filename);
static void (*glob_cb_export_ok)(GtkWidget *export_window, static void (*glob_cb_export_ok)(GtkWidget *export_window,
GtkWidget *clist, GtkWidget *treeView,
int type, int type,
const char *filename); const char *filename);
/****************************** Main Code *************************************/ /****************************** Main Code *************************************/
/* /*
* Browse GUI * Browse GUI
*/ */
static gboolean cb_export_browse_destroy(GtkWidget *widget) static gboolean cb_export_browse_destroy(GtkWidget *widget) {
{ gtk_main_quit();
gtk_main_quit(); return FALSE;
return FALSE; }
}
static void cb_export_browse_cancel(GtkWidget *widget, gpointer data) {
static void cb_export_browse_cancel(GtkWidget *widget, gpointer data) glob_export_browse_pressed = BROWSE_CANCEL;
{ gtk_widget_destroy(widget);
glob_export_browse_pressed=BROWSE_CANCEL; }
gtk_widget_destroy(data);
} static void cb_export_browse_ok(GtkWidget *widget, gpointer data) {
char *sel;
static void cb_export_browse_ok(GtkWidget *widget, gpointer data) int pref = GPOINTER_TO_INT(data);
{ glob_export_browse_pressed = BROWSE_OK;
const char *sel; if (pref) {
sel = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (widget));
glob_export_browse_pressed=BROWSE_OK; set_pref(pref, 0, sel, TRUE);
if (glob_pref_export) { gtk_entry_set_text(GTK_ENTRY(save_as_entry), sel);
sel = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)); }
set_pref(glob_pref_export, 0, sel, TRUE); gtk_widget_destroy(widget);
} }
gtk_widget_destroy(data);
} int export_browse(GtkWidget *main_window, int pref_export) {
GtkWidget *fileChooserWidget;
int export_browse(GtkWidget *main_window, int pref_export) const char *svalue;
{ char dir[MAX_PREF_LEN + 2];
GtkWidget *filesel; int i;
const char *svalue;
char dir[MAX_PREF_LEN+2]; glob_export_browse_pressed = 0;
int i; if (pref_export) {
glob_pref_export = pref_export;
glob_export_browse_pressed = 0; } else {
glob_pref_export = 0;
if (pref_export) { }
glob_pref_export = pref_export;
} else { if (pref_export) {
glob_pref_export = 0; get_pref(pref_export, NULL, &svalue);
} g_strlcpy(dir, svalue, sizeof(dir));
i = strlen(dir) - 1;
if (pref_export) { if (i < 0) i = 0;
get_pref(pref_export, NULL, &svalue); if (dir[i] != '/') {
g_strlcpy(dir, svalue, sizeof(dir)); for (i = strlen(dir); i >= 0; i--) {
i=strlen(dir)-1; if (dir[i] == '/') {
if (i<0) i=0; dir[i + 1] = '\0';
if (dir[i]!='/') { break;
for (i=strlen(dir); i>=0; i--) { }
if (dir[i]=='/') {
dir[i+1]='\0';
break;
} }
} }
}
if (chdir(dir)<0) {
jp_logf(JP_LOG_WARN, "chdir failed %s %d\n", __FILE__, __LINE__);
}
}
filesel = gtk_file_selection_new(_("File Browser"));
gtk_window_set_modal(GTK_WINDOW(filesel), TRUE);
gtk_window_set_transient_for(GTK_WINDOW(filesel), GTK_WINDOW(main_window));
gtk_signal_connect(GTK_OBJECT(filesel), "destroy",
GTK_SIGNAL_FUNC(cb_export_browse_destroy), filesel);
gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), if (chdir(dir) < 0) {
"clicked", GTK_SIGNAL_FUNC(cb_export_browse_ok), filesel); jp_logf(JP_LOG_WARN, "chdir failed %s %d\n", __FILE__, __LINE__);
gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), }
"clicked", GTK_SIGNAL_FUNC(cb_export_browse_cancel), files }
el); fileChooserWidget = gtk_file_chooser_dialog_new(_("File Browser"), GTK_WINDO
W(main_window), GTK_FILE_CHOOSER_ACTION_SAVE,
"Cancel", GTK_RESPONSE_CANCE
L, "Open",
GTK_RESPONSE_ACCEPT, NULL);
gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(fileChooserWidget), TRUE);
//This blocks main thread until they close the dialog.
if (gtk_dialog_run(GTK_DIALOG (fileChooserWidget)) == GTK_RESPONSE_ACCEPT) {
cb_export_browse_ok(fileChooserWidget, GINT_TO_POINTER(pref_export));
glob_export_browse_pressed = BROWSE_OK;
} else {
cb_export_browse_cancel(fileChooserWidget, NULL);
}
cb_export_browse_destroy(fileChooserWidget);
gtk_widget_show(filesel); gtk_main();
return glob_export_browse_pressed;
gtk_main();
return glob_export_browse_pressed;
} }
/* End Export Browse */ /* End Export Browse */
/* /*
* Start Export code * Start Export code
*/ */
static gboolean cb_export_destroy(GtkWidget *widget) static gboolean cb_export_destroy(GtkWidget *widget) {
{ const char *filename;
const char *filename;
filename = gtk_entry_get_text(GTK_ENTRY(save_as_entry)); filename = gtk_entry_get_text(GTK_ENTRY(save_as_entry));
if (glob_cb_export_done) { if (glob_cb_export_done) {
glob_cb_export_done(widget, filename); glob_cb_export_done(widget, filename);
} }
clist_clear(GTK_CLIST(export_clist)); gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(ex
gtk_main_quit(); port_treeView))));
if (category_menu != NULL) {
GtkTreeModel *clearingmodel = gtk_combo_box_get_model(GTK_COMBO_BOX(cate
gory_menu));
gtk_list_store_clear(GTK_LIST_STORE(clearingmodel));
}
gtk_main_quit();
return FALSE; return FALSE;
} }
static void cb_ok(GtkWidget *widget, gpointer data) static void cb_ok(GtkWidget *widget, gpointer data) {
{ const char *filename;
const char *filename;
filename = gtk_entry_get_text(GTK_ENTRY(save_as_entry)); filename = gtk_entry_get_text(GTK_ENTRY(save_as_entry));
if (glob_cb_export_ok) { if (glob_cb_export_ok) {
glob_cb_export_ok(data, export_clist, glob_export_type, filename); glob_cb_export_ok(data, export_treeView, glob_export_type, filename);
} }
gtk_widget_destroy(data); gtk_widget_destroy(data);
} }
static void cb_export_browse(GtkWidget *widget, gpointer data) static void cb_export_browse(GtkWidget *widget, gpointer data) {
{ export_browse(GTK_WIDGET(data), glob_pref_export);
int r;
const char *svalue;
r = export_browse(GTK_WIDGET(data), glob_pref_export);
if (r==BROWSE_OK) {
if (glob_pref_export) {
get_pref(glob_pref_export, NULL, &svalue);
gtk_entry_set_text(GTK_ENTRY(save_as_entry), svalue);
}
}
} }
static void cb_export_quit(GtkWidget *widget, gpointer data) static void cb_export_quit(GtkWidget *widget, gpointer data) {
{ gtk_widget_destroy(data);
gtk_widget_destroy(data);
} }
static void cb_export_type(GtkWidget *widget, gpointer data) static void cb_export_type(GtkWidget *widget, gpointer data) {
{ glob_export_type = GPOINTER_TO_INT(data);
glob_export_type=GPOINTER_TO_INT(data);
} }
static void cb_export_category(GtkWidget *item, int selection) static void cb_export_category(GtkComboBox *item, int selection) {
{ if (!item) return;
if ((GTK_CHECK_MENU_ITEM(item))->active) { if (gtk_combo_box_get_active(GTK_COMBO_BOX(item)) < 0) {
export_category = selection; return;
jp_logf(JP_LOG_DEBUG, "cb_export_category() cat=%d\n", export_category); }
if (glob_cb_export_menu) { int selectedItem = get_selected_category_from_combo_box(item);
glob_cb_export_menu(export_clist, export_category); if (selectedItem == -1) {
} return;
gtk_clist_select_all(GTK_CLIST(export_clist)); }
jp_logf(JP_LOG_DEBUG, "Leaving cb_export_category()\n"); export_category = selectedItem;
} jp_logf(JP_LOG_DEBUG, "cb_export_category() cat=%d\n", export_category);
if (glob_cb_export_menu && export_treeView != NULL) {
glob_cb_export_menu(export_treeView, export_category);
gtk_tree_selection_select_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(
export_treeView)));
}
jp_logf(JP_LOG_DEBUG, "Leaving cb_export_category()\n");
//gtk_combo_box_set_active(GTK_COMBO_BOX(item), pos);
} }
int export_gui(GtkWidget *main_window, int export_gui(GtkWidget *main_window,
int w, int h, int x, int y, int w, int h, int x, int y,
int columns, int columns,
struct sorted_cats *sort_l, struct sorted_cats *sort_l,
int pref_export, int pref_export,
char *type_text[], char *type_text[],
int type_int[], int type_int[],
void (*cb_export_menu)(GtkWidget *clist, int category), GtkWidget *(*cb_init_menu)(),
void (*cb_export_menu)(GtkWidget *treeView, int category),
void (*cb_export_done)(GtkWidget *widget, void (*cb_export_done)(GtkWidget *widget,
const char *filename), const char *filename),
void (*cb_export_ok)(GtkWidget *export_window, void (*cb_export_ok)(GtkWidget *export_window,
GtkWidget *clist, GtkWidget *treeView,
int type, int type,
const char *filename) const char *filename)
) ) {
{ GtkWidget *export_window;
GtkWidget *export_window; GtkWidget *button;
GtkWidget *button; GtkWidget *vbox;
GtkWidget *vbox; GtkWidget *hbox;
GtkWidget *hbox;
GtkWidget *category_menu; GtkWidget *scrolled_window;
GtkWidget *cat_menu_item[NUM_CAT_ITEMS+1]; GtkWidget *label;
GtkWidget *scrolled_window; char title[256];
GtkWidget *label; GSList *group;
char title[256]; int i;
GSList *group; const char *svalue;
int i;
const char *svalue; jp_logf(JP_LOG_DEBUG, "export_gui()\n");
jp_logf(JP_LOG_DEBUG, "export_gui()\n"); export_category = CATEGORY_ALL;
export_category = CATEGORY_ALL; /* Set the export type to the first type available */
glob_export_type = type_int[0];
/* Set the export type to the first type available */ glob_cb_init_menu = cb_init_menu;
glob_export_type = type_int[0]; glob_cb_export_menu = cb_export_menu;
glob_cb_export_menu = cb_export_menu; glob_cb_export_done = cb_export_done;
glob_cb_export_done = cb_export_done; glob_cb_export_ok = cb_export_ok;
glob_cb_export_ok = cb_export_ok;
glob_pref_export = pref_export;
glob_pref_export=pref_export;
g_snprintf(title, sizeof(title), "%s %s", PN, _("Export"));
g_snprintf(title, sizeof(title), "%s %s", PN, _("Export"));
export_window = gtk_widget_new(GTK_TYPE_WINDOW,
export_window = gtk_widget_new(GTK_TYPE_WINDOW, "type", GTK_WINDOW_TOPLEVEL,
"type", GTK_WINDOW_TOPLEVEL, "title", title,
"title", title, NULL);
NULL);
gtk_window_set_default_size(GTK_WINDOW(export_window), w, h);
gtk_window_set_default_size(GTK_WINDOW(export_window), w, h); //gtk_widget_set_uposition(GTK_WIDGET(export_window), x, y);
gtk_widget_set_uposition(GTK_WIDGET(export_window), x, y);
gtk_window_set_modal(GTK_WINDOW(export_window), TRUE);
gtk_window_set_modal(GTK_WINDOW(export_window), TRUE); gtk_window_set_transient_for(GTK_WINDOW(export_window), GTK_WINDOW(main_wind
gtk_window_set_transient_for(GTK_WINDOW(export_window), GTK_WINDOW(main_windo ow));
w));
gtk_container_set_border_width(GTK_CONTAINER(export_window), 5);
gtk_container_set_border_width(GTK_CONTAINER(export_window), 5);
g_signal_connect(G_OBJECT(export_window), "destroy",
gtk_signal_connect(GTK_OBJECT(export_window), "destroy", G_CALLBACK(cb_export_destroy), export_window);
GTK_SIGNAL_FUNC(cb_export_destroy), export_window);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(export_window), vbox);
gtk_container_add(GTK_CONTAINER(export_window), vbox);
/* Label for instructions */
/* Label for instructions */ label = gtk_label_new(_("Select records to be exported"));
label = gtk_label_new(_("Select records to be exported")); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); label = gtk_label_new(_("Use Ctrl and Shift Keys"));
label = gtk_label_new(_("Use Ctrl and Shift Keys")); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
/* Put the export category menu up */
/* Put the export category menu up */ if (category_menu && GTK_IS_COMBO_BOX(category_menu)) {
make_category_menu(&category_menu, cat_menu_item, sort_l, GtkTreeModel *clearingmodel = gtk_combo_box_get_model(GTK_COMBO_BOX(cate
cb_export_category, TRUE, FALSE); gory_menu));
gtk_box_pack_start(GTK_BOX(vbox), category_menu, FALSE, FALSE, 0); gtk_list_store_clear(GTK_LIST_STORE(clearingmodel));
}
/* Put the record list window up */ make_category_menu(&category_menu, sort_l,
scrolled_window = gtk_scrolled_window_new(NULL, NULL); cb_export_category, TRUE, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 0); gtk_combo_box_set_active(GTK_COMBO_BOX(category_menu), 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), gtk_box_pack_start(GTK_BOX(vbox), category_menu, FALSE, FALSE, 0);
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); /* Put the record list window up */
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
export_clist = gtk_clist_new(columns); gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
gtk_clist_set_shadow_type(GTK_CLIST(export_clist), SHADOW); GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_clist_set_selection_mode(GTK_CLIST(export_clist), GTK_SELECTION_EXTENDED) gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
;
for (i=0; i<columns; i++) { if (glob_cb_init_menu) {
gtk_clist_set_column_auto_resize(GTK_CLIST(export_clist), i, TRUE); export_treeView = glob_cb_init_menu();
} } else {
export_treeView = gtk_tree_view_new();
gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(export_clist)); }
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(export
/* Export Type buttons */ _treeView)),
group = NULL; GTK_SELECTION_MULTIPLE);
for (i=0; i<100; i++) { gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(export_treeView), gtk_false(
if (type_text[i]==NULL) break; ));
export_radio_type[i] = gtk_radio_button_new_with_label(group, _(type_text[
i])); gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(export_treeView
group = gtk_radio_button_group(GTK_RADIO_BUTTON(export_radio_type[i])); ));
gtk_box_pack_start(GTK_BOX(vbox), export_radio_type[i], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(export_radio_type[i]), "pressed", /* Export Type buttons */
GTK_SIGNAL_FUNC(cb_export_type), group = NULL;
GINT_TO_POINTER(type_int[i])); for (i = 0; i < 100; i++) {
} if (type_text[i] == NULL) break;
export_radio_type[i] = NULL; export_radio_type[i] = gtk_radio_button_new_with_label(group, _(type_tex
t[i]));
/* Save As entry */ group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(export_radio_type[i]
hbox = gtk_hbox_new(FALSE, 5); ));
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), export_radio_type[i], FALSE, FALSE, 0)
label = gtk_label_new(_("Save as")); ;
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(export_radio_type[i]), "pressed",
save_as_entry = gtk_entry_new_with_max_length(250); G_CALLBACK(cb_export_type),
svalue=NULL; GINT_TO_POINTER(type_int[i]));
if (glob_pref_export) { }
get_pref(glob_pref_export, NULL, &svalue); export_radio_type[i] = NULL;
}
if (svalue) { /* Save As entry */
gtk_entry_set_text(GTK_ENTRY(save_as_entry), svalue); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
} gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), save_as_entry, TRUE, TRUE, 0); label = gtk_label_new(_("Save as"));
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
/* Browse button */ save_as_entry = gtk_entry_new();
button = gtk_button_new_with_label(_("Browse")); gtk_entry_set_max_length(GTK_ENTRY(save_as_entry), 250);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); svalue = NULL;
gtk_signal_connect(GTK_OBJECT(button), "clicked", if (glob_pref_export) {
GTK_SIGNAL_FUNC(cb_export_browse), export_window); get_pref(glob_pref_export, NULL, &svalue);
}
/* Cancel/OK buttons */ if (svalue) {
hbox = gtk_hbutton_box_new(); gtk_entry_set_text(GTK_ENTRY(save_as_entry), svalue);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 12); }
gtk_button_box_set_layout(GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END); gtk_box_pack_start(GTK_BOX(hbox), save_as_entry, TRUE, TRUE, 0);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), 6);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); /* Browse button */
button = gtk_button_new_with_label(_("Browse"));
button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked",
gtk_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(cb_export_browse), export_window);
GTK_SIGNAL_FUNC(cb_export_quit), export_window);
/* Cancel/OK buttons */
button = gtk_button_new_from_stock(GTK_STOCK_OK); hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
gtk_signal_connect(GTK_OBJECT(button), "clicked", gtk_button_box_set_layout(GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
GTK_SIGNAL_FUNC(cb_ok), export_window); gtk_box_set_spacing(GTK_BOX(hbox), 6);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
if (glob_cb_export_menu) {
glob_cb_export_menu(export_clist, export_category); button = gtk_button_new_with_label("Cancel");
} gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(cb_export_quit), export_window);
button = gtk_button_new_with_label("OK");
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(cb_ok), export_window);
if (glob_cb_export_menu) {
glob_cb_export_menu(GTK_WIDGET(export_treeView), export_category);
}
gtk_widget_show_all(export_window); gtk_widget_show_all(export_window);
gtk_clist_select_all(GTK_CLIST(export_clist)); gtk_tree_selection_select_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(expo rt_treeView)));
gtk_main(); gtk_main();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
 End of changes. 27 change blocks. 
262 lines changed or deleted 274 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)