"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "install_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.

install_gui.c  (jpilot-1.8.2):install_gui.c  (jpilot-2_0_1)
skipping to change at line 40 skipping to change at line 40
#include "i18n.h" #include "i18n.h"
#include "utils.h" #include "utils.h"
#include "prefs.h" #include "prefs.h"
#include "log.h" #include "log.h"
/********************************* Constants **********************************/ /********************************* Constants **********************************/
#define INST_SDCARD_COLUMN 0 #define INST_SDCARD_COLUMN 0
#define INST_FNAME_COLUMN 1 #define INST_FNAME_COLUMN 1
/******************************* Global vars **********************************/ /******************************* Global vars **********************************/
static GtkWidget *filew=NULL; static GtkWidget *treeView;
static GtkWidget *clist; static GtkListStore *listStore;
static int clist_row_selected; static int row_selected;
static int column_selected;
enum {
INSTALL_SDCARD_COLUMN_ENUM = 0,
INSTALL_FNAME_COLUMN_ENUM,
INSTALL_DATA_COLUMN_ENUM,
INSTALL_BACKGROUND_COLOR_ENUM,
INSTALL_BACKGROUND_COLOR_ENABLED_ENUM,
INSTALL_NUM_COLS
};
/****************************** Prototypes ************************************/ /****************************** Prototypes ************************************/
static int install_update_clist(void); static int install_update_listStore(void);
/****************************** Main Code *************************************/ /****************************** Main Code *************************************/
static int install_remove_line(int deleted_line_num) static int install_remove_line(int deleted_line_num) {
{ FILE *in;
FILE *in; FILE *out;
FILE *out; char line[1002];
char line[1002]; char *Pc;
char *Pc; int r, line_count;
int r, line_count;
in = jp_open_home_file(EPN".install", "r");
in = jp_open_home_file(EPN".install", "r"); if (!in) {
if (!in) { jp_logf(JP_LOG_DEBUG, "failed opening install_file\n");
jp_logf(JP_LOG_DEBUG, "failed opening install_file\n"); return EXIT_FAILURE;
return EXIT_FAILURE; }
}
out = jp_open_home_file(EPN".install.tmp", "w");
out = jp_open_home_file(EPN".install.tmp", "w"); if (!out) {
if (!out) { fclose(in);
fclose(in); jp_logf(JP_LOG_DEBUG, "failed opening install_file.tmp\n");
jp_logf(JP_LOG_DEBUG, "failed opening install_file.tmp\n"); return EXIT_FAILURE;
return EXIT_FAILURE; }
}
/* Delete line by copying file and skipping over line to delete */
/* Delete line by copying file and skipping over line to delete */ for (line_count = 0; !feof(in); line_count++) {
for (line_count=0; !feof(in); line_count++) { line[0] = '\0';
line[0]='\0'; Pc = fgets(line, 1000, in);
Pc = fgets(line, 1000, in); if (!Pc) {
if (!Pc) { break;
break; }
} if (line_count == deleted_line_num) {
if (line_count == deleted_line_num) { continue;
continue; }
} r = fprintf(out, "%s", line);
r = fprintf(out, "%s", line); if (r == EOF) {
if (r==EOF) { break;
break; }
} }
} fclose(in);
fclose(in); fclose(out);
fclose(out);
rename_file(EPN".install.tmp", EPN".install");
return EXIT_SUCCESS;
}
int install_append_line(const char *line)
{
FILE *out;
int r;
out = jp_open_home_file(EPN".install", "a");
if (!out) {
return EXIT_FAILURE;
}
r = fprintf(out, "%s\n", line);
if (r==EOF) {
fclose(out);
return EXIT_FAILURE;
}
fclose(out);
return EXIT_SUCCESS;
}
static int install_modify_line(int modified_line_num, const char *modified_line)
{
FILE *in;
FILE *out;
char line[1002];
char *Pc;
int r, line_count;
in = jp_open_home_file(EPN".install", "r");
if (!in) {
jp_logf(JP_LOG_DEBUG, "failed opening install_file\n");
return EXIT_FAILURE;
}
out = jp_open_home_file(EPN".install.tmp", "w");
if (!out) {
fclose(in);
jp_logf(JP_LOG_DEBUG, "failed opening install_file.tmp\n");
return EXIT_FAILURE;
}
/* Delete line by copying file and skipping over line to delete */
for (line_count=0; !feof(in); line_count++) {
line[0]='\0';
Pc = fgets(line, 1000, in);
if (!Pc) {
break;
}
if (line_count == modified_line_num) {
r = fprintf(out, "%s\n", modified_line);
} else {
r = fprintf(out, "%s", line);
}
if (r==EOF) {
break;
}
}
fclose(in);
fclose(out);
rename_file(EPN".install.tmp", EPN".install");
return EXIT_SUCCESS;
}
static gboolean cb_destroy(GtkWidget *widget)
{
filew = NULL;
gtk_main_quit(); rename_file(EPN".install.tmp", EPN".install");
return TRUE; return EXIT_SUCCESS;
} }
/* Save working directory for future installs */ int install_append_line(const char *line) {
static void cb_quit(GtkWidget *widget, gpointer data) FILE *out;
{ int r;
const char *sel;
char dir[MAX_PREF_LEN+2]; out = jp_open_home_file(EPN".install", "a");
struct stat statb; if (!out) {
int i; return EXIT_FAILURE;
}
jp_logf(JP_LOG_DEBUG, "Quit\n");
r = fprintf(out, "%s\n", line);
sel = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)); if (r == EOF) {
fclose(out);
g_strlcpy(dir, sel, MAX_PREF_LEN); return EXIT_FAILURE;
}
if (stat(sel, &statb)) { fclose(out);
jp_logf(JP_LOG_WARN, "File selected was not stat-able\n");
} return EXIT_SUCCESS;
}
if (S_ISDIR(statb.st_mode)) {
/* For directory, add '/' indicator to path */ static int install_modify_line(int modified_line_num, const char *modified_line)
i = strlen(dir); {
dir[i]='/', dir[i+1]='\0'; FILE *in;
} else { FILE *out;
/* Otherwise, strip off filename to find actual directory */ char line[1002];
for (i=strlen(dir); i>=0; i--) { char *Pc;
if (dir[i]=='/') { int r, line_count;
dir[i+1]='\0';
in = jp_open_home_file(EPN".install", "r");
if (!in) {
jp_logf(JP_LOG_DEBUG, "failed opening install_file\n");
return EXIT_FAILURE;
}
out = jp_open_home_file(EPN".install.tmp", "w");
if (!out) {
fclose(in);
jp_logf(JP_LOG_DEBUG, "failed opening install_file.tmp\n");
return EXIT_FAILURE;
}
/* Delete line by copying file and skipping over line to delete */
for (line_count = 0; !feof(in); line_count++) {
line[0] = '\0';
Pc = fgets(line, 1000, in);
if (!Pc) {
break; break;
} }
} if (line_count == modified_line_num) {
} r = fprintf(out, "%s\n", modified_line);
} else {
set_pref(PREF_INSTALL_PATH, 0, dir, TRUE); r = fprintf(out, "%s", line);
}
filew = NULL; if (r == EOF) {
break;
gtk_widget_destroy(data); }
} }
fclose(in);
static void cb_add(GtkWidget *widget, gpointer data) fclose(out);
{
const char *sel; rename_file(EPN".install.tmp", EPN".install");
struct stat statb;
jp_logf(JP_LOG_DEBUG, "install: cb_add\n");
sel = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data));
jp_logf(JP_LOG_DEBUG, "file selected [%s]\n", sel);
/* Check to see if its a regular file */
if (stat(sel, &statb)) {
jp_logf(JP_LOG_DEBUG, "File selected was not stat-able\n");
return;
}
if (!S_ISREG(statb.st_mode)) {
jp_logf(JP_LOG_DEBUG, "File selected was not a regular file\n");
return;
}
install_append_line(sel);
install_update_clist();
}
static void cb_remove(GtkWidget *widget, gpointer data)
{
if (clist_row_selected < 0) {
return;
}
jp_logf(JP_LOG_DEBUG, "Remove line %d\n", clist_row_selected);
install_remove_line(clist_row_selected);
install_update_clist();
}
static void cb_clist_selection(GtkWidget *clist,
gint row,
gint column,
GdkEventButton *event,
gpointer data)
{
char fname[1000];
char *gtk_str;
clist_row_selected = row;
if (column == INST_SDCARD_COLUMN) {
/* Toggle display of SDCARD pixmap */
if (gtk_clist_get_text(GTK_CLIST(clist), row, column, NULL)) {
GdkPixmap *pixmap;
GdkBitmap *mask;
get_pixmaps(clist, PIXMAP_SDCARD, &pixmap, &mask);
gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, mask);
gtk_clist_get_text(GTK_CLIST(clist), row, INST_FNAME_COLUMN, &gtk_str);
fname[0] = '\001';
g_strlcpy(&fname[1], gtk_str, sizeof(fname)-1);
install_modify_line(row, fname);
} else {
gtk_clist_set_text(GTK_CLIST(clist), row, column, "");
gtk_clist_get_text(GTK_CLIST(clist), row, INST_FNAME_COLUMN, &gtk_str);
g_strlcpy(&fname[0], gtk_str, sizeof(fname));
install_modify_line(row, fname);
}
}
return;
}
static int install_update_clist(void)
{
FILE *in;
char line[1002];
char *Pc;
char *new_line[3];
int last_row_selected;
int count;
int len;
int sdcard_install;
new_line[0]="";
new_line[1]=line;
new_line[2]=NULL;
last_row_selected = clist_row_selected;
in = jp_open_home_file(EPN".install", "r");
if (!in) {
return EXIT_FAILURE;
}
gtk_signal_disconnect_by_func(GTK_OBJECT(clist),
GTK_SIGNAL_FUNC(cb_clist_selection), NULL);
gtk_clist_freeze(GTK_CLIST(clist));
gtk_clist_clear(GTK_CLIST(clist));
#ifdef __APPLE__
gtk_clist_thaw(GTK_CLIST(clist));
gtk_widget_hide(clist);
gtk_widget_show_all(clist);
gtk_clist_freeze(GTK_CLIST(clist));
#endif
for (count=0; !feof(in); count++) { return EXIT_SUCCESS;
line[0]='\0'; }
Pc = fgets(line, 1000, in);
if (!Pc) { static gboolean cb_destroy(GtkWidget *widget) {
break; gtk_widget_destroy(GTK_WIDGET(widget));
} return TRUE;
}
/* Strip newline characters from end of string */
len=strlen(line); /* Save working directory for future installs */
if ((line[len-1]=='\n') || (line[len-1]=='\r')) line[len-1]='\0'; /* FIXME: find out why this is no longer used */
if ((line[len-2]=='\n') || (line[len-2]=='\r')) line[len-2]='\0'; #if 0
static void cb_quit(GtkWidget *widget, gpointer data) {
sdcard_install = (line[0] == '\001'); const gchar *sel;
/* Strip char indicating SDCARD install from start of string */ char dir[MAX_PREF_LEN + 2];
if (sdcard_install) { struct stat statb;
new_line[1] = &line[1]; int i;
} else {
new_line[1] = &line[0]; jp_logf(JP_LOG_DEBUG, "Quit\n");
}
sel = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
gtk_clist_append(GTK_CLIST(clist), new_line);
g_strlcpy(dir, sel, MAX_PREF_LEN);
/* Add SDCARD icon for files to be installed on SDCARD */
if (sdcard_install) { if (stat(sel, &statb)) {
GdkPixmap *pixmap; jp_logf(JP_LOG_WARN, "File selected was not stat-able\n");
GdkBitmap *mask; }
get_pixmaps(clist, PIXMAP_SDCARD, &pixmap, &mask);
gtk_clist_set_pixmap(GTK_CLIST(clist), count, INST_SDCARD_COLUMN, pixma if (S_ISDIR(statb.st_mode)) {
p, mask); /* For directory, add '/' indicator to path */
} i = strlen(dir);
} dir[i] = '/', dir[i + 1] = '\0';
fclose(in); } else {
/* Otherwise, strip off filename to find actual directory */
gtk_signal_connect(GTK_OBJECT(clist), "select_row", for (i = strlen(dir); i >= 0; i--) {
GTK_SIGNAL_FUNC(cb_clist_selection), NULL); if (dir[i] == '/') {
dir[i + 1] = '\0';
if (last_row_selected > count-1) { break;
last_row_selected = count - 1; }
} }
if (last_row_selected >= 0) { }
clist_select_row(GTK_CLIST(clist), last_row_selected, INST_FNAME_COLUMN);
} set_pref(PREF_INSTALL_PATH, 0, dir, TRUE);
gtk_clist_thaw(GTK_CLIST(clist));
gtk_widget_destroy(GTK_WIDGET(widget));
return EXIT_SUCCESS; }
}
int install_gui(GtkWidget *main_window, int w, int h, int x, int y)
{
GtkWidget *scrolled_window;
GtkWidget *button;
GtkWidget *label;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
char temp_str[256];
const char *svalue;
gchar *titles[] = {"", _("Files to install")};
if (filew) {
return EXIT_SUCCESS;
}
clist_row_selected = 0;
g_snprintf(temp_str, sizeof(temp_str), "%s %s", PN, _("Install"));
filew = gtk_widget_new(GTK_TYPE_FILE_SELECTION,
"type", GTK_WINDOW_TOPLEVEL,
"title", temp_str,
NULL);
gtk_window_set_default_size(GTK_WINDOW(filew), w, h);
gtk_widget_set_uposition(filew, x, y);
gtk_window_set_modal(GTK_WINDOW(filew), TRUE);
gtk_window_set_transient_for(GTK_WINDOW(filew), GTK_WINDOW(main_window));
get_pref(PREF_INSTALL_PATH, NULL, &svalue);
if (svalue && svalue[0]) {
gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), svalue);
}
gtk_file_selection_hide_fileop_buttons((gpointer) filew);
gtk_widget_hide((GTK_FILE_SELECTION(filew)->cancel_button));
gtk_signal_connect(GTK_OBJECT(filew), "destroy",
GTK_SIGNAL_FUNC(cb_destroy), filew);
/* Even though I hide the ok button I still want to connect its signal */
/* because a double click on the file name also calls this callback */
gtk_widget_hide(GTK_WIDGET(GTK_FILE_SELECTION(filew)->ok_button));
gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->ok_button),
"clicked", GTK_SIGNAL_FUNC(cb_add), filew);
clist = gtk_clist_new_with_titles(2, titles);
gtk_widget_set_usize(GTK_WIDGET(clist), 0, 166);
gtk_clist_column_titles_passive(GTK_CLIST(clist));
gtk_clist_set_column_auto_resize(GTK_CLIST(clist), INST_SDCARD_COLUMN, TRUE);
gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_BROWSE);
get_pixmaps(clist, PIXMAP_SDCARD, &pixmap, &mask);
#ifdef __APPLE__
mask = NULL;
#endif #endif
pixmapwid = gtk_pixmap_new(pixmap, mask);
gtk_clist_set_column_widget(GTK_CLIST(clist), INST_SDCARD_COLUMN, pixmapwid);
gtk_clist_set_column_justification(GTK_CLIST(clist), INST_SDCARD_COLUMN, GTK_
JUSTIFY_CENTER);
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
GTK_SIGNAL_FUNC(cb_clist_selection), NULL);
/* Scrolled Window for file list */
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(clist));
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 5);
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->action_area),
scrolled_window, TRUE, TRUE, 0);
label = gtk_label_new(_("To change to a hidden directory type it below and hi
t TAB"));
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->main_vbox),
label, FALSE, FALSE, 0);
/* Add/Remove/Quit buttons */
button = gtk_button_new_from_stock(GTK_STOCK_ADD);
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->ok_button->parent),
button, TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT(button),
"clicked", GTK_SIGNAL_FUNC(cb_add), filew);
button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->ok_button->parent),
button, TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT(button),
"clicked", GTK_SIGNAL_FUNC(cb_remove), filew);
button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filew)->ok_button->parent),
button, TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT(button),
"clicked", GTK_SIGNAL_FUNC(cb_quit), filew);
/**********************************************************************/
gtk_widget_show_all(filew);
/* Hide default buttons not used by Jpilot file selector */
gtk_widget_hide(GTK_FILE_SELECTION(filew)->cancel_button);
gtk_widget_hide(GTK_FILE_SELECTION(filew)->ok_button);
install_update_clist(); static void cb_add(GtkWidget *widget, gpointer data) {
const char *sel;
struct stat statb;
jp_logf(JP_LOG_DEBUG, "install: cb_add\n");
sel = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
jp_logf(JP_LOG_DEBUG, "file selected [%s]\n", sel);
/* Check to see if its a regular file */
if (stat(sel, &statb)) {
jp_logf(JP_LOG_DEBUG, "File selected was not stat-able\n");
return;
}
if (!S_ISREG(statb.st_mode)) {
jp_logf(JP_LOG_DEBUG, "File selected was not a regular file\n");
return;
}
install_append_line(sel);
install_update_listStore();
}
static void cb_remove(GtkWidget *widget, gpointer data) {
if (row_selected < 0) {
return;
}
jp_logf(JP_LOG_DEBUG, "Remove line %d\n", row_selected);
install_remove_line(row_selected);
install_update_listStore();
}
gboolean
selectInstallRecordByRow (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data) {
int * i = gtk_tree_path_get_indices ( path ) ;
if(i[0] == row_selected){
GtkTreeSelection * selection = NULL;
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeView));
gtk_tree_selection_select_path(selection, path);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeView), path, INSTALL_SDC
ARD_COLUMN_ENUM,FALSE, 1.0, 0.0);
return TRUE;
}
return FALSE;
}
static int install_update_listStore(void) {
GtkTreeIter iter;
GdkPixbuf *sdCardColumnDisplay;
FILE *in;
char line[1002];
char *Pc;
char *new_line[3];
int last_row_selected;
int count;
int len;
int sdcard_install;
new_line[0] = "";
new_line[1] = line;
new_line[2] = NULL;
last_row_selected = row_selected;
in = jp_open_home_file(EPN".install", "r");
if (!in) {
return EXIT_FAILURE;
}
gtk_list_store_clear(listStore);
for (count = 0; !feof(in); count++) {
line[0] = '\0';
sdCardColumnDisplay = NULL;
Pc = fgets(line, 1000, in);
if (!Pc) {
break;
}
/* Strip newline characters from end of string */
len = strlen(line);
if ((line[len - 1] == '\n') || (line[len - 1] == '\r')) line[len - 1] =
'\0';
if ((line[len - 2] == '\n') || (line[len - 2] == '\r')) line[len - 2] =
'\0';
sdcard_install = (line[0] == '\001');
/* Strip char indicating SDCARD install from start of string */
if (sdcard_install) {
new_line[1] = &line[1];
} else {
new_line[1] = &line[0];
}
/* Add SDCARD icon for files to be installed on SDCARD */
if (sdcard_install) {
get_pixbufs(PIXMAP_SDCARD, &sdCardColumnDisplay);
}
gtk_list_store_append(listStore, &iter);
gtk_list_store_set(listStore, &iter,
INSTALL_SDCARD_COLUMN_ENUM, sdCardColumnDisplay,
INSTALL_FNAME_COLUMN_ENUM, new_line[1],
-1);
}
fclose(in);
if (last_row_selected > count - 1) {
last_row_selected = count - 1;
}
if (last_row_selected >= 0) {
row_selected = last_row_selected;
gtk_tree_model_foreach(GTK_TREE_MODEL(listStore), selectInstallRecordByR
ow, NULL);
}
return EXIT_SUCCESS;
}
void
columnClicked (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data){
GtkTreeIter iter;
column_selected = gtk_tree_view_column_get_sort_column_id(column);
char fname[1000];
char *gtk_str;
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(listStore), &iter, path)) {
int *i = gtk_tree_path_get_indices(path);
GdkPixbuf *sdCardColumnDisplay = NULL;
if (column_selected == INSTALL_SDCARD_COLUMN_ENUM) {
/* Toggle display of SDCARD pixmap */
gtk_tree_model_get(GTK_TREE_MODEL(listStore),&iter,INSTALL_SDCARD_CO
LUMN_ENUM,&sdCardColumnDisplay,
INSTALL_FNAME_COLUMN_ENUM,&gtk_str,-1);
if (sdCardColumnDisplay == NULL) {
fname[0] = '\001';
g_strlcpy(&fname[1], gtk_str, sizeof(fname) - 1);
install_modify_line(i[0], fname);
} else {
g_strlcpy(&fname[0], gtk_str, sizeof(fname));
install_modify_line(i[0], fname);
}
install_update_listStore();
}
}
}
static gboolean handleInstallRowSelection(GtkTreeSelection *selection,
GtkTreeModel *model,
GtkTreePath *path,
gboolean path_currently_selected,
gpointer userdata) {
GtkTreeIter iter;
if ((gtk_tree_model_get_iter(model, &iter, path)) && (!path_currently_select
ed)) {
int *i = gtk_tree_path_get_indices(path);
row_selected = i[0];
}
return TRUE;
}
void intializeInstallTreeView(GtkWidget *pixbufwid, GdkPixbuf **pixbuf) {
listStore = gtk_list_store_new(INSTALL_NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STR
ING, G_TYPE_POINTER,
GDK_TYPE_RGBA, G_TYPE_BOOLEAN);
treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(listStore));
GtkCellRenderer *sdRenderer = gtk_cell_renderer_pixbuf_new();
GtkTreeViewColumn *sdColumn = gtk_tree_view_column_new_with_attributes("",
sdRen
derer,
"pixb
uf", INSTALL_SDCARD_COLUMN_ENUM,
"cell
-background-rgba",
INSTA
LL_BACKGROUND_COLOR_ENUM,
"cell
-background-set",
INSTA
LL_BACKGROUND_COLOR_ENABLED_ENUM,
NULL)
;
gtk_tree_view_column_set_sort_column_id(sdColumn,INSTALL_SDCARD_COLUMN_ENUM)
;
GtkCellRenderer *fileNameRenderer = gtk_cell_renderer_text_new();
GtkTreeViewColumn *fileNameColumn = gtk_tree_view_column_new_with_attributes
("Files to install",
fileNameRenderer,
"text", INSTALL_FNAME_COLUMN_ENUM,
"cell-background-rgba",
INSTALL_BACKGROUND_COLOR_ENUM,
"cell-background-set",
INSTALL_BACKGROUND_COLOR_ENABLED_ENUM,
NULL);
gtk_tree_view_column_set_sort_column_id(fileNameColumn,INSTALL_FNAME_COLUMN_
ENUM);
gtk_tree_view_column_set_clickable(sdColumn, gtk_false());
gtk_tree_view_column_set_clickable(fileNameColumn, gtk_false());
gtk_tree_view_column_set_sizing(sdColumn, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_widget_set_size_request(GTK_WIDGET(treeView), 0, 166);
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeVi
ew)),
GTK_SELECTION_BROWSE);
gtk_tree_view_insert_column(GTK_TREE_VIEW (treeView), sdColumn, INSTALL_SDCA
RD_COLUMN_ENUM);
gtk_tree_view_insert_column(GTK_TREE_VIEW (treeView), fileNameColumn, INSTAL
L_FNAME_COLUMN_ENUM);
get_pixbufs(PIXMAP_SDCARD, pixbuf);
pixbufwid = gtk_image_new_from_pixbuf((*pixbuf));
gtk_widget_show(GTK_WIDGET(pixbufwid));
gtk_tree_view_column_set_widget(sdColumn, pixbufwid);
gtk_tree_view_column_set_alignment(sdColumn, GTK_JUSTIFY_CENTER);
GtkTreeSelection *treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
treeView));
column_selected = -1;
gtk_tree_selection_set_select_function(treeSelection, handleInstallRowSelect
ion, NULL, NULL);
gtk_widget_set_events(treeView, GDK_BUTTON1_MOTION_MASK);
g_signal_connect (G_OBJECT(treeView), "motion_notify_event",
G_CALLBACK(motion_notify_event), NULL);
g_signal_connect (G_OBJECT(treeView), "button-press-event",
G_CALLBACK(button_pressed_for_motion), NULL);
g_signal_connect (G_OBJECT(treeView), "button-release-event",
G_CALLBACK(button_released_for_motion), NULL);
gtk_tree_view_set_activate_on_single_click(GTK_TREE_VIEW(treeView), TRUE);
g_signal_connect (treeView, "row-activated", G_CALLBACK(columnClicked), NULL
);
}
int install_gui(GtkWidget *main_window, int w, int h, int x, int y) {
GtkWidget *pixbufwid;
GdkPixbuf *pixbuf;
char temp_str[256];
const char *svalue;
GtkWidget *fileChooserWidget;
row_selected = 0;
pixbufwid = NULL;
intializeInstallTreeView(pixbufwid, &pixbuf);
install_update_listStore();
g_snprintf(temp_str, sizeof(temp_str), "%s %s", PN, _("Install"));
fileChooserWidget = gtk_file_chooser_dialog_new(_("Install"), GTK_WINDOW(mai
n_window), GTK_FILE_CHOOSER_ACTION_OPEN,
"_Add", GTK_RESPONSE_ACCEPT,
"_Delete", GTK_RESPONSE_DELETE_EVENT,
"Close",GTK_RESPONSE_CLOSE,
NULL);
get_pref(PREF_INSTALL_PATH, NULL, &svalue);
if (svalue && svalue[0]) {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooserWidget),
svalue);
}
GtkBox *extraWidget = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
gtk_box_pack_start(extraWidget,treeView,TRUE,TRUE,0);
gtk_widget_show_all(GTK_WIDGET(extraWidget));
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(fileChooserWidget), GTK_W
IDGET(extraWidget));
g_signal_connect(G_OBJECT(fileChooserWidget), "destroy",
G_CALLBACK(cb_destroy), fileChooserWidget);
int dialogResponse = gtk_dialog_run(GTK_DIALOG(fileChooserWidget));
do {
if(dialogResponse == GTK_RESPONSE_DELETE_EVENT){
//remove from list
cb_remove(fileChooserWidget,fileChooserWidget);
} else if(dialogResponse == GTK_RESPONSE_ACCEPT){
// add to list.
cb_add(fileChooserWidget,fileChooserWidget);
} else {
// handle close and destroy widget.
cb_destroy(fileChooserWidget);
}
if(dialogResponse != GTK_RESPONSE_CLOSE){
dialogResponse = gtk_dialog_run(GTK_DIALOG (fileChooserWidget));
}
} while (dialogResponse != GTK_RESPONSE_CLOSE);
gtk_widget_destroy(GTK_WIDGET(fileChooserWidget));
gtk_main(); // gtk_main();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
 End of changes. 12 change blocks. 
412 lines changed or deleted 452 lines changed or added

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