aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2019-07-09 18:32:15 -0400
committerJason Woodward2019-07-12 03:34:44 +0000
commitd0478181f6b0cb0743da65c330a42550f9efb60d (patch)
treef94ff41bcb07cf458885f079974d497eff102f48
parent6c45c58e938584cbcd5bf56e0e30f4fce59b0f5a (diff)
downloadgslapt-d0478181f6b0cb0743da65c330a42550f9efb60d.tar.gz
clang-format
-rw-r--r--.clang-format37
-rw-r--r--src/callbacks.c6436
-rw-r--r--src/callbacks.h170
-rw-r--r--src/main.c365
-rw-r--r--src/series.c129
-rw-r--r--src/settings.c241
-rw-r--r--src/settings.h26
7 files changed, 3570 insertions, 3834 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..7952c63
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,37 @@
+´╗┐Language: Cpp
+IndentWidth: 4
+AllowShortFunctionsOnASingleLine: None
+KeepEmptyLinesAtTheStartOfBlocks: false
+ColumnLimit: 0
+UseTab: Never
+TabWidth: 4
+# BreakBeforeBraces: Linux
+BreakBeforeBraces: Custom
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: false
+ AfterEnum: false
+ AfterFunction: true
+ AfterNamespace: false
+ AfterObjCDeclaration: true
+ AfterStruct: false
+ AfterUnion: false
+ AfterExternBlock: true
+ BeforeCatch: true
+ BeforeElse: false
+ IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+PointerBindsToType: false
+SortIncludes: false
+ForEachMacros: [
+'slapt_vector_t_foreach',
+]
+SpaceBeforeParens: ControlStatements
+SpaceBeforeAssignmentOperators: true
+AlignAfterOpenBracket: true
+AlignConsecutiveAssignments: false
+SpaceBeforeRangeBasedForLoopColon: true
+# SpacesBeforeTrailingComments: true
+SpacesInParentheses: false
diff --git a/src/callbacks.c b/src/callbacks.c
index 24faf18..a3d5ad1 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#define _GNU_SOURCE
@@ -38,4080 +38,3792 @@ extern slapt_vector_t *installed;
extern slapt_transaction_t *trans;
extern char rc_location[];
-
static GtkWidget *progress_window;
static GtkBuilder *progress_window_builder = NULL;
static GtkWidget *preferences_window;
static GtkBuilder *preferences_window_builder = NULL;
-G_LOCK_DEFINE_STATIC (_cancelled);
+G_LOCK_DEFINE_STATIC(_cancelled);
static volatile guint _cancelled = 0;
static gboolean sources_modified = FALSE;
static gboolean excludes_modified = FALSE;
static volatile guint pending_trans_context_id = 0;
-static gboolean pkg_action_popup_menu (GtkTreeView *treeview, gpointer data);
-static int set_iter_to_pkg (GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg);
-static slapt_pkg_upgrade_t *lsearch_upgrade_transaction (slapt_transaction_t *tran,slapt_pkg_info_t *pkg);
-static void build_package_action_menu (slapt_pkg_info_t *pkg);
-static void rebuild_package_action_menu (void);
-static void mark_upgrade_packages (void);
-static void fillin_pkg_details (slapt_pkg_info_t *pkg);
-static void get_package_data (void);
-static void rebuild_treeviews (GtkWidget *current_window,gboolean reload);
-static guint gslapt_set_status (const gchar *);
-static void gslapt_clear_status (guint context_id);
-static void lock_toolbar_buttons (void);
-static void unlock_toolbar_buttons (void);
-static void build_sources_treeviewlist (GtkWidget *treeview);
+static gboolean pkg_action_popup_menu(GtkTreeView *treeview, gpointer data);
+static int set_iter_to_pkg(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg);
+static slapt_pkg_upgrade_t *lsearch_upgrade_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg);
+static void build_package_action_menu(slapt_pkg_info_t *pkg);
+static void rebuild_package_action_menu(void);
+static void mark_upgrade_packages(void);
+static void fillin_pkg_details(slapt_pkg_info_t *pkg);
+static void get_package_data(void);
+static void rebuild_treeviews(GtkWidget *current_window, gboolean reload);
+static guint gslapt_set_status(const gchar *);
+static void gslapt_clear_status(guint context_id);
+static void lock_toolbar_buttons(void);
+static void unlock_toolbar_buttons(void);
+static void build_sources_treeviewlist(GtkWidget *treeview);
#ifdef SLAPT_HAS_GPGME
-static void build_verification_sources_treeviewlist (GtkWidget *treeview);
+static void build_verification_sources_treeviewlist(GtkWidget *treeview);
#endif
-static void build_exclude_treeviewlist (GtkWidget *treeview);
-static int populate_transaction_window (GtkBuilder *b);
-char *download_packages (void);
-static gboolean install_packages (void);
-static void set_execute_active (void);
-static void clear_execute_active (void);
-static void notify (const char *title,const char *message);
-static void reset_search_list (void);
-static int ladd_deps_to_trans (slapt_transaction_t *tran, slapt_vector_t *avail_pkgs,
- slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg);
-static gboolean toggle_source_status (GtkTreeView *treeview, gpointer data);
-static void display_dep_error_dialog (slapt_pkg_info_t *pkg);
-static void view_installed_or_available_packages (gboolean show_installed, gboolean show_available);
-
-static int set_iter_for_install(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg);
-static int set_iter_for_reinstall(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg);
-static int set_iter_for_downgrade(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg);
-static int set_iter_for_upgrade(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg);
-static int set_iter_for_remove(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg);
-
-static void set_busy_cursor (void);
-static void unset_busy_cursor (void);
+static void build_exclude_treeviewlist(GtkWidget *treeview);
+static int populate_transaction_window(GtkBuilder *b);
+char *download_packages(void);
+static gboolean install_packages(void);
+static void set_execute_active(void);
+static void clear_execute_active(void);
+static void notify(const char *title, const char *message);
+static void reset_search_list(void);
+static int ladd_deps_to_trans(slapt_transaction_t *tran, slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg);
+static gboolean toggle_source_status(GtkTreeView *treeview, gpointer data);
+static void display_dep_error_dialog(slapt_pkg_info_t *pkg);
+static void view_installed_or_available_packages(gboolean show_installed, gboolean show_available);
+
+static int set_iter_for_install(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg);
+static int set_iter_for_reinstall(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg);
+static int set_iter_for_downgrade(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg);
+static int set_iter_for_upgrade(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg);
+static int set_iter_for_remove(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg);
+
+static void set_busy_cursor(void);
+static void unset_busy_cursor(void);
static SLAPT_PRIORITY_T convert_gslapt_priority_to_slapt_priority(gint p);
static gint convert_slapt_priority_to_gslapt_priority(SLAPT_PRIORITY_T p);
gboolean gslapt_window_resized(GtkWindow *window, GdkEvent *event, gpointer data)
{
- const char *widget_name = gtk_buildable_get_name(GTK_BUILDABLE(window));
- gint x, y, width, height;
-
- x = event->configure.x;
- y = event->configure.y;
- width = event->configure.width;
- height = event->configure.height;
-
- if (strcmp(widget_name,"gslapt") == 0) {
- gslapt_settings->x = x;
- gslapt_settings->y = y;
- gslapt_settings->width = width;
- gslapt_settings->height = height;
- } else if (strcmp(widget_name,"window_preferences") == 0) {
- gslapt_settings->pref_x = x;
- gslapt_settings->pref_y = y;
- gslapt_settings->pref_width = width;
- gslapt_settings->pref_height = height;
- } else if (strcmp(widget_name,"changelog_window") == 0) {
- gslapt_settings->cl_x = x;
- gslapt_settings->cl_y = y;
- gslapt_settings->cl_width = width;
- gslapt_settings->cl_height = height;
- } else if (strcmp(widget_name,"transaction_window") == 0) {
- gslapt_settings->tran_x = x;
- gslapt_settings->tran_y = y;
- gslapt_settings->tran_width = width;
- gslapt_settings->tran_height = height;
- } else {
- fprintf(stderr, "need to handle widget name: %s\n", widget_name);
- }
-
- return FALSE;
+ const char *widget_name = gtk_buildable_get_name(GTK_BUILDABLE(window));
+ gint x, y, width, height;
+
+ x = event->configure.x;
+ y = event->configure.y;
+ width = event->configure.width;
+ height = event->configure.height;
+
+ if (strcmp(widget_name, "gslapt") == 0) {
+ gslapt_settings->x = x;
+ gslapt_settings->y = y;
+ gslapt_settings->width = width;
+ gslapt_settings->height = height;
+ } else if (strcmp(widget_name, "window_preferences") == 0) {
+ gslapt_settings->pref_x = x;
+ gslapt_settings->pref_y = y;
+ gslapt_settings->pref_width = width;
+ gslapt_settings->pref_height = height;
+ } else if (strcmp(widget_name, "changelog_window") == 0) {
+ gslapt_settings->cl_x = x;
+ gslapt_settings->cl_y = y;
+ gslapt_settings->cl_width = width;
+ gslapt_settings->cl_height = height;
+ } else if (strcmp(widget_name, "transaction_window") == 0) {
+ gslapt_settings->tran_x = x;
+ gslapt_settings->tran_y = y;
+ gslapt_settings->tran_width = width;
+ gslapt_settings->tran_height = height;
+ } else {
+ fprintf(stderr, "need to handle widget name: %s\n", widget_name);
+ }
+
+ return FALSE;
}
-void on_gslapt_destroy (GObject *object, gpointer *user_data)
+void on_gslapt_destroy(GObject *object, gpointer *user_data)
{
- slapt_free_transaction(trans);
- slapt_vector_t_free(all);
- slapt_vector_t_free(installed);
- slapt_free_rc_config(global_config);
- gslapt_series_map_free(gslapt_series_map);
+ slapt_free_transaction(trans);
+ slapt_vector_t_free(all);
+ slapt_vector_t_free(installed);
+ slapt_free_rc_config(global_config);
+ gslapt_series_map_free(gslapt_series_map);
- gslapt_write_rc(gslapt_settings);
- gslapt_free_rc(gslapt_settings);
+ gslapt_write_rc(gslapt_settings);
+ gslapt_free_rc(gslapt_settings);
- gtk_main_quit();
- exit(0);
+ gtk_main_quit();
+ exit(0);
}
-void update_callback (GObject *object, gpointer *user_data)
+void update_callback(GObject *object, gpointer *user_data)
{
- GThread *gpd;
+ GThread *gpd;
- clear_execute_active();
+ clear_execute_active();
-#if !GLIB_CHECK_VERSION (2, 31, 0)
- gpd = g_thread_create((GThreadFunc)get_package_data,NULL,FALSE,NULL);
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+ gpd = g_thread_create((GThreadFunc)get_package_data, NULL, FALSE, NULL);
#else
- gpd = g_thread_new("GslaptUpdateCallback", (GThreadFunc)get_package_data,NULL);
+ gpd = g_thread_new("GslaptUpdateCallback", (GThreadFunc)get_package_data, NULL);
#endif
- return;
+ return;
}
-void upgrade_callback (GObject *object, gpointer *user_data)
+void upgrade_callback(GObject *object, gpointer *user_data)
{
- set_busy_cursor();
- mark_upgrade_packages();
- if (trans->install_pkgs->size > 0 || trans->upgrade_pkgs->size > 0 || trans->reinstall_pkgs->size > 0) {
- set_execute_active();
- }
- unset_busy_cursor();
+ set_busy_cursor();
+ mark_upgrade_packages();
+ if (trans->install_pkgs->size > 0 || trans->upgrade_pkgs->size > 0 || trans->reinstall_pkgs->size > 0) {
+ set_execute_active();
+ }
+ unset_busy_cursor();
}
-void execute_callback (GObject *object, gpointer *user_data)
+void execute_callback(GObject *object, gpointer *user_data)
{
- GtkBuilder *builder;
- GtkWidget *trans_window;
-
- if (
- trans->install_pkgs->size == 0
- && trans->upgrade_pkgs->size == 0
- && trans->reinstall_pkgs->size == 0
- && trans->remove_pkgs->size == 0
- ) return;
-
- builder = gtk_builder_new ();
- gslapt_load_ui (builder, "transaction_window.ui");
- trans_window = GTK_WIDGET (gtk_builder_get_object (builder, "transaction_window"));
- gtk_builder_connect_signals (builder, builder);
- gtk_window_set_transient_for (GTK_WINDOW(trans_window), GTK_WINDOW(gslapt));
-
-
- if ((gslapt_settings->tran_x == gslapt_settings->tran_y == gslapt_settings->tran_width == gslapt_settings->tran_height == 0)) {
- gtk_window_set_default_size(GTK_WINDOW(trans_window),
- gslapt_settings->tran_width, gslapt_settings->tran_height);
- gtk_window_move(GTK_WINDOW(trans_window),
- gslapt_settings->tran_x, gslapt_settings->tran_y);
- }
-
- if ( populate_transaction_window(builder) == 0 ) {
- gtk_widget_show_all(trans_window);
- } else {
- gtk_widget_destroy(trans_window);
- }
+ GtkBuilder *builder;
+ GtkWidget *trans_window;
+
+ if (trans->install_pkgs->size == 0 && trans->upgrade_pkgs->size == 0 && trans->reinstall_pkgs->size == 0 && trans->remove_pkgs->size == 0)
+ return;
+
+ builder = gtk_builder_new();
+ gslapt_load_ui(builder, "transaction_window.ui");
+ trans_window = GTK_WIDGET(gtk_builder_get_object(builder, "transaction_window"));
+ gtk_builder_connect_signals(builder, builder);
+ gtk_window_set_transient_for(GTK_WINDOW(trans_window), GTK_WINDOW(gslapt));
+
+ if ((gslapt_settings->tran_x == gslapt_settings->tran_y == gslapt_settings->tran_width == gslapt_settings->tran_height == 0)) {
+ gtk_window_set_default_size(GTK_WINDOW(trans_window), gslapt_settings->tran_width, gslapt_settings->tran_height);
+ gtk_window_move(GTK_WINDOW(trans_window), gslapt_settings->tran_x, gslapt_settings->tran_y);
+ }
+
+ if (populate_transaction_window(builder) == 0) {
+ gtk_widget_show_all(trans_window);
+ } else {
+ gtk_widget_destroy(trans_window);
+ }
}
-void open_preferences (GtkMenuItem *menuitem, gpointer *user_data)
+void open_preferences(GtkMenuItem *menuitem, gpointer *user_data)
{
- GtkWidget *preferences;
- GtkEntry *working_dir;
- GtkTreeView *source_tree,*exclude_tree;
- #ifdef SLAPT_HAS_GPGME
- GtkTreeView *verification_source_tree;
- #endif
-
- if (preferences_window_builder == NULL)
- preferences_window_builder = gtk_builder_new ();
+ GtkWidget *preferences;
+ GtkEntry *working_dir;
+ GtkTreeView *source_tree, *exclude_tree;
+#ifdef SLAPT_HAS_GPGME
+ GtkTreeView *verification_source_tree;
+#endif
- gslapt_load_ui (preferences_window_builder, "window_preferences.ui");
- preferences = GTK_WIDGET (gtk_builder_get_object (preferences_window_builder, "window_preferences"));
- gtk_builder_connect_signals (preferences_window_builder, preferences_window_builder);
- gtk_window_set_transient_for (GTK_WINDOW(preferences), GTK_WINDOW(gslapt));
+ if (preferences_window_builder == NULL)
+ preferences_window_builder = gtk_builder_new();
+ gslapt_load_ui(preferences_window_builder, "window_preferences.ui");
+ preferences = GTK_WIDGET(gtk_builder_get_object(preferences_window_builder, "window_preferences"));
+ gtk_builder_connect_signals(preferences_window_builder, preferences_window_builder);
+ gtk_window_set_transient_for(GTK_WINDOW(preferences), GTK_WINDOW(gslapt));
- if ((gslapt_settings->pref_x == gslapt_settings->pref_y == gslapt_settings->pref_width == gslapt_settings->pref_height == 0)) {
- gtk_window_set_default_size(GTK_WINDOW(preferences),
- gslapt_settings->pref_width, gslapt_settings->pref_height);
- gtk_window_move(GTK_WINDOW(preferences),
- gslapt_settings->pref_x, gslapt_settings->pref_y);
- }
+ if ((gslapt_settings->pref_x == gslapt_settings->pref_y == gslapt_settings->pref_width == gslapt_settings->pref_height == 0)) {
+ gtk_window_set_default_size(GTK_WINDOW(preferences), gslapt_settings->pref_width, gslapt_settings->pref_height);
+ gtk_window_move(GTK_WINDOW(preferences), gslapt_settings->pref_x, gslapt_settings->pref_y);
+ }
- working_dir = GTK_ENTRY(gtk_builder_get_object(preferences_window_builder,"preferences_working_dir_entry"));
- gtk_entry_set_text(working_dir,global_config->working_dir);
+ working_dir = GTK_ENTRY(gtk_builder_get_object(preferences_window_builder, "preferences_working_dir_entry"));
+ gtk_entry_set_text(working_dir, global_config->working_dir);
- source_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder,"preferences_sources_treeview"));
- build_sources_treeviewlist((GtkWidget *)source_tree);
+ source_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder, "preferences_sources_treeview"));
+ build_sources_treeviewlist((GtkWidget *)source_tree);
- #ifdef SLAPT_HAS_GPGME
- verification_source_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder,"preferences_verification_sources_treeview"));
- build_verification_sources_treeviewlist((GtkWidget *)verification_source_tree);
- #endif
+#ifdef SLAPT_HAS_GPGME
+ verification_source_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder, "preferences_verification_sources_treeview"));
+ build_verification_sources_treeviewlist((GtkWidget *)verification_source_tree);
+#endif
- exclude_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder,"preferences_exclude_treeview"));
- build_exclude_treeviewlist((GtkWidget *)exclude_tree);
+ exclude_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder, "preferences_exclude_treeview"));
+ build_exclude_treeviewlist((GtkWidget *)exclude_tree);
- gtk_widget_show_all(preferences);
- preferences_window = preferences;
+ gtk_widget_show_all(preferences);
+ preferences_window = preferences;
}
-void search_activated (GtkWidget *gslapt, gpointer *user_data)
+void search_activated(GtkWidget *gslapt, gpointer *user_data)
{
- gboolean valid = FALSE, exists = FALSE;
- GtkTreeIter iter;
- GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
- GtkEntryCompletion *completion = gtk_entry_get_completion(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
- GtkTreeModel *completions = gtk_entry_completion_get_model(completion);
-
- build_searched_treeviewlist(GTK_WIDGET(treeview),pattern);
-
- /* add search to completion */
- valid = gtk_tree_model_get_iter_first(completions,&iter);
- while (valid) {
- gchar *string = NULL;
- gtk_tree_model_get(completions,&iter,0,&string,-1);
- if (strcmp(string,pattern) == 0)
- exists = TRUE;
- g_free(string);
- valid = gtk_tree_model_iter_next(completions,&iter);
- }
- if (!exists) {
- gtk_list_store_append(GTK_LIST_STORE(completions),&iter);
- gtk_list_store_set(GTK_LIST_STORE(completions),&iter,
- 0,pattern,
- -1
- );
- }
+ gboolean valid = FALSE, exists = FALSE;
+ GtkTreeIter iter;
+ GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
+ GtkEntryCompletion *completion = gtk_entry_get_completion(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
+ GtkTreeModel *completions = gtk_entry_completion_get_model(completion);
+ build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
+
+ /* add search to completion */
+ valid = gtk_tree_model_get_iter_first(completions, &iter);
+ while (valid) {
+ gchar *string = NULL;
+ gtk_tree_model_get(completions, &iter, 0, &string, -1);
+ if (strcmp(string, pattern) == 0)
+ exists = TRUE;
+ g_free(string);
+ valid = gtk_tree_model_iter_next(completions, &iter);
+ }
+ if (!exists) {
+ gtk_list_store_append(GTK_LIST_STORE(completions), &iter);
+ gtk_list_store_set(GTK_LIST_STORE(completions), &iter, 0, pattern, -1);
+ }
}
-void add_pkg_for_install (GtkWidget *gslapt, gpointer *user_data)
+void add_pkg_for_install(GtkWidget *gslapt, gpointer *user_data)
{
- slapt_pkg_info_t *pkg = NULL,
- *installed_pkg = NULL;
- GtkTreeView *treeview;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkBin *caller_button = (GtkBin *)user_data;
- GtkLabel *caller_button_label = GTK_LABEL(gtk_bin_get_child(caller_button));
- GtkTreeModel *model;
- GtkTreeIter actual_iter,filter_iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModelSort *package_model;
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- selection = gtk_tree_view_get_selection(treeview);
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
-
- if ( gtk_tree_selection_get_selected(selection,(GtkTreeModel **)&package_model,&iter) == TRUE) {
- gchar *pkg_name;
- gchar *pkg_version;
- gchar *pkg_location;
-
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
-
- if ( pkg_name == NULL || pkg_version == NULL || pkg_location == NULL) {
- fprintf(stderr,"failed to get package name and version from selection\n");
-
- if (pkg_name != NULL)
- g_free(pkg_name);
+ slapt_pkg_info_t *pkg = NULL,
+ *installed_pkg = NULL;
+ GtkTreeView *treeview;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkBin *caller_button = (GtkBin *)user_data;
+ GtkLabel *caller_button_label = GTK_LABEL(gtk_bin_get_child(caller_button));
+ GtkTreeModel *model;
+ GtkTreeIter actual_iter, filter_iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModelSort *package_model;
- if (pkg_version != NULL)
- g_free(pkg_version);
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ selection = gtk_tree_view_get_selection(treeview);
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- if (pkg_location != NULL)
- g_free(pkg_location);
+ if (gtk_tree_selection_get_selected(selection, (GtkTreeModel **)&package_model, &iter) == TRUE) {
+ gchar *pkg_name;
+ gchar *pkg_version;
+ gchar *pkg_location;
- return;
- }
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
- if ( strcmp(gtk_label_get_text(caller_button_label),(gchar *)_("Upgrade")) == 0) {
- pkg = slapt_get_newest_pkg(all,pkg_name);
- } else if ( strcmp(gtk_label_get_text(caller_button_label),(gchar *)_("Re-Install")) == 0) {
- pkg = slapt_get_exact_pkg(all,pkg_name,pkg_version);
- } else {
- pkg = slapt_get_pkg_by_details(all,pkg_name,pkg_version,pkg_location);
+ if (pkg_name == NULL || pkg_version == NULL || pkg_location == NULL) {
+ fprintf(stderr, "failed to get package name and version from selection\n");
+
+ if (pkg_name != NULL)
+ g_free(pkg_name);
+
+ if (pkg_version != NULL)
+ g_free(pkg_version);
+
+ if (pkg_location != NULL)
+ g_free(pkg_location);
+
+ return;
+ }
+
+ if (strcmp(gtk_label_get_text(caller_button_label), (gchar *)_("Upgrade")) == 0) {
+ pkg = slapt_get_newest_pkg(all, pkg_name);
+ } else if (strcmp(gtk_label_get_text(caller_button_label), (gchar *)_("Re-Install")) == 0) {
+ pkg = slapt_get_exact_pkg(all, pkg_name, pkg_version);
+ } else {
+ pkg = slapt_get_pkg_by_details(all, pkg_name, pkg_version, pkg_location);
+ }
+
+ if (pkg == NULL) {
+ fprintf(stderr, "Failed to find package: %s-%s@%s\n", pkg_name, pkg_version, pkg_location);
+ g_free(pkg_name);
+ g_free(pkg_version);
+ g_free(pkg_location);
+ return;
+ }
+
+ installed_pkg = slapt_get_newest_pkg(installed, pkg_name);
+
+ g_free(pkg_name);
+ g_free(pkg_version);
+ g_free(pkg_location);
}
- if ( pkg == NULL ) {
- fprintf(stderr,"Failed to find package: %s-%s@%s\n",pkg_name,pkg_version,pkg_location);
- g_free(pkg_name);
- g_free(pkg_version);
- g_free(pkg_location);
- return;
+ if (pkg == NULL) {
+ fprintf(stderr, "No package to work with\n");
+ return;
}
- installed_pkg = slapt_get_newest_pkg(installed,pkg_name);
+ /* convert sort model and iter to filter */
+ gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(package_model), &filter_iter, &iter);
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ /* convert filter to regular tree */
+ gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(filter_model), &actual_iter, &filter_iter);
+ model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ /* a=installed,i=install,r=remove,u=upgrade,z=available */
- g_free(pkg_name);
- g_free(pkg_version);
- g_free(pkg_location);
+ /* if it is not already installed, install it */
+ if (installed_pkg == NULL) {
+ if (ladd_deps_to_trans(trans, all, installed, pkg) == 0) {
+ slapt_vector_t *conflicts = slapt_is_conflicted(trans, all, installed, pkg);
- }
+ slapt_add_install_to_transaction(trans, pkg);
+ set_iter_for_install(model, &actual_iter, pkg);
+ set_execute_active();
- if ( pkg == NULL ) {
- fprintf(stderr,"No package to work with\n");
- return;
- }
-
- /* convert sort model and iter to filter */
- gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(package_model),&filter_iter,&iter);
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- /* convert filter to regular tree */
- gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(filter_model),&actual_iter,&filter_iter);
- model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- /* a=installed,i=install,r=remove,u=upgrade,z=available */
-
- /* if it is not already installed, install it */
- if ( installed_pkg == NULL ) {
- if ( ladd_deps_to_trans(trans,all,installed,pkg) == 0 ) {
- slapt_vector_t *conflicts = slapt_is_conflicted(trans,all,installed,pkg);
-
- slapt_add_install_to_transaction(trans,pkg);
- set_iter_for_install(model, &actual_iter, pkg);
- set_execute_active();
-
- /* if there is a conflict, we schedule the conflict for removal */
- if ( conflicts->size > 0) {
- slapt_vector_t_foreach(slapt_pkg_info_t *, conflicted_pkg, conflicts) {
- slapt_add_remove_to_transaction(trans,conflicted_pkg);
- set_execute_active();
- if (set_iter_to_pkg(model,&actual_iter,conflicted_pkg)) {
- set_iter_for_remove(model, &actual_iter, conflicted_pkg);
- }
+ /* if there is a conflict, we schedule the conflict for removal */
+ if (conflicts->size > 0) {
+ slapt_vector_t_foreach (slapt_pkg_info_t *, conflicted_pkg, conflicts) {
+ slapt_add_remove_to_transaction(trans, conflicted_pkg);
+ set_execute_active();
+ if (set_iter_to_pkg(model, &actual_iter, conflicted_pkg)) {
+ set_iter_for_remove(model, &actual_iter, conflicted_pkg);
+ }
+ }
+ }
+ slapt_vector_t_free(conflicts);
+ } else {
+ display_dep_error_dialog(pkg);
+ }
+
+ } else { /* else we upgrade or reinstall */
+ int ver_cmp;
+
+ /* it is already installed, attempt an upgrade */
+ if (((ver_cmp = slapt_cmp_pkgs(installed_pkg, pkg)) < 0) || (global_config->re_install == TRUE)) {
+ if (ladd_deps_to_trans(trans, all, installed, pkg) == 0) {
+ slapt_vector_t *conflicts = slapt_is_conflicted(trans, all, installed, pkg);
+
+ if (conflicts->size > 0) {
+ slapt_vector_t_foreach (slapt_pkg_info_t *, conflicted_pkg, conflicts) {
+ fprintf(stderr, "%s conflicts with %s\n", pkg->name, conflicted_pkg->name);
+ slapt_add_remove_to_transaction(trans, conflicted_pkg);
+ set_execute_active();
+ if (set_iter_to_pkg(model, &actual_iter, conflicted_pkg)) {
+ set_iter_for_remove(model, &actual_iter, conflicted_pkg);
+ }
+ }
+ } else {
+ if (global_config->re_install == TRUE)
+ slapt_add_reinstall_to_transaction(trans, installed_pkg, pkg);
+ else
+ slapt_add_upgrade_to_transaction(trans, installed_pkg, pkg);
+
+ if (global_config->re_install == TRUE) {
+ if (ver_cmp == 0) {
+ set_iter_for_reinstall(model, &actual_iter, pkg);
+ } else {
+ set_iter_for_downgrade(model, &actual_iter, pkg);
+ if (set_iter_to_pkg(model, &actual_iter, installed_pkg)) {
+ set_iter_for_downgrade(model, &actual_iter, installed_pkg);
+ }
+ }
+ } else {
+ slapt_pkg_info_t *inst_avail = slapt_get_exact_pkg(all, installed_pkg->name, installed_pkg->version);
+ set_iter_for_upgrade(model, &actual_iter, pkg);
+ if (pkg != NULL && set_iter_to_pkg(model, &actual_iter, pkg)) {
+ set_iter_for_upgrade(model, &actual_iter, pkg);
+ }
+ if (installed_pkg != NULL && set_iter_to_pkg(model, &actual_iter, installed_pkg)) {
+ set_iter_for_upgrade(model, &actual_iter, installed_pkg);
+ }
+ if (inst_avail != NULL && set_iter_to_pkg(model, &actual_iter, inst_avail)) {
+ set_iter_for_upgrade(model, &actual_iter, inst_avail);
+ }
+ }
+ set_execute_active();
+ }
+
+ slapt_vector_t_free(conflicts);
+ } else {
+ display_dep_error_dialog(pkg);
+ }
}
- }
- slapt_vector_t_free(conflicts);
- } else {
- display_dep_error_dialog(pkg);
}
- } else { /* else we upgrade or reinstall */
- int ver_cmp;
-
- /* it is already installed, attempt an upgrade */
- if (
- ((ver_cmp = slapt_cmp_pkgs(installed_pkg,pkg)) < 0) ||
- (global_config->re_install == TRUE)
- ) {
- if ( ladd_deps_to_trans(trans,all,installed,pkg) == 0 ) {
- slapt_vector_t *conflicts = slapt_is_conflicted(trans,all,installed,pkg);
-
- if (conflicts->size > 0) {
- slapt_vector_t_foreach(slapt_pkg_info_t *, conflicted_pkg, conflicts) {
- fprintf(stderr,"%s conflicts with %s\n",pkg->name,conflicted_pkg->name);
- slapt_add_remove_to_transaction(trans,conflicted_pkg);
+ rebuild_package_action_menu();
+}
+
+void add_pkg_for_removal(GtkWidget *gslapt, gpointer *user_data)
+{
+ GtkTreeView *treeview;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModelSort *package_model;
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ selection = gtk_tree_view_get_selection(treeview);
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
+
+ if (gtk_tree_selection_get_selected(selection, (GtkTreeModel **)&package_model, &iter) == TRUE) {
+ gchar *pkg_name;
+ gchar *pkg_version;
+ gchar *pkg_location;
+ slapt_pkg_info_t *pkg;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
+
+ if ((pkg = slapt_get_exact_pkg(installed, pkg_name, pkg_version)) != NULL) {
+ slapt_vector_t *deps;
+ GtkTreeModel *model;
+ GtkTreeIter filter_iter, actual_iter;
+ GtkTreeModelFilter *filter_model;
+
+ /* convert sort model and iter to filter */
+ gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(package_model), &filter_iter, &iter);
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ /* convert filter to regular tree */
+ gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(filter_model), &actual_iter, &filter_iter);
+ model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ deps = slapt_is_required_by(global_config, all, installed, trans->install_pkgs, trans->remove_pkgs, pkg);
+
+ slapt_add_remove_to_transaction(trans, pkg);
+ set_iter_for_remove(model, &actual_iter, pkg);
set_execute_active();
- if (set_iter_to_pkg(model,&actual_iter,conflicted_pkg)) {
- set_iter_for_remove(model, &actual_iter, conflicted_pkg);
+
+ slapt_vector_t_foreach (slapt_pkg_info_t *, dep, deps) {
+ /* need to check that it is actually installed */
+ slapt_pkg_info_t *installed_dep = slapt_get_exact_pkg(installed, dep->name, dep->version);
+ if (installed_dep != NULL) {
+ slapt_add_remove_to_transaction(trans, installed_dep);
+ if (set_iter_to_pkg(model, &actual_iter, installed_dep)) {
+ set_iter_for_remove(model, &actual_iter, installed_dep);
+ }
+ }
}
- }
- }else{
- if (global_config->re_install == TRUE)
- slapt_add_reinstall_to_transaction(trans,installed_pkg,pkg);
- else
- slapt_add_upgrade_to_transaction(trans,installed_pkg,pkg);
+ slapt_vector_t_free(deps);
+ }
- if (global_config->re_install == TRUE) {
- if (ver_cmp == 0) {
- set_iter_for_reinstall(model,&actual_iter,pkg);
- } else {
- set_iter_for_downgrade(model,&actual_iter,pkg);
- if (set_iter_to_pkg(model,&actual_iter,installed_pkg)) {
- set_iter_for_downgrade(model,&actual_iter,installed_pkg);
- }
+ g_free(pkg_name);
+ g_free(pkg_version);
+ g_free(pkg_location);
+ }
+
+ rebuild_package_action_menu();
+}
+
+void build_package_treeviewlist(GtkWidget *treeview)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *base_model;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModelSort *package_model;
+
+ base_model = GTK_TREE_MODEL(gtk_list_store_new(
+ NUMBER_OF_COLUMNS,
+ GDK_TYPE_PIXBUF, /* status icon */
+ G_TYPE_STRING, /* name */
+ G_TYPE_STRING, /* version */
+ G_TYPE_STRING, /* location */
+ G_TYPE_STRING, /* series */
+ G_TYPE_STRING, /*desc */
+ G_TYPE_UINT, /* size */
+ G_TYPE_STRING, /* status */
+ G_TYPE_BOOLEAN, /* is installed */
+ G_TYPE_BOOLEAN, /* visible */
+ G_TYPE_BOOLEAN, /* marked */
+ G_TYPE_BOOLEAN /* is an upgrade */
+ ));
+
+ slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, all) {
+ /* we use this for sorting the status */
+ /* a=installed,i=install,r=remove,u=upgrade,z=available */
+ gchar *status = NULL;
+ gboolean is_inst = FALSE, is_an_upgrade = FALSE;
+ GdkPixbuf *status_icon = NULL;
+ gchar *short_desc = slapt_gen_short_pkg_description(pkg);
+ slapt_pkg_info_t *installed_pkg = NULL, *newer_available_pkg = NULL;
+ gchar *location = NULL, *series = NULL;
+
+ installed_pkg = slapt_get_newest_pkg(installed, pkg->name);
+ if (installed_pkg != NULL) {
+ int cmp = slapt_cmp_pkgs(pkg, installed_pkg);
+ if (strcmp(pkg->version, installed_pkg->version) == 0) {
+ is_inst = TRUE;
+ } else if (cmp > 0) {
+ is_an_upgrade = TRUE;
+
+ /* we need to see if there is another available package that is newer than this one */
+ if ((newer_available_pkg = slapt_get_newest_pkg(all, pkg->name)) != NULL) {
+ if (slapt_cmp_pkgs(pkg, newer_available_pkg) < 0)
+ is_an_upgrade = FALSE;
+ }
}
- } else {
- slapt_pkg_info_t *inst_avail = slapt_get_exact_pkg(all,installed_pkg->name,installed_pkg->version);
- set_iter_for_upgrade(model, &actual_iter, pkg);
- if ( pkg != NULL && set_iter_to_pkg(model,&actual_iter,pkg)) {
- set_iter_for_upgrade(model, &actual_iter, pkg);
+ }
+
+ if (slapt_get_exact_pkg(trans->exclude_pkgs, pkg->name, pkg->version) != NULL) {
+ /* if it's excluded */
+ if ((slapt_get_exact_pkg(trans->exclude_pkgs, pkg->name, pkg->version) != NULL) || slapt_is_excluded(global_config, pkg) == 1) {
+ status_icon = gslapt_img("pkg_action_available_excluded.png");
+ } else {
+ status_icon = gslapt_img("pkg_action_available.png");
}
- if (installed_pkg != NULL && set_iter_to_pkg(model,&actual_iter,installed_pkg)) {
- set_iter_for_upgrade(model, &actual_iter, installed_pkg);
+ status = g_strdup_printf("z%s", pkg->name);
+ location = pkg->location;
+ } else if (slapt_get_exact_pkg(trans->remove_pkgs, pkg->name, pkg->version) != NULL) {
+ status_icon = gslapt_img("pkg_action_remove.png");
+ status = g_strdup_printf("r%s", pkg->name);
+ location = pkg->location;
+ } else if (slapt_get_exact_pkg(trans->install_pkgs, pkg->name, pkg->version) != NULL) {
+ status_icon = gslapt_img("pkg_action_install.png");
+ status = g_strdup_printf("i%s", pkg->name);
+ location = pkg->location;
+ } else if (lsearch_upgrade_transaction(trans, pkg) != NULL) {
+ status_icon = gslapt_img("pkg_action_upgrade.png");
+ status = g_strdup_printf("u%s", pkg->name);
+ location = pkg->location;
+ } else if (is_inst) {
+ /* if it's excluded */
+ if ((slapt_get_exact_pkg(trans->exclude_pkgs, pkg->name, pkg->version) != NULL) || slapt_is_excluded(global_config, pkg) == 1) {
+ status_icon = gslapt_img("pkg_action_installed_excluded.png");
+ } else {
+ status_icon = gslapt_img("pkg_action_installed.png");
}
- if (inst_avail != NULL && set_iter_to_pkg(model,&actual_iter,inst_avail)) {
- set_iter_for_upgrade(model, &actual_iter, inst_avail);
+ status = g_strdup_printf("a%s", pkg->name);
+ location = installed_pkg->location;
+ } else {
+ /* if it's excluded */
+ if ((slapt_get_exact_pkg(trans->exclude_pkgs, pkg->name, pkg->version) != NULL) || slapt_is_excluded(global_config, pkg) == 1) {
+ status_icon = gslapt_img("pkg_action_available_excluded.png");
+ } else {
+ status_icon = gslapt_img("pkg_action_available.png");
}
- }
- set_execute_active();
+ status = g_strdup_printf("z%s", pkg->name);
+ location = pkg->location;
}
- slapt_vector_t_free(conflicts);
- } else {
- display_dep_error_dialog(pkg);
- }
+ series = gslapt_series_map_lookup(gslapt_series_map, location);
+ if (series == NULL)
+ series = g_strdup(location);
+
+ gtk_list_store_append(GTK_LIST_STORE(base_model), &iter);
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter,
+ STATUS_ICON_COLUMN, status_icon,
+ NAME_COLUMN, pkg->name,
+ VERSION_COLUMN, pkg->version,
+ LOCATION_COLUMN, location,
+ SERIES_COLUMN, series,
+ DESC_COLUMN, short_desc,
+ SIZE_COLUMN, pkg->size_u,
+ STATUS_COLUMN, status,
+ INST_COLUMN, is_inst,
+ VISIBLE_COLUMN, TRUE,
+ MARKED_COLUMN, FALSE,
+ UPGRADEABLE_COLUMN, is_an_upgrade,
+ -1);
+
+ g_free(status);
+ g_free(short_desc);
+ g_free(series);
+ }
+
+ slapt_vector_t_foreach (slapt_pkg_info_t *, installed_pkg, installed) {
+ /* do not duplicate those packages that are still available from the package sources */
+ if (slapt_get_exact_pkg(all, installed_pkg->name, installed_pkg->version) == NULL) {
+ /* we use this for sorting the status */
+ /* a=installed,i=install,r=remove,u=upgrade,z=available */
+ gchar *status = NULL;
+ GdkPixbuf *status_icon = NULL;
+ gchar *short_desc = slapt_gen_short_pkg_description(installed_pkg);
+
+ if (slapt_get_exact_pkg(trans->remove_pkgs, installed_pkg->name, installed_pkg->version) != NULL) {
+ status_icon = gslapt_img("pkg_action_remove.png");
+ status = g_strdup_printf("r%s", installed_pkg->name);
+ } else {
+ /* if it's excluded */
+ if ((slapt_get_exact_pkg(trans->exclude_pkgs, installed_pkg->name, installed_pkg->version) != NULL) || slapt_is_excluded(global_config, installed_pkg) == 1) {
+ status_icon = gslapt_img("pkg_action_installed_excluded.png");
+ } else {
+ status_icon = gslapt_img("pkg_action_installed.png");
+ }
+ status = g_strdup_printf("a%s", installed_pkg->name);
+ }
+ gtk_list_store_append(GTK_LIST_STORE(base_model), &iter);
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter,
+ STATUS_ICON_COLUMN, status_icon,
+ NAME_COLUMN, installed_pkg->name,
+ VERSION_COLUMN, installed_pkg->version,
+ LOCATION_COLUMN, installed_pkg->location,
+ SERIES_COLUMN, installed_pkg->location,
+ DESC_COLUMN, short_desc,
+ SIZE_COLUMN, installed_pkg->size_u,
+ STATUS_COLUMN, status,
+ INST_COLUMN, TRUE,
+ VISIBLE_COLUMN, TRUE,
+ MARKED_COLUMN, FALSE,
+ UPGRADEABLE_COLUMN, FALSE,
+ -1);
+
+ g_free(status);
+ g_free(short_desc);
+ }
}
- }
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_filter_new(base_model, NULL));
+ gtk_tree_model_filter_set_visible_column(filter_model, VISIBLE_COLUMN);
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(filter_model)));
+ gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(package_model));
- rebuild_package_action_menu();
+ if (gtk_widget_get_window(gslapt) != NULL) {
+ unset_busy_cursor();
+ }
}
-void add_pkg_for_removal (GtkWidget *gslapt, gpointer *user_data)
+void build_searched_treeviewlist(GtkWidget *treeview, gchar *pattern)
{
- GtkTreeView *treeview;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkTreeModelSort *package_model;
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- selection = gtk_tree_view_get_selection(treeview);
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
-
- if ( gtk_tree_selection_get_selected(selection,(GtkTreeModel **)&package_model,&iter) == TRUE) {
- gchar *pkg_name;
- gchar *pkg_version;
- gchar *pkg_location;
- slapt_pkg_info_t *pkg;
-
- gtk_tree_model_get (GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
- gtk_tree_model_get (GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
- gtk_tree_model_get (GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
-
- if ( (pkg = slapt_get_exact_pkg(installed,pkg_name,pkg_version)) != NULL ) {
- slapt_vector_t *deps;
- GtkTreeModel *model;
- GtkTreeIter filter_iter,actual_iter;
- GtkTreeModelFilter *filter_model;
-
- /* convert sort model and iter to filter */
- gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(package_model),&filter_iter,&iter);
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- /* convert filter to regular tree */
- gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(filter_model),&actual_iter,&filter_iter);
- model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- deps = slapt_is_required_by(global_config, all, installed, trans->install_pkgs, trans->remove_pkgs, pkg);
-
- slapt_add_remove_to_transaction(trans,pkg);
- set_iter_for_remove(model, &actual_iter, pkg);
- set_execute_active();
-
- slapt_vector_t_foreach(slapt_pkg_info_t *, dep, deps) {
- /* need to check that it is actually installed */
- slapt_pkg_info_t *installed_dep = slapt_get_exact_pkg(installed, dep->name, dep->version);
- if (installed_dep != NULL ) {
- slapt_add_remove_to_transaction(trans, installed_dep);
- if (set_iter_to_pkg(model, &actual_iter, installed_dep)) {
- set_iter_for_remove(model, &actual_iter, installed_dep);
- }
+ gboolean valid;
+ GtkTreeIter iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ slapt_vector_t *a_matches = NULL, *i_matches = NULL;
+ GtkTreeModelSort *package_model;
+ gboolean view_list_all = FALSE, view_list_installed = FALSE,
+ view_list_available = FALSE, view_list_marked = FALSE,
+ view_list_upgradeable = FALSE;
+ slapt_regex_t *series_regex = NULL;
+
+ if (pattern == NULL || (strcmp(pattern, "") == 0)) {
+ reset_search_list();
+ } else {
+ series_regex = slapt_init_regex(pattern);
+ }
+
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
+
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ view_list_all = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_all_packages_menu")));
+ view_list_available = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_available_packages_menu")));
+ view_list_installed = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_installed_packages_menu")));
+ view_list_marked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_marked_packages_menu")));
+ view_list_upgradeable = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_upgradeable_packages_menu")));
+
+ a_matches = slapt_search_pkg_list(all, pattern);
+ i_matches = slapt_search_pkg_list(installed, pattern);
+ valid = gtk_tree_model_get_iter_first(base_model, &iter);
+ while (valid) {
+ gchar *name = NULL, *version = NULL, *location = NULL, *series = NULL;
+ slapt_pkg_info_t *a_pkg = NULL, *i_pkg = NULL;
+ gboolean marked = FALSE;
+ gboolean upgradeable = FALSE;
+ gboolean series_match = FALSE;
+
+ gtk_tree_model_get(base_model, &iter,
+ NAME_COLUMN, &name,
+ VERSION_COLUMN, &version,
+ LOCATION_COLUMN, &location,
+ SERIES_COLUMN, &series,
+ MARKED_COLUMN, &marked,
+ UPGRADEABLE_COLUMN, &upgradeable,
+ -1);
+
+ if (series_regex != NULL) {
+ slapt_execute_regex(series_regex, series);
+ if (series_regex->reg_return == 0) {
+ series_match = TRUE;
+ }
}
- }
- slapt_vector_t_free(deps);
+ a_pkg = slapt_get_pkg_by_details(a_matches, name, version, location);
+ i_pkg = slapt_get_pkg_by_details(i_matches, name, version, location);
+
+ if (view_list_installed && i_pkg != NULL) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else if (view_list_available && a_pkg != NULL) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else if (view_list_all && (a_pkg != NULL || i_pkg != NULL)) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else if (view_list_marked && marked && (a_pkg != NULL || i_pkg != NULL)) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else if (view_list_upgradeable && upgradeable && a_pkg != NULL) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else if (series_match == TRUE) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, FALSE, -1);
+ }
+ g_free(name);
+ g_free(version);
+ g_free(location);
+ g_free(series);
+ valid = gtk_tree_model_iter_next(base_model, &iter);
}
- g_free(pkg_name);
- g_free(pkg_version);
- g_free(pkg_location);
+ if (series_regex != NULL)
+ slapt_free_regex(series_regex);
- }
+ slapt_vector_t_free(a_matches);
+ slapt_vector_t_free(i_matches);
+}
+
+void open_about(GObject *object, gpointer *user_data)
+{
+ GtkBuilder *builder;
+ GtkWidget *about;
- rebuild_package_action_menu();
+ builder = gtk_builder_new();
+ gslapt_load_ui(builder, "about.ui");
+ about = GTK_WIDGET(gtk_builder_get_object(builder, "about"));
+ gtk_builder_connect_signals(builder, NULL);
+ gtk_window_set_transient_for(GTK_WINDOW(about), GTK_WINDOW(gslapt));
+ gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), VERSION);
+ g_object_unref(G_OBJECT(builder));
+ gtk_dialog_run(GTK_DIALOG(about));
+ gtk_widget_destroy(about);
}
-void build_package_treeviewlist (GtkWidget *treeview)
+void show_pkg_details(GtkTreeSelection *selection, gpointer data)
{
- GtkTreeIter iter;
- GtkTreeModel *base_model;
- GtkTreeModelFilter *filter_model;
- GtkTreeModelSort *package_model;
-
- base_model = GTK_TREE_MODEL(gtk_list_store_new (
- NUMBER_OF_COLUMNS,
- GDK_TYPE_PIXBUF, /* status icon */
- G_TYPE_STRING, /* name */
- G_TYPE_STRING, /* version */
- G_TYPE_STRING, /* location */
- G_TYPE_STRING, /* series */
- G_TYPE_STRING, /*desc */
- G_TYPE_UINT, /* size */
- G_TYPE_STRING, /* status */
- G_TYPE_BOOLEAN, /* is installed */
- G_TYPE_BOOLEAN, /* visible */
- G_TYPE_BOOLEAN, /* marked */
- G_TYPE_BOOLEAN /* is an upgrade */
- ));
-
- slapt_vector_t_foreach(slapt_pkg_info_t *, pkg, all) {
- /* we use this for sorting the status */
- /* a=installed,i=install,r=remove,u=upgrade,z=available */
- gchar *status = NULL;
- gboolean is_inst = FALSE, is_an_upgrade = FALSE;
- GdkPixbuf *status_icon = NULL;
- gchar *short_desc = slapt_gen_short_pkg_description(pkg);
- slapt_pkg_info_t *installed_pkg = NULL, *newer_available_pkg = NULL;
- gchar *location = NULL, *series = NULL;
+ GtkTreeIter iter;
+ GtkTreeModelSort *package_model;
+ GtkTreeView *treeview;
- installed_pkg = slapt_get_newest_pkg(installed, pkg->name);
- if (installed_pkg != NULL) {
- int cmp = slapt_cmp_pkgs(pkg, installed_pkg);
- if (strcmp(pkg->version,installed_pkg->version) == 0) {
- is_inst = TRUE;
- } else if (cmp > 0) {
- is_an_upgrade = TRUE;
-
- /* we need to see if there is another available package
- that is newer than this one */
- if ( (newer_available_pkg = slapt_get_newest_pkg(all, pkg->name)) != NULL) {
- if ( slapt_cmp_pkgs(pkg, newer_available_pkg) < 0 )
- is_an_upgrade = FALSE;
- }
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- }
- }
-
- if (slapt_get_exact_pkg(trans->exclude_pkgs,pkg->name,pkg->version) != NULL) {
- /* if it's excluded */
- if ((slapt_get_exact_pkg(trans->exclude_pkgs,pkg->name, pkg->version) != NULL) ||
- slapt_is_excluded(global_config,pkg) == 1) {
- status_icon = gslapt_img("pkg_action_available_excluded.png");
- } else {
- status_icon = gslapt_img("pkg_action_available.png");
- }
- status = g_strdup_printf("z%s",pkg->name);
- location = pkg->location;
- } else if (slapt_get_exact_pkg(trans->remove_pkgs,pkg->name, pkg->version) != NULL) {
- status_icon = gslapt_img("pkg_action_remove.png");
- status = g_strdup_printf("r%s",pkg->name);
- location = pkg->location;
- } else if (slapt_get_exact_pkg(trans->install_pkgs,pkg->name, pkg->version) != NULL) {
- status_icon = gslapt_img("pkg_action_install.png");
- status = g_strdup_printf("i%s",pkg->name);
- location = pkg->location;
- } else if (lsearch_upgrade_transaction(trans,pkg) != NULL) {
- status_icon = gslapt_img("pkg_action_upgrade.png");
- status = g_strdup_printf("u%s",pkg->name);
- location = pkg->location;
- } else if (is_inst) {
- /* if it's excluded */
- if ((slapt_get_exact_pkg(trans->exclude_pkgs,pkg->name, pkg->version) != NULL) ||
- slapt_is_excluded(global_config,pkg) == 1) {
- status_icon = gslapt_img("pkg_action_installed_excluded.png");
- } else {
- status_icon = gslapt_img("pkg_action_installed.png");
- }
- status = g_strdup_printf("a%s",pkg->name);
- location = installed_pkg->location;
- } else {
- /* if it's excluded */
- if ((slapt_get_exact_pkg(trans->exclude_pkgs,pkg->name, pkg->version) != NULL) ||
- slapt_is_excluded(global_config,pkg) == 1) {
- status_icon = gslapt_img("pkg_action_available_excluded.png");
- } else {
- status_icon = gslapt_img("pkg_action_available.png");
- }
- status = g_strdup_printf("z%s",pkg->name);
- location = pkg->location;
- }
+ if (gtk_tree_selection_get_selected(selection, (GtkTreeModel **)&package_model, &iter)) {
+ gchar *p_name, *p_version, *p_location;
+ slapt_pkg_info_t *pkg;
- series = gslapt_series_map_lookup(gslapt_series_map, location);
- if (series == NULL)
- series = g_strdup(location);
-
- gtk_list_store_append(GTK_LIST_STORE(base_model), &iter);
- gtk_list_store_set(GTK_LIST_STORE(base_model), &iter,
- STATUS_ICON_COLUMN,status_icon,
- NAME_COLUMN,pkg->name,
- VERSION_COLUMN,pkg->version,
- LOCATION_COLUMN,location,
- SERIES_COLUMN,series,
- DESC_COLUMN,short_desc,
- SIZE_COLUMN,pkg->size_u,
- STATUS_COLUMN,status,
- INST_COLUMN, is_inst,
- VISIBLE_COLUMN,TRUE,
- MARKED_COLUMN, FALSE,
- UPGRADEABLE_COLUMN, is_an_upgrade,
- -1
- );
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &p_name, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &p_version, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &p_location, -1);
- g_free(status);
- g_free(short_desc);
- g_free(series);
- }
-
- slapt_vector_t_foreach(slapt_pkg_info_t *, installed_pkg, installed) {
- /* do not duplicate those packages that are still available from the package sources */
- if (slapt_get_exact_pkg(all,installed_pkg->name,installed_pkg->version) == NULL) {
- /* we use this for sorting the status */
- /* a=installed,i=install,r=remove,u=upgrade,z=available */
- gchar *status = NULL;
- GdkPixbuf *status_icon = NULL;
- gchar *short_desc = slapt_gen_short_pkg_description(installed_pkg);
-
- if (slapt_get_exact_pkg(trans->remove_pkgs,installed_pkg->name, installed_pkg->version) != NULL) {
- status_icon = gslapt_img("pkg_action_remove.png");
- status = g_strdup_printf("r%s",installed_pkg->name);
- } else {
- /* if it's excluded */
- if ((slapt_get_exact_pkg(trans->exclude_pkgs,installed_pkg->name, installed_pkg->version) != NULL) ||
- slapt_is_excluded(global_config,installed_pkg) == 1) {
- status_icon = gslapt_img("pkg_action_installed_excluded.png");
+ pkg = slapt_get_pkg_by_details(all, p_name, p_version, p_location);
+ if (pkg != NULL) {
+ fillin_pkg_details(pkg);
+ build_package_action_menu(pkg);
} else {
- status_icon = gslapt_img("pkg_action_installed.png");
+ pkg = slapt_get_pkg_by_details(installed, p_name, p_version, p_location);
+ if (pkg != NULL) {
+ fillin_pkg_details(pkg);
+ build_package_action_menu(pkg);
+ }
}
- status = g_strdup_printf("a%s",installed_pkg->name);
- }
-
- gtk_list_store_append (GTK_LIST_STORE(base_model), &iter);
- gtk_list_store_set ( GTK_LIST_STORE(base_model), &iter,
- STATUS_ICON_COLUMN,status_icon,
- NAME_COLUMN,installed_pkg->name,
- VERSION_COLUMN,installed_pkg->version,
- LOCATION_COLUMN,installed_pkg->location,
- SERIES_COLUMN,installed_pkg->location,
- DESC_COLUMN,short_desc,
- SIZE_COLUMN,installed_pkg->size_u,
- STATUS_COLUMN,status,
- INST_COLUMN, TRUE,
- VISIBLE_COLUMN,TRUE,
- MARKED_COLUMN, FALSE,
- UPGRADEABLE_COLUMN, FALSE,
- -1
- );
-
- g_free(status);
- g_free(short_desc);
- }
- }
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_filter_new(base_model,NULL));
- gtk_tree_model_filter_set_visible_column(filter_model,VISIBLE_COLUMN);
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(filter_model)));
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview),GTK_TREE_MODEL(package_model));
-
- if (gtk_widget_get_window(gslapt) != NULL) {
- unset_busy_cursor();
- }
+ g_free(p_name);
+ g_free(p_version);
+ g_free(p_location);
+ }
}
-
-void build_searched_treeviewlist (GtkWidget *treeview, gchar *pattern)
+static void fillin_pkg_details(slapt_pkg_info_t *pkg)
{
- gboolean valid;
- GtkTreeIter iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- slapt_vector_t *a_matches = NULL,*i_matches = NULL;
- GtkTreeModelSort *package_model;
- gboolean view_list_all = FALSE, view_list_installed = FALSE,
- view_list_available = FALSE, view_list_marked = FALSE,
- view_list_upgradeable = FALSE;
- slapt_regex_t *series_regex = NULL;
-
- if (pattern == NULL || (strcmp(pattern,"") == 0)) {
- reset_search_list();
- } else {
- series_regex = slapt_init_regex(pattern);
- }
-
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
-
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- view_list_all = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_all_packages_menu")));
- view_list_available = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_available_packages_menu")));
- view_list_installed = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_installed_packages_menu")));
- view_list_marked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_marked_packages_menu")));
- view_list_upgradeable = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_upgradeable_packages_menu")));
-
- a_matches = slapt_search_pkg_list(all,pattern);
- i_matches = slapt_search_pkg_list(installed,pattern);
- valid = gtk_tree_model_get_iter_first(base_model,&iter);
- while (valid) {
- gchar *name = NULL,*version = NULL,*location = NULL, *series = NULL;
- slapt_pkg_info_t *a_pkg = NULL, *i_pkg = NULL;
- gboolean marked = FALSE;
- gboolean upgradeable = FALSE;
- gboolean series_match = FALSE;
-
- gtk_tree_model_get(base_model,&iter,
- NAME_COLUMN, &name,
- VERSION_COLUMN, &version,
- LOCATION_COLUMN, &location,
- SERIES_COLUMN,&series,
- MARKED_COLUMN, &marked,
- UPGRADEABLE_COLUMN, &upgradeable,
- -1
- );
-
- if (series_regex != NULL) {
- slapt_execute_regex(series_regex, series);
- if (series_regex->reg_return == 0) {
- series_match = TRUE;
- }
+ gchar *short_desc;
+ GtkTextBuffer *pkg_full_desc;
+ GtkTextBuffer *pkg_changelog;
+ GtkTextBuffer *pkg_filelist;
+ GtkTreeStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GList *columns;
+ guint i;
+ GtkWidget *treeview = GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "dep_conf_sug_treeview"));
+ slapt_pkg_info_t *latest_pkg = slapt_get_newest_pkg(all, pkg->name);
+ slapt_pkg_info_t *installed_pkg = slapt_get_newest_pkg(installed, pkg->name);
+ slapt_pkg_upgrade_t *pkg_upgrade = NULL;
+ char *clean_desc = NULL, *changelog = NULL, *filelist = NULL, *location = NULL;
+ const char *priority_str = NULL;
+
+ /* set package details */
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_name")), pkg->name);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_version")), pkg->version);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_source")), pkg->mirror);
+ short_desc = slapt_gen_short_pkg_description(pkg);
+ if (short_desc != NULL) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_description")), short_desc);
+ free(short_desc);
+ } else {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_description")), "");
}
-
- a_pkg = slapt_get_pkg_by_details(a_matches,name,version,location);
- i_pkg = slapt_get_pkg_by_details(i_matches,name,version,location);
-
- if (view_list_installed && i_pkg != NULL) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else if (view_list_available && a_pkg != NULL) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else if (view_list_all && (a_pkg != NULL || i_pkg != NULL)) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else if (view_list_marked && marked && (a_pkg != NULL || i_pkg != NULL)) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else if (view_list_upgradeable && upgradeable && a_pkg != NULL) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else if ( series_match == TRUE) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
+ location = gslapt_series_map_lookup(gslapt_series_map, pkg->location);
+ if (location != NULL) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_location")), location);
+ free(location);
} else {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,FALSE,-1);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_location")), pkg->location);
}
- g_free(name);
- g_free(version);
- g_free(location);
- g_free(series);
- valid = gtk_tree_model_iter_next(base_model,&iter);
- }
+ priority_str = slapt_priority_to_str(pkg->priority);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_priority")), priority_str);
- if (series_regex != NULL)
- slapt_free_regex(series_regex);
+ /* dependency information tab */
+ store = gtk_tree_store_new(1, G_TYPE_STRING);
- slapt_vector_t_free(a_matches);
- slapt_vector_t_free(i_matches);
-}
+ if (pkg->installed == false) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("<b>Required:</b>"), -1);
+ if (pkg->required != NULL && strlen(pkg->required) > 2) {
+ GtkTreeIter child_iter;
+ slapt_vector_t *dependencies = slapt_parse_delimited_list(pkg->required, ',');
-void open_about (GObject *object, gpointer *user_data)
-{
- GtkBuilder *builder;
- GtkWidget *about;
-
- builder = gtk_builder_new ();
- gslapt_load_ui (builder, "about.ui");
- about = GTK_WIDGET (gtk_builder_get_object (builder, "about"));
- gtk_builder_connect_signals (builder, NULL);
- gtk_window_set_transient_for (GTK_WINDOW(about), GTK_WINDOW(gslapt));
-
- gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about), VERSION);
- g_object_unref (G_OBJECT (builder));
- gtk_dialog_run (GTK_DIALOG(about));
- gtk_widget_destroy (about);
-}
+ slapt_vector_t_foreach (char *, buffer, dependencies) {
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, buffer, -1);
+ }
+ slapt_vector_t_free(dependencies);
+ }
-void show_pkg_details (GtkTreeSelection *selection, gpointer data)
-{
- GtkTreeIter iter;
- GtkTreeModelSort *package_model;
- GtkTreeView *treeview;
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
-
- if (gtk_tree_selection_get_selected(selection,(GtkTreeModel **)&package_model, &iter)) {
- gchar *p_name,*p_version,*p_location;
- slapt_pkg_info_t *pkg;
-
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &p_name, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &p_version, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &p_location, -1);
-
- pkg = slapt_get_pkg_by_details(all,p_name,p_version,p_location);
- if (pkg != NULL) {
- fillin_pkg_details(pkg);
- build_package_action_menu(pkg);
- }else{
- pkg = slapt_get_pkg_by_details(installed,p_name,p_version,p_location);
- if (pkg != NULL) {
- fillin_pkg_details(pkg);
- build_package_action_menu(pkg);
- }
- }
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("<b>Conflicts:</b>"), -1);
- g_free (p_name);
- g_free (p_version);
- g_free (p_location);
- }
+ if (pkg->conflicts != NULL && strlen(pkg->conflicts) > 2) {
+ GtkTreeIter child_iter;
+ slapt_vector_t *conflicts = slapt_parse_delimited_list(pkg->conflicts, ',');
-}
+ slapt_vector_t_foreach (char *, buffer, conflicts) {
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, buffer, -1);
+ }
+ slapt_vector_t_free(conflicts);
+ }
-static void fillin_pkg_details (slapt_pkg_info_t *pkg)
-{
- gchar *short_desc;
- GtkTextBuffer *pkg_full_desc;
- GtkTextBuffer *pkg_changelog;
- GtkTextBuffer *pkg_filelist;
- GtkTreeStore *store;
- GtkTreeIter iter;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GList *columns;
- guint i;
- GtkWidget *treeview = GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"dep_conf_sug_treeview"));
- slapt_pkg_info_t *latest_pkg = slapt_get_newest_pkg(all,pkg->name);
- slapt_pkg_info_t *installed_pkg = slapt_get_newest_pkg(installed,pkg->name);
- slapt_pkg_upgrade_t *pkg_upgrade = NULL;
- char *clean_desc = NULL, *changelog = NULL, *filelist = NULL, *location = NULL;
- const char *priority_str = NULL;
-
- /* set package details */
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_name")),pkg->name);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_version")),pkg->version);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_source")),pkg->mirror);
- short_desc = slapt_gen_short_pkg_description(pkg);
- if (short_desc != NULL) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_description")),short_desc);
- free(short_desc);
- } else {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_description")),"");
- }
- location = gslapt_series_map_lookup(gslapt_series_map, pkg->location);
- if (location != NULL) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_location")),location);
- free(location);
- } else {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_location")),pkg->location);
- }
-
- priority_str = slapt_priority_to_str(pkg->priority);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_priority")),priority_str);
-
- /* dependency information tab */
- store = gtk_tree_store_new(1,G_TYPE_STRING);
-
- if (pkg->installed == false) {
-
- gtk_tree_store_append(store,&iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("<b>Required:</b>"),-1);
-
- if (pkg->required != NULL && strlen(pkg->required) > 2) {
- GtkTreeIter child_iter;
- slapt_vector_t *dependencies = slapt_parse_delimited_list(pkg->required,',');
-
- slapt_vector_t_foreach(char *, buffer, dependencies) {
- gtk_tree_store_append(store,&child_iter,&iter);
- gtk_tree_store_set(store,&child_iter,0,buffer,-1);
- }
- slapt_vector_t_free(dependencies);
- }
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("<b>Suggests:</b>"), -1);
- gtk_tree_store_append(store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("<b>Conflicts:</b>"), -1);
+ if (pkg->suggests != NULL && strlen(pkg->suggests) > 2) {
+ GtkTreeIter child_iter;
+ slapt_vector_t *suggestions = slapt_parse_delimited_list(pkg->suggests, ',');
- if (pkg->conflicts != NULL && strlen(pkg->conflicts) > 2) {
- GtkTreeIter child_iter;
- slapt_vector_t *conflicts = slapt_parse_delimited_list(pkg->conflicts,',');
+ slapt_vector_t_foreach (char *, buffer, suggestions) {
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, buffer, -1);
+ }
+ slapt_vector_t_free(suggestions);
+ }
- slapt_vector_t_foreach(char *, buffer, conflicts) {
- gtk_tree_store_append(store,&child_iter,&iter);
- gtk_tree_store_set(store,&child_iter,0,buffer,-1);
- }
- slapt_vector_t_free(conflicts);
+ } else { /* installed */
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("No dependency information available"), -1);
}
- gtk_tree_store_append(store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("<b>Suggests:</b>"),-1);
+ columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(treeview));
+ for (i = 0; i < g_list_length(columns); i++) {
+ GtkTreeViewColumn *my_column = GTK_TREE_VIEW_COLUMN(g_list_nth_data(columns, i));
+ if (my_column != NULL) {
+ gtk_tree_view_remove_column(GTK_TREE_VIEW(treeview), my_column);
+ }
+ }
+ g_list_free(columns);
- if (pkg->suggests != NULL && strlen(pkg->suggests) > 2) {
- GtkTreeIter child_iter;
- slapt_vector_t *suggestions = slapt_parse_delimited_list(pkg->suggests,',');
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Source"), renderer, "markup", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
- slapt_vector_t_foreach(char *, buffer, suggestions) {
- gtk_tree_store_append(store,&child_iter,&iter);
- gtk_tree_store_set(store,&child_iter,0,buffer,-1);
- }
- slapt_vector_t_free(suggestions);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
+ gtk_tree_view_expand_all(GTK_TREE_VIEW(treeview));
- }
+ /* description tab */
+ pkg_full_desc = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_description_textview")));
+ clean_desc = strdup(pkg->description);
+ slapt_clean_description(clean_desc, pkg->name);
+ gtk_text_buffer_set_text(pkg_full_desc, clean_desc, -1);
- } else { /* installed */
- gtk_tree_store_append(store,&iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("No dependency information available"),-1);
- }
+ if (clean_desc != NULL)
+ free(clean_desc);
- columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(treeview));
- for (i = 0; i < g_list_length(columns); i++ ) {
- GtkTreeViewColumn *my_column = GTK_TREE_VIEW_COLUMN(g_list_nth_data(columns,i));
- if ( my_column != NULL ) {
- gtk_tree_view_remove_column(GTK_TREE_VIEW(treeview),my_column);
- }
- }
- g_list_free(columns);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Source"), renderer,
- "markup", 0, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview),GTK_TREE_MODEL(store));
- gtk_tree_view_expand_all(GTK_TREE_VIEW(treeview));
-
- /* description tab */
- pkg_full_desc = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_description_textview")));
- clean_desc = strdup(pkg->description);
- slapt_clean_description(clean_desc,pkg->name);
- gtk_text_buffer_set_text(pkg_full_desc, clean_desc, -1);
-
- if ( clean_desc != NULL )
- free(clean_desc);
-
- /* changelog tab */
- pkg_changelog = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_changelog_textview")));
- if ((changelog = slapt_get_pkg_changelog(pkg)) != NULL) {
- if (!g_utf8_validate(changelog, -1, NULL)) {
- char *converted = g_convert(changelog, strlen(changelog), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
- if (converted != NULL) {
+ /* changelog tab */
+ pkg_changelog = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_changelog_textview")));
+ if ((changelog = slapt_get_pkg_changelog(pkg)) != NULL) {
+ if (!g_utf8_validate(changelog, -1, NULL)) {
+ char *converted = g_convert(changelog, strlen(changelog), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+ if (converted != NULL) {
+ free(changelog);
+ changelog = converted;
+ }
+ }
+ gtk_text_buffer_set_text(pkg_changelog, changelog, -1);
free(changelog);
- changelog = converted;
- }
+ } else {
+ gtk_text_buffer_set_text(pkg_changelog, _("No changelog information available"), -1);
}
- gtk_text_buffer_set_text(pkg_changelog, changelog, -1);
- free(changelog);
- } else {
- gtk_text_buffer_set_text(pkg_changelog, _("No changelog information available"), -1);
- }
-
- /* file list tab */
- pkg_filelist = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_filelist_textview")));
- if ((filelist = slapt_get_pkg_filelist(pkg)) != NULL) {
- if (!g_utf8_validate(filelist, -1, NULL)) {
- char *converted = g_convert(filelist, strlen(filelist), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
- if (converted != NULL) {
+
+ /* file list tab */
+ pkg_filelist = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_filelist_textview")));
+ if ((filelist = slapt_get_pkg_filelist(pkg)) != NULL) {
+ if (!g_utf8_validate(filelist, -1, NULL)) {
+ char *converted = g_convert(filelist, strlen(filelist), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+ if (converted != NULL) {
+ free(filelist);
+ filelist = converted;
+ }
+ }
+ gtk_text_buffer_set_text(pkg_filelist, filelist, -1);
free(filelist);
- filelist = converted;
- }
- }
- gtk_text_buffer_set_text(pkg_filelist, filelist, -1);
- free(filelist);
- } else {
- gtk_text_buffer_set_text(pkg_filelist, _("The list of installed files is only available for installed packages"), -1);
- }
-
- /* set status */
- if ((slapt_get_exact_pkg(trans->exclude_pkgs,pkg->name,pkg->version) != NULL) ||
- slapt_is_excluded(global_config,pkg) == 1) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("Excluded"));
- } else if (slapt_get_exact_pkg(trans->remove_pkgs,pkg->name,pkg->version) != NULL) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("To be Removed"));
- } else if (slapt_get_exact_pkg(trans->install_pkgs,pkg->name,pkg->version) != NULL) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("To be Installed"));
- } else if ( (pkg_upgrade = lsearch_upgrade_transaction(trans,pkg)) != NULL) {
- if (slapt_cmp_pkgs(pkg, pkg_upgrade->installed) == 0 &&
- slapt_cmp_pkg_versions(pkg_upgrade->upgrade->version,pkg_upgrade->installed->version) == 0) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("To be Re-Installed"));
- } else if (slapt_cmp_pkgs(latest_pkg, pkg_upgrade->upgrade) > 0 && slapt_cmp_pkg_versions(pkg->version, pkg_upgrade->upgrade->version) > 0) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("To be Downgraded"));
- } else if (slapt_cmp_pkgs(pkg, pkg_upgrade->upgrade) < 0) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("To be Upgraded"));
- } else if (slapt_cmp_pkgs(pkg, pkg_upgrade->upgrade) == 0) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("To be Installed"));
- } else if (slapt_cmp_pkgs(pkg, pkg_upgrade->upgrade) > 0) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("To be Downgraded"));
+ } else {
+ gtk_text_buffer_set_text(pkg_filelist, _("The list of installed files is only available for installed packages"), -1);
+ }
+
+ /* set status */
+ if ((slapt_get_exact_pkg(trans->exclude_pkgs, pkg->name, pkg->version) != NULL) || slapt_is_excluded(global_config, pkg) == 1) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("Excluded"));
+ } else if (slapt_get_exact_pkg(trans->remove_pkgs, pkg->name, pkg->version) != NULL) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("To be Removed"));
+ } else if (slapt_get_exact_pkg(trans->install_pkgs, pkg->name, pkg->version) != NULL) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("To be Installed"));
+ } else if ((pkg_upgrade = lsearch_upgrade_transaction(trans, pkg)) != NULL) {
+ if (slapt_cmp_pkgs(pkg, pkg_upgrade->installed) == 0 && slapt_cmp_pkg_versions(pkg_upgrade->upgrade->version, pkg_upgrade->installed->version) == 0) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("To be Re-Installed"));
+ } else if (slapt_cmp_pkgs(latest_pkg, pkg_upgrade->upgrade) > 0 && slapt_cmp_pkg_versions(pkg->version, pkg_upgrade->upgrade->version) > 0) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("To be Downgraded"));
+ } else if (slapt_cmp_pkgs(pkg, pkg_upgrade->upgrade) < 0) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("To be Upgraded"));
+ } else if (slapt_cmp_pkgs(pkg, pkg_upgrade->upgrade) == 0) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("To be Installed"));
+ } else if (slapt_cmp_pkgs(pkg, pkg_upgrade->upgrade) > 0) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("To be Downgraded"));
+ }
+ } else if (slapt_get_exact_pkg(installed, pkg->name, pkg->version) != NULL) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("Installed"));
+ } else {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_status")), (gchar *)_("Not Installed"));
}
- } else if (slapt_get_exact_pkg(installed,pkg->name,pkg->version) != NULL) {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("Installed"));
- } else {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_status")),(gchar *)_("Not Installed"));
- }
-
- /* set installed info */
- if (installed_pkg != NULL) {
- gchar size_u[20];
- sprintf(size_u,"%d K",installed_pkg->size_u);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_installed_installed_size")),size_u);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_installed_version")),installed_pkg->version);
- } else {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_installed_installed_size")),"");
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_installed_version")),"");
- }
-
- /* set latest available info */
- if (latest_pkg != NULL) {
- gchar latest_size_c[20],latest_size_u[20];
- sprintf(latest_size_c,"%d K",latest_pkg->size_c);
- sprintf(latest_size_u,"%d K",latest_pkg->size_u);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_version")),latest_pkg->version);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_source")),latest_pkg->mirror);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_size")),latest_size_c);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_installed_size")),latest_size_u);
- } else {
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_version")),"");
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_source")),"");
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_size")),"");
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder,"pkg_info_available_installed_size")),"");
- }
+ /* set installed info */
+ if (installed_pkg != NULL) {
+ gchar size_u[20];
+ sprintf(size_u, "%d K", installed_pkg->size_u);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_installed_installed_size")), size_u);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_installed_version")), installed_pkg->version);
+ } else {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_installed_installed_size")), "");
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_installed_version")), "");
+ }
+
+ /* set latest available info */
+ if (latest_pkg != NULL) {
+ gchar latest_size_c[20], latest_size_u[20];
+ sprintf(latest_size_c, "%d K", latest_pkg->size_c);
+ sprintf(latest_size_u, "%d K", latest_pkg->size_u);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_version")), latest_pkg->version);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_source")), latest_pkg->mirror);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_size")), latest_size_c);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_installed_size")), latest_size_u);
+ } else {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_version")), "");
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_source")), "");
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_size")), "");
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gslapt_builder, "pkg_info_available_installed_size")), "");
+ }
}
-static void get_package_data (void)
+static void get_package_data(void)
{
- GtkLabel *progress_action_label,
- *progress_message_label;
- GtkProgressBar *p_bar,
- *dl_bar;
- guint context_id;
- gfloat dl_files = 0.0,
- dl_count = 0.0;
- FILE *pkg_list_fh;
- slapt_vector_t *new_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
-
- if (progress_window_builder == NULL)
- progress_window_builder = gtk_builder_new ();
-
- gslapt_load_ui (progress_window_builder, "dl_progress_window.ui");
- progress_window = GTK_WIDGET (gtk_builder_get_object (progress_window_builder, "dl_progress_window"));
- gtk_builder_connect_signals (progress_window_builder, NULL);
- gtk_window_set_transient_for (GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
-
- gtk_window_set_title(GTK_WINDOW(progress_window),(gchar *)_("Progress"));
- p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress_progressbar"));
- dl_bar = GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress"));
- progress_action_label = GTK_LABEL(gtk_builder_get_object (progress_window_builder,"dl_progress_action"));
- progress_message_label = GTK_LABEL(gtk_builder_get_object (progress_window_builder,"dl_progress_message"));
-
- gdk_threads_enter();
- lock_toolbar_buttons();
- context_id = gslapt_set_status((gchar *)_("Checking for new package data..."));
- gtk_widget_show_all(progress_window);
- gdk_threads_leave();
-
- #ifdef SLAPT_HAS_GPGME
- dl_files = (global_config->sources->size * 5.0 );
- #else
- dl_files = (global_config->sources->size * 4.0 );
- #endif
-
- if (_cancelled == 1) {
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- unlock_toolbar_buttons();
- gdk_threads_leave();
- return;
- }
-
- /* go through each package source and download the meta data */
- slapt_vector_t_foreach(slapt_source_t *, src, global_config->sources) {
- slapt_vector_t *available_pkgs = NULL;
- slapt_vector_t *patch_pkgs = NULL;
- FILE *tmp_checksum_f = NULL;
- #ifdef SLAPT_HAS_GPGME
- FILE *tmp_signature_f = NULL;
- #endif
- bool compressed = 0;
- SLAPT_PRIORITY_T source_priority = src->priority;
-
- if (src->disabled == true)
- continue;
+ GtkLabel *progress_action_label, *progress_message_label;
+ GtkProgressBar *p_bar, *dl_bar;
+ guint context_id;
+ gfloat dl_files = 0.0, dl_count = 0.0;
+ FILE *pkg_list_fh;
+ slapt_vector_t *new_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
- if (_cancelled == 1) {
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- unlock_toolbar_buttons();
- gdk_threads_leave();
- return;
- }
+ if (progress_window_builder == NULL)
+ progress_window_builder = gtk_builder_new();
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(dl_bar,0.0);
- gtk_label_set_text(progress_message_label,src->url);
- gtk_label_set_text(progress_action_label,(gchar *)_("Retrieving package data..."));
- gdk_threads_leave();
+ gslapt_load_ui(progress_window_builder, "dl_progress_window.ui");
+ progress_window = GTK_WIDGET(gtk_builder_get_object(progress_window_builder, "dl_progress_window"));
+ gtk_builder_connect_signals(progress_window_builder, NULL);
+ gtk_window_set_transient_for(GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
- /* download our SLAPT_PKG_LIST */
- available_pkgs =
- slapt_get_pkg_source_packages(global_config,
- src->url,
- &compressed);
+ gtk_window_set_title(GTK_WINDOW(progress_window), (gchar *)_("Progress"));
+ p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress_progressbar"));
+ dl_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress"));
+ progress_action_label = GTK_LABEL(gtk_builder_get_object(progress_window_builder, "dl_progress_action"));
+ progress_message_label = GTK_LABEL(gtk_builder_get_object(progress_window_builder, "dl_progress_message"));
- /* make sure we found a package listing */
- if (available_pkgs == NULL) {
- gboolean continue_anyway = FALSE;
+ gdk_threads_enter();
+ lock_toolbar_buttons();
+ context_id = gslapt_set_status((gchar *)_("Checking for new package data..."));
+ gtk_widget_show_all(progress_window);
+ gdk_threads_leave();
- gdk_threads_enter();
+#ifdef SLAPT_HAS_GPGME
+ dl_files = (global_config->sources->size * 5.0);
+#else
+ dl_files = (global_config->sources->size * 4.0);
+#endif
- if (_cancelled == 1) {
+ if (_cancelled == 1) {
G_LOCK(_cancelled);
_cancelled = 0;
G_UNLOCK(_cancelled);
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
gtk_widget_destroy(progress_window);
unlock_toolbar_buttons();
- gslapt_clear_status(context_id);
- } else {
- /* prompt the user to continue downloading package sources */
- GtkBuilder * builder = gtk_builder_new ();
- GtkWidget *q;
-
- gslapt_load_ui (builder, "source_failed_dialog.ui");
- q = GTK_WIDGET (gtk_builder_get_object (builder, "source_failed_dialog"));
- gtk_builder_connect_signals (builder, NULL);
-
- gtk_label_set_text(
- GTK_LABEL(gtk_builder_get_object (builder,"failed_source_label")),
- src->url
- );
-
- gtk_widget_show_all(q);
-
- gint result = gtk_dialog_run(GTK_DIALOG(q));
- if (result == GTK_RESPONSE_YES) {
- /* we'll disable this source and continue on */
- /* this is only disabled for the current session since
- slapt_write_rc_config() is not called */
- continue_anyway = TRUE;
- src->disabled = true;
- } else {
- gtk_widget_destroy(progress_window);
- unlock_toolbar_buttons();
- gslapt_clear_status(context_id);
- }
- gtk_widget_destroy(q);
- g_object_unref (G_OBJECT (builder));
-
- }
-
- gdk_threads_leave();
-
- if (continue_anyway == TRUE)
- continue;
- else
+ gdk_threads_leave();
return;
}
- ++dl_count;
+ /* go through each package source and download the meta data */
+ slapt_vector_t_foreach (slapt_source_t *, src, global_config->sources) {
+ slapt_vector_t *available_pkgs = NULL;
+ slapt_vector_t *patch_pkgs = NULL;
+ FILE *tmp_checksum_f = NULL;
+#ifdef SLAPT_HAS_GPGME
+ FILE *tmp_signature_f = NULL;
+#endif
+ bool compressed = 0;
+ SLAPT_PRIORITY_T source_priority = src->priority;
+
+ if (src->disabled == true)
+ continue;
+
+ if (_cancelled == 1) {
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ unlock_toolbar_buttons();
+ gdk_threads_leave();
+ return;
+ }
- if (_cancelled == 1) {
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- unlock_toolbar_buttons();
- gdk_threads_leave();
- return;
- }
+ gdk_threads_enter();
+ gtk_progress_bar_set_fraction(dl_bar, 0.0);
+ gtk_label_set_text(progress_message_label, src->url);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Retrieving package data..."));
+ gdk_threads_leave();
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(p_bar,((dl_count * 100)/dl_files)/100);
- gtk_progress_bar_set_fraction(dl_bar,0.0);
- gtk_label_set_text(progress_action_label,(gchar *)_("Retrieving patch list..."));
- gdk_threads_leave();
+ /* download our SLAPT_PKG_LIST */
+ available_pkgs = slapt_get_pkg_source_packages(global_config, src->url, &compressed);
+ /* make sure we found a package listing */
+ if (available_pkgs == NULL) {
+ gboolean continue_anyway = FALSE;
- /* download SLAPT_PATCHES_LIST */
- patch_pkgs = slapt_get_pkg_source_patches(global_config, src->url, &compressed);
+ gdk_threads_enter();
+ if (_cancelled == 1) {
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ gtk_widget_destroy(progress_window);
+ unlock_toolbar_buttons();
+ gslapt_clear_status(context_id);
+ } else {
+ /* prompt the user to continue downloading package sources */
+ GtkBuilder *builder = gtk_builder_new();
+ GtkWidget *q;
+
+ gslapt_load_ui(builder, "source_failed_dialog.ui");
+ q = GTK_WIDGET(gtk_builder_get_object(builder, "source_failed_dialog"));
+ gtk_builder_connect_signals(builder, NULL);
+
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder, "failed_source_label")), src->url);
+
+ gtk_widget_show_all(q);
+
+ gint result = gtk_dialog_run(GTK_DIALOG(q));
+ if (result == GTK_RESPONSE_YES) {
+ /* we'll disable this source and continue on */
+ /* this is only disabled for the current session since slapt_write_rc_config() is not called */
+ continue_anyway = TRUE;
+ src->disabled = true;
+ } else {
+ gtk_widget_destroy(progress_window);
+ unlock_toolbar_buttons();
+ gslapt_clear_status(context_id);
+ }
+ gtk_widget_destroy(q);
+ g_object_unref(G_OBJECT(builder));
+ }
- if (_cancelled == 1) {
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- unlock_toolbar_buttons();
- gdk_threads_leave();
- return;
- }
+ gdk_threads_leave();
- ++dl_count;
+ if (continue_anyway == TRUE)
+ continue;
+ else
+ return;
+ }
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(p_bar,((dl_count * 100)/dl_files)/100);
- gtk_progress_bar_set_fraction(dl_bar,0.0);
- gtk_label_set_text(progress_action_label,(gchar *)_("Retrieving checksum list..."));
- gdk_threads_leave();
+ ++dl_count;
+
+ if (_cancelled == 1) {
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ unlock_toolbar_buttons();
+ gdk_threads_leave();
+ return;
+ }
+ gdk_threads_enter();
+ gtk_progress_bar_set_fraction(p_bar, ((dl_count * 100) / dl_files) / 100);
+ gtk_progress_bar_set_fraction(dl_bar, 0.0);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Retrieving patch list..."));
+ gdk_threads_leave();
- /* download checksum file */
- tmp_checksum_f =
- slapt_get_pkg_source_checksums(global_config,
- src->url,
- &compressed);
+ /* download SLAPT_PATCHES_LIST */
+ patch_pkgs = slapt_get_pkg_source_patches(global_config, src->url, &compressed);
+
+ if (_cancelled == 1) {
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ unlock_toolbar_buttons();
+ gdk_threads_leave();
+ return;
+ }
- if (tmp_checksum_f == NULL) {
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- unlock_toolbar_buttons();
- if (_cancelled == 1) {
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- } else {
- notify((gchar *)_("Source download failed"),src->url);
- }
- gdk_threads_leave();
- return;
- }
+ ++dl_count;
- ++dl_count;
+ gdk_threads_enter();
+ gtk_progress_bar_set_fraction(p_bar, ((dl_count * 100) / dl_files) / 100);
+ gtk_progress_bar_set_fraction(dl_bar, 0.0);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Retrieving checksum list..."));
+ gdk_threads_leave();
- #ifdef SLAPT_HAS_GPGME
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(p_bar,((dl_count * 100)/dl_files)/100);
- gtk_progress_bar_set_fraction(dl_bar,0.0);
- gtk_label_set_text(progress_action_label,(gchar *)_("Retrieving checksum signature..."));
- gdk_threads_leave();
+ /* download checksum file */
+ tmp_checksum_f = slapt_get_pkg_source_checksums(global_config, src->url, &compressed);
+
+ if (tmp_checksum_f == NULL) {
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ unlock_toolbar_buttons();
+ if (_cancelled == 1) {
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ } else {
+ notify((gchar *)_("Source download failed"), src->url);
+ }
+ gdk_threads_leave();
+ return;
+ }
- tmp_signature_f = slapt_get_pkg_source_checksums_signature (global_config,
- src->url,
- &compressed);
+ ++dl_count;
- if (tmp_signature_f == NULL) {
- if (_cancelled == 1) {
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- unlock_toolbar_buttons();
- gdk_threads_leave();
- return;
- }
- } else {
- FILE *tmp_checksum_to_verify_f = NULL;
-
- /* if we downloaded the compressed checksums, open it raw (w/o gunzippign) */
- if (compressed) {
- char *filename = slapt_gen_filename_from_url(src->url,
- SLAPT_CHECKSUM_FILE_GZ);
- tmp_checksum_to_verify_f = slapt_open_file(filename,"r");
- free(filename);
- } else {
- tmp_checksum_to_verify_f = tmp_checksum_f;
- }
-
- if (tmp_checksum_to_verify_f != NULL) {
- slapt_code_t verified = SLAPT_CHECKSUMS_NOT_VERIFIED;
+#ifdef SLAPT_HAS_GPGME
gdk_threads_enter();
- gtk_label_set_text(progress_action_label,(gchar *)_("Verifying checksum signature..."));
+ gtk_progress_bar_set_fraction(p_bar, ((dl_count * 100) / dl_files) / 100);
+ gtk_progress_bar_set_fraction(dl_bar, 0.0);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Retrieving checksum signature..."));
gdk_threads_leave();
- verified = slapt_gpg_verify_checksums(tmp_checksum_to_verify_f, tmp_signature_f);
- if (verified == SLAPT_CHECKSUMS_NOT_VERIFIED) {
- fclose(tmp_checksum_f);
- fclose(tmp_signature_f);
- if (compressed)
- fclose(tmp_checksum_to_verify_f);
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- unlock_toolbar_buttons();
- notify((gchar *)_("GPG Key verification failed"),src->url);
- gdk_threads_leave();
- return;
- }
- }
-
- fclose(tmp_signature_f);
- /* if we opened the raw gzipped checksums, close it here */
- if (compressed)
- fclose(tmp_checksum_to_verify_f);
- else
- rewind(tmp_checksum_f);
- }
+ tmp_signature_f = slapt_get_pkg_source_checksums_signature(global_config, src->url, &compressed);
+
+ if (tmp_signature_f == NULL) {
+ if (_cancelled == 1) {
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ unlock_toolbar_buttons();
+ gdk_threads_leave();
+ return;
+ }
+ } else {
+ FILE *tmp_checksum_to_verify_f = NULL;
- ++dl_count;
- #endif
+ /* if we downloaded the compressed checksums, open it raw (w/o gunzippign) */
+ if (compressed) {
+ char *filename = slapt_gen_filename_from_url(src->url, SLAPT_CHECKSUM_FILE_GZ);
+ tmp_checksum_to_verify_f = slapt_open_file(filename, "r");
+ free(filename);
+ } else {
+ tmp_checksum_to_verify_f = tmp_checksum_f;
+ }
- /* download changelog file */
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(p_bar,((dl_count * 100)/dl_files)/100);
- gtk_progress_bar_set_fraction(dl_bar,0.0);
- gtk_label_set_text(progress_action_label,(gchar *)_("Retrieving ChangeLog.txt..."));
- gdk_threads_leave();
+ if (tmp_checksum_to_verify_f != NULL) {
+ slapt_code_t verified = SLAPT_CHECKSUMS_NOT_VERIFIED;
+ gdk_threads_enter();
+ gtk_label_set_text(progress_action_label, (gchar *)_("Verifying checksum signature..."));
+ gdk_threads_leave();
+ verified = slapt_gpg_verify_checksums(tmp_checksum_to_verify_f, tmp_signature_f);
+ if (verified == SLAPT_CHECKSUMS_NOT_VERIFIED) {
+ fclose(tmp_checksum_f);
+ fclose(tmp_signature_f);
+ if (compressed)
+ fclose(tmp_checksum_to_verify_f);
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ unlock_toolbar_buttons();
+ notify((gchar *)_("GPG Key verification failed"), src->url);
+ gdk_threads_leave();
+ return;
+ }
+ }
- slapt_get_pkg_source_changelog(global_config,
- src->url,
- &compressed);
+ fclose(tmp_signature_f);
+ /* if we opened the raw gzipped checksums, close it here */
+ if (compressed)
+ fclose(tmp_checksum_to_verify_f);
+ else
+ rewind(tmp_checksum_f);
+ }
+ ++dl_count;
+#endif
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(p_bar,((dl_count * 100)/dl_files)/100);
- gtk_progress_bar_set_fraction(dl_bar,0.0);
- gtk_label_set_text(progress_action_label,(gchar *)_("Reading Package Lists..."));
- gdk_threads_leave();
+ /* download changelog file */
+ gdk_threads_enter();
+ gtk_progress_bar_set_fraction(p_bar, ((dl_count * 100) / dl_files) / 100);
+ gtk_progress_bar_set_fraction(dl_bar, 0.0);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Retrieving ChangeLog.txt..."));
+ gdk_threads_leave();
- if (available_pkgs) {
+ slapt_get_pkg_source_changelog(global_config, src->url, &compressed);
- /* map packages to md5sums */
- slapt_get_md5sums(available_pkgs,tmp_checksum_f);
+ gdk_threads_enter();
+ gtk_progress_bar_set_fraction(p_bar, ((dl_count * 100) / dl_files) / 100);
+ gtk_progress_bar_set_fraction(dl_bar, 0.0);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Reading Package Lists..."));
+ gdk_threads_leave();
- /* put these into our new package list */
- slapt_vector_t_foreach(slapt_pkg_info_t *, apkg, available_pkgs) {
- /* honor the mirror if it was set in the PACKAGES.TXT */
- if (apkg->mirror == NULL || strlen(apkg->mirror) == 0) {
- if (apkg->mirror != NULL) {
- free(apkg->mirror);
+ if (available_pkgs) {
+ /* map packages to md5sums */
+ slapt_get_md5sums(available_pkgs, tmp_checksum_f);
+
+ /* put these into our new package list */
+ slapt_vector_t_foreach (slapt_pkg_info_t *, apkg, available_pkgs) {
+ /* honor the mirror if it was set in the PACKAGES.TXT */
+ if (apkg->mirror == NULL || strlen(apkg->mirror) == 0) {
+ if (apkg->mirror != NULL) {
+ free(apkg->mirror);
+ }
+ apkg->mirror = strdup(src->url);
+ }
+ /* set the priority of the package based on the source */
+ apkg->priority = source_priority;
+ slapt_vector_t_add(new_pkgs, apkg);
}
- apkg->mirror = strdup(src->url);
- }
- /* set the priority of the package based on the source */
- apkg->priority = source_priority;
- slapt_vector_t_add(new_pkgs, apkg);
- }
-
- /* don't free the slapt_pkg_info_t objects
- as they are now part of new_pkgs */
- available_pkgs->free_function = NULL;
- slapt_vector_t_free(available_pkgs);
- }
- if (patch_pkgs) {
+ /* don't free the slapt_pkg_info_t objects as they are now part of new_pkgs */
+ available_pkgs->free_function = NULL;
+ slapt_vector_t_free(available_pkgs);
+ }
- /* map packages to md5sums */
- slapt_get_md5sums(patch_pkgs,tmp_checksum_f);
+ if (patch_pkgs) {
+ /* map packages to md5sums */
+ slapt_get_md5sums(patch_pkgs, tmp_checksum_f);
+
+ /* put these into our new package list */
+ slapt_vector_t_foreach (slapt_pkg_info_t *, ppkg, patch_pkgs) {
+ /* honor the mirror if it was set in the PACKAGES.TXT */
+ if (ppkg->mirror == NULL || strlen(ppkg->mirror) == 0) {
+ if (ppkg->mirror != NULL) {
+ free(ppkg->mirror);
+ }
+ ppkg->mirror = strdup(src->url);
+ }
+ /* set the priority of the package based on the source, plus 1 for the patch priority */
+ if (global_config->use_priority == true)
+ ppkg->priority = source_priority + 1;
+ else
+ ppkg->priority = source_priority;
+ slapt_vector_t_add(new_pkgs, ppkg);
+ }
- /* put these into our new package list */
- slapt_vector_t_foreach(slapt_pkg_info_t *, ppkg, patch_pkgs) {
- /* honor the mirror if it was set in the PACKAGES.TXT */
- if (ppkg->mirror == NULL || strlen(ppkg->mirror) == 0) {
- if (ppkg->mirror != NULL) {
- free(ppkg->mirror);
- }
- ppkg->mirror = strdup(src->url);
+ /* don't free the slapt_pkg_info_t objects as they are now part of new_pkgs */
+ patch_pkgs->free_function = NULL;
+ slapt_vector_t_free(patch_pkgs);
}
- /* set the priority of the package based on the source, plus 1 for the patch priority */
- if (global_config->use_priority == true)
- ppkg->priority = source_priority + 1;
- else
- ppkg->priority = source_priority;
- slapt_vector_t_add(new_pkgs,ppkg);
- }
-
- /* don't free the slapt_pkg_info_t objects
- as they are now part of new_pkgs */
- patch_pkgs->free_function = NULL;
- slapt_vector_t_free(patch_pkgs);
- }
- fclose(tmp_checksum_f);
+ fclose(tmp_checksum_f);
- }/* end for loop */
+ } /* end for loop */
- /* if all our downloads where a success, write to SLAPT_PKG_LIST_L */
- if ( (pkg_list_fh = slapt_open_file(SLAPT_PKG_LIST_L,"w+")) == NULL )
- exit(1);
+ /* if all our downloads where a success, write to SLAPT_PKG_LIST_L */
+ if ((pkg_list_fh = slapt_open_file(SLAPT_PKG_LIST_L, "w+")) == NULL)
+ exit(1);
- slapt_write_pkg_data(NULL,pkg_list_fh,new_pkgs);
+ slapt_write_pkg_data(NULL, pkg_list_fh, new_pkgs);
- fclose(pkg_list_fh);
+ fclose(pkg_list_fh);
- slapt_vector_t_free(new_pkgs);
+ slapt_vector_t_free(new_pkgs);
- /* reset our currently selected packages */
- slapt_free_transaction(trans);
- trans = slapt_init_transaction();
+ /* reset our currently selected packages */
+ slapt_free_transaction(trans);
+ trans = slapt_init_transaction();
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- unlock_toolbar_buttons();
- rebuild_treeviews(progress_window,TRUE);
- gdk_threads_leave();
-
- g_object_unref (G_OBJECT (progress_window_builder));
- progress_window_builder = NULL;
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ unlock_toolbar_buttons();
+ rebuild_treeviews(progress_window, TRUE);
+ gdk_threads_leave();
+ g_object_unref(G_OBJECT(progress_window_builder));
+ progress_window_builder = NULL;
}
-int gtk_progress_callback(void *data, double dltotal, double dlnow,
- double ultotal, double ulnow)
+int gtk_progress_callback(void *data, double dltotal, double dlnow, double ultotal, double ulnow)
{
- GtkProgressBar *p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder,"dl_progress"));
- double perc = 1.0;
- struct slapt_progress_data *cb_data = (struct slapt_progress_data *)data;
- time_t now = time(NULL);
- double elapsed = now - cb_data->start;
- double speed = dlnow / (elapsed > 0 ? elapsed : 1);
- gchar *status = NULL;
+ GtkProgressBar *p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress"));
+ double perc = 1.0;
+ struct slapt_progress_data *cb_data = (struct slapt_progress_data *)data;
+ time_t now = time(NULL);
+ double elapsed = now - cb_data->start;
+ double speed = dlnow / (elapsed > 0 ? elapsed : 1);
+ gchar *status = NULL;
- if (_cancelled == 1) {
- return -1;
- }
+ if (_cancelled == 1) {
+ return -1;
+ }
- if (p_bar == NULL) {
- return -1;
- }
+ if (p_bar == NULL) {
+ return -1;
+ }
- if ( dltotal != 0.0 )
- perc = ((dlnow * 100)/dltotal)/100;
+ if (dltotal != 0.0)
+ perc = ((dlnow * 100) / dltotal) / 100;
- status = g_strdup_printf((gchar *)_("Download rate: %.0f%s/s"),
- (speed > 1000) ? (speed > 1000000) ? speed / 1000000 : speed / 1000 : speed,
- (speed > 1000) ? (speed > 1000000) ? "M" : "k" : "b");
+ status = g_strdup_printf((gchar *)_("Download rate: %.0f%s/s"),
+ (speed > 1000) ? (speed > 1000000) ? speed / 1000000 : speed / 1000 : speed,
+ (speed > 1000) ? (speed > 1000000) ? "M" : "k" : "b");
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(p_bar,perc);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(progress_window_builder,"progress_dl_speed")),status);
- gdk_threads_leave();
+ gdk_threads_enter();
+ gtk_progress_bar_set_fraction(p_bar, perc);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(progress_window_builder, "progress_dl_speed")), status);
+ gdk_threads_leave();
- g_free(status);
+ g_free(status);
- return 0;
+ return 0;
}
-static void rebuild_treeviews (GtkWidget *current_window,gboolean reload)
+static void rebuild_treeviews(GtkWidget *current_window, gboolean reload)
{
- GtkWidget *treeview;
- GtkListStore *store;
- GtkTreeModelFilter *filter_model;
- GtkTreeModelSort *package_model;
- const gchar *search_text = gtk_entry_get_text(
- GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
+ GtkWidget *treeview;
+ GtkListStore *store;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModelSort *package_model;
+ const gchar *search_text = gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
- set_busy_cursor();
+ set_busy_cursor();
- if (reload == TRUE) {
- slapt_vector_t *all_ptr,*installed_ptr;
+ if (reload == TRUE) {
+ slapt_vector_t *all_ptr, *installed_ptr;
- installed_ptr = installed;
- all_ptr = all;
+ installed_ptr = installed;
+ all_ptr = all;
- installed = slapt_get_installed_pkgs();
- all = slapt_get_available_pkgs();
+ installed = slapt_get_installed_pkgs();
+ all = slapt_get_available_pkgs();
- slapt_vector_t_free(installed_ptr);
- slapt_vector_t_free(all_ptr);
- }
+ slapt_vector_t_free(installed_ptr);
+ slapt_vector_t_free(all_ptr);
+ }
- treeview = (GtkWidget *)gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview");
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
+ treeview = (GtkWidget *)gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview");
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- store = GTK_LIST_STORE(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
- gtk_list_store_clear(store);
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ store = GTK_LIST_STORE(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+ gtk_list_store_clear(store);
- if (reload == TRUE) {
- gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")),"");
- }
+ if (reload == TRUE) {
+ gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")), "");
+ }
- rebuild_package_action_menu();
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_all_packages_menu")), TRUE);
- build_package_treeviewlist(treeview);
+ rebuild_package_action_menu();
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_all_packages_menu")), TRUE);
+ build_package_treeviewlist(treeview);
- if ((reload == FALSE) && (strcmp(search_text,"") != 0)) {
- gchar *search = g_strdup(search_text);
- build_searched_treeviewlist(GTK_WIDGET(treeview),search);
- g_free(search);
- }
+ if ((reload == FALSE) && (strcmp(search_text, "") != 0)) {
+ gchar *search = g_strdup(search_text);
+ build_searched_treeviewlist(GTK_WIDGET(treeview), search);
+ g_free(search);
+ }
}
-static guint gslapt_set_status (const gchar *msg)
+static guint gslapt_set_status(const gchar *msg)
{
- guint context_id;
- GtkStatusbar *bar = GTK_STATUSBAR(gtk_builder_get_object(gslapt_builder,"bottom_statusbar"));
- context_id = gtk_statusbar_get_context_id(bar,msg);
+ guint context_id;
+ GtkStatusbar *bar = GTK_STATUSBAR(gtk_builder_get_object(gslapt_builder, "bottom_statusbar"));
+ context_id = gtk_statusbar_get_context_id(bar, msg);
- gtk_statusbar_push(bar,context_id,msg);
+ gtk_statusbar_push(bar, context_id, msg);
- return context_id;
+ return context_id;
}
-static void gslapt_clear_status (guint context_id)
+static void gslapt_clear_status(guint context_id)
{
- GtkStatusbar *bar = GTK_STATUSBAR(gtk_builder_get_object(gslapt_builder,"bottom_statusbar"));
+ GtkStatusbar *bar = GTK_STATUSBAR(gtk_builder_get_object(gslapt_builder, "bottom_statusbar"));
- gtk_statusbar_pop(bar,context_id);
+ gtk_statusbar_pop(bar, context_id);
}
-static void lock_toolbar_buttons (void)
+static void lock_toolbar_buttons(void)
{
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"top_menubar")),FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "top_menubar")), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"action_bar_update_button")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"action_bar_upgrade_button")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"action_bar_execute_button")),FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_update_button")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_upgrade_button")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_execute_button")), FALSE);
}
-static void unlock_toolbar_buttons (void)
+static void unlock_toolbar_buttons(void)
{
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "top_menubar")), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"top_menubar")),TRUE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"action_bar_update_button")),TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"action_bar_upgrade_button")),TRUE);
-
- if (
- trans->upgrade_pkgs->size != 0
- || trans->remove_pkgs->size != 0
- || trans->install_pkgs->size != 0
- || trans->reinstall_pkgs->size != 0
- ) {
- set_execute_active();
- }
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_update_button")), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_upgrade_button")), TRUE);
+ if (trans->upgrade_pkgs->size != 0 || trans->remove_pkgs->size != 0 || trans->install_pkgs->size != 0 || trans->reinstall_pkgs->size != 0) {
+ set_execute_active();
+ }
}
-static void lhandle_transaction (GtkBuilder *b)
+static void lhandle_transaction(GtkBuilder *b)
{
- GtkCheckButton *dl_only_checkbutton;
- gboolean dl_only = FALSE;
- slapt_vector_t *installed_ptr;
-
- gdk_threads_enter();
- lock_toolbar_buttons();
-
- dl_only_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(b,"download_only_checkbutton"));
- dl_only = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dl_only_checkbutton));
- gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(b,"transaction_window")));
- g_object_unref (G_OBJECT (b));
- gdk_threads_leave();
-
- /* download the pkgs */
- if (trans->install_pkgs->size > 0 || trans->upgrade_pkgs->size > 0 || trans->reinstall_pkgs->size > 0) {
- const char *err = download_packages();
- if ( err != NULL || _cancelled == 1) {
-
- gdk_threads_enter();
- if (err != NULL && _cancelled == 0) {
- notify((gchar *)_("Error"),(gchar *)err);
- }
- unlock_toolbar_buttons();
- gdk_threads_leave();
-
- if (_cancelled == 1) {
+ GtkCheckButton *dl_only_checkbutton;
+ gboolean dl_only = FALSE;
+ slapt_vector_t *installed_ptr;
+
+ gdk_threads_enter();
+ lock_toolbar_buttons();
+
+ dl_only_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(b, "download_only_checkbutton"));
+ dl_only = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dl_only_checkbutton));
+ gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(b, "transaction_window")));
+ g_object_unref(G_OBJECT(b));
+ gdk_threads_leave();
+
+ /* download the pkgs */
+ if (trans->install_pkgs->size > 0 || trans->upgrade_pkgs->size > 0 || trans->reinstall_pkgs->size > 0) {
+ const char *err = download_packages();
+ if (err != NULL || _cancelled == 1) {
+ gdk_threads_enter();
+ if (err != NULL && _cancelled == 0) {
+ notify((gchar *)_("Error"), (gchar *)err);
+ }
+ unlock_toolbar_buttons();
+ gdk_threads_leave();
+
+ if (_cancelled == 1) {
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ }
+ return;
+ }
+ }
+
+ /* return early if download_only is set */
+ if (dl_only == TRUE) {
+ gdk_threads_enter();
+ unlock_toolbar_buttons();
+ clear_execute_active();
+ unlock_toolbar_buttons();
+ gdk_threads_leave();
+ return;
+ }
+
+ if (_cancelled == 1) {
G_LOCK(_cancelled);
_cancelled = 0;
G_UNLOCK(_cancelled);
- }
- return;
+ gdk_threads_enter();
+ unlock_toolbar_buttons();
+ rebuild_treeviews(NULL, FALSE);
+ clear_execute_active();
+ gdk_threads_leave();
+ return;
}
- }
+ /* begin removing, installing, and upgrading */
+ if (install_packages() == FALSE) {
+ gdk_threads_enter();
+ notify((gchar *)_("Error"), (gchar *)_("pkgtools returned an error"));
+ unlock_toolbar_buttons();
+ gdk_threads_leave();
+ return;
+ }
- /* return early if download_only is set */
- if ( dl_only == TRUE ) {
+ /* set busy cursor */
gdk_threads_enter();
- unlock_toolbar_buttons();
clear_execute_active();
- unlock_toolbar_buttons();
+ set_busy_cursor();
gdk_threads_leave();
- return;
- }
- if (_cancelled == 1) {
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- gdk_threads_enter();
- unlock_toolbar_buttons();
- rebuild_treeviews(NULL,FALSE);
- clear_execute_active();
- gdk_threads_leave();
- return;
- }
+ slapt_free_transaction(trans);
+ trans = slapt_init_transaction();
+ /* rebuild the installed list */
+ installed_ptr = installed;
+ installed = slapt_get_installed_pkgs();
+ slapt_vector_t_free(installed_ptr);
- /* begin removing, installing, and upgrading */
- if ( install_packages() == FALSE ) {
gdk_threads_enter();
- notify((gchar *)_("Error"),(gchar *)_("pkgtools returned an error"));
+ /* reset cursor */
+ rebuild_treeviews(NULL, FALSE);
+ rebuild_package_action_menu();
unlock_toolbar_buttons();
+ unset_busy_cursor();
+ notify((gchar *)_("Completed actions"), (gchar *)_("Successfully executed all actions."));
gdk_threads_leave();
- return;
- }
-
- /* set busy cursor */
- gdk_threads_enter();
- clear_execute_active();
- set_busy_cursor();
- gdk_threads_leave();
-
- slapt_free_transaction(trans);
- trans = slapt_init_transaction();
- /* rebuild the installed list */
- installed_ptr = installed;
- installed = slapt_get_installed_pkgs();
- slapt_vector_t_free(installed_ptr);
-
- gdk_threads_enter();
- /* reset cursor */
- rebuild_treeviews(NULL,FALSE);
- rebuild_package_action_menu();
- unlock_toolbar_buttons();
- unset_busy_cursor();
- notify((gchar *)_("Completed actions"),(gchar *)_("Successfully executed all actions."));
- gdk_threads_leave();
-
}
-void transaction_okbutton_clicked (GtkWidget *w, gpointer *user_data)
+void transaction_okbutton_clicked(GtkWidget *w, gpointer *user_data)
{
- GThread *gdp;
+ GThread *gdp;
-#if !GLIB_CHECK_VERSION (2, 31, 0)
- gdp = g_thread_create((GThreadFunc)lhandle_transaction,GTK_BUILDER(user_data),FALSE,NULL);
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+ gdp = g_thread_create((GThreadFunc)lhandle_transaction, GTK_BUILDER(user_data), FALSE, NULL);
#else
- gdp = g_thread_new("GslaptTransactionStart", (GThreadFunc)lhandle_transaction,GTK_BUILDER(user_data));
+ gdp = g_thread_new("GslaptTransactionStart", (GThreadFunc)lhandle_transaction, GTK_BUILDER(user_data));
#endif
- return;
-
+ return;
}
static void build_sources_treeviewlist(GtkWidget *treeview)
{
- GtkListStore *store;
- GtkTreeIter iter;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *select;
- GdkPixbuf *enabled_status_icon = gslapt_img("pkg_action_installed.png");
- GdkPixbuf *disabled_status_icon = gslapt_img("pkg_action_available.png");
- gboolean enabled = TRUE;
-
- store = gtk_list_store_new (
- 5,
- GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_BOOLEAN,G_TYPE_STRING,G_TYPE_UINT
- );
-
- slapt_vector_t_foreach(slapt_source_t *, src, global_config->sources) {
- GdkPixbuf *status_icon;
- const char *priority_str;
-
- if ( src->url == NULL )
- continue;
-
- if (src->disabled == true) {
- enabled = FALSE;
- status_icon = disabled_status_icon;
- } else {
- enabled = TRUE;
- status_icon = enabled_status_icon;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *select;
+ GdkPixbuf *enabled_status_icon = gslapt_img("pkg_action_installed.png");
+ GdkPixbuf *disabled_status_icon = gslapt_img("pkg_action_available.png");
+ gboolean enabled = TRUE;
+
+ store = gtk_list_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT);
+
+ slapt_vector_t_foreach (slapt_source_t *, src, global_config->sources) {
+ GdkPixbuf *status_icon;
+ const char *priority_str;
+
+ if (src->url == NULL)
+ continue;
+
+ if (src->disabled == true) {
+ enabled = FALSE;
+ status_icon = disabled_status_icon;
+ } else {
+ enabled = TRUE;
+ status_icon = enabled_status_icon;
+ }
+
+ priority_str = slapt_priority_to_str(src->priority);
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, 0, status_icon, 1, src->url, 2, enabled, 3, priority_str, 4, src->priority, -1);
}
- priority_str = slapt_priority_to_str(src->priority);
+ /* column for enabled status */
+ renderer = gtk_cell_renderer_pixbuf_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Enabled"), renderer, "pixbuf", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store,&iter,
- 0,status_icon,
- 1,src->url,
- 2,enabled,
- 3,priority_str,
- 4,src->priority,
- -1);
-
- }
-
- /* column for enabled status */
- renderer = gtk_cell_renderer_pixbuf_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Enabled"), renderer,
- "pixbuf", 0, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
-
- /* column for url */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Source"), renderer,
- "text", 1, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
-
- /* enabled/disabled bool column */
- renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes((gchar *)_("Visible"),renderer,
- "radio",2,NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_visible(column,FALSE);
-
- /* priority column */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes((gchar *)_("Priority"),renderer,
- "text",3,NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview),GTK_TREE_MODEL(store));
-
- select = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
- g_signal_handlers_disconnect_by_func(G_OBJECT(treeview),toggle_source_status,NULL);
- g_signal_connect(G_OBJECT(treeview),"cursor-changed",
- G_CALLBACK(toggle_source_status),NULL);
+ /* column for url */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Source"), renderer, "text", 1, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+
+ /* enabled/disabled bool column */
+ renderer = gtk_cell_renderer_toggle_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Visible"), renderer, "radio", 2, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_visible(column, FALSE);
+ /* priority column */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Priority"), renderer, "text", 3, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+
+ gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
+
+ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+ gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(treeview), toggle_source_status, NULL);
+ g_signal_connect(G_OBJECT(treeview), "cursor-changed", G_CALLBACK(toggle_source_status), NULL);
}
static void build_exclude_treeviewlist(GtkWidget *treeview)
{
- GtkListStore *store;
- GtkTreeIter iter;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *select;
-
- store = gtk_list_store_new (
- 1, /* exclude expression */
- G_TYPE_STRING
- );
-
- slapt_vector_t_foreach(char *, exclude, global_config->exclude_list) {
- if (exclude == NULL) {
- continue;
- }
- gtk_list_store_append (store, &iter);
- gtk_list_store_set(store,&iter,0,exclude,-1);
- }
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *select;
+
+ store = gtk_list_store_new(
+ 1, /* exclude expression */
+ G_TYPE_STRING);
- /* column for url */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Expression"), renderer,
- "text", 0, NULL);
- gtk_tree_view_column_set_sort_column_id (column, 0);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
+ slapt_vector_t_foreach (char *, exclude, global_config->exclude_list) {
+ if (exclude == NULL) {
+ continue;
+ }
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, 0, exclude, -1);
+ }
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview),GTK_TREE_MODEL(store));
- select = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
+ /* column for url */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Expression"), renderer, "text", 0, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, 0);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
+ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+ gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
}
-static int populate_transaction_window (GtkBuilder *b)
+static int populate_transaction_window(GtkBuilder *b)
{
- GtkTreeView *summary_treeview;
- GtkTreeStore *store;
- GtkTreeIter iter,child_iter;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkLabel *sum_pkg_num,*sum_dl_size,*sum_free_space;
- double dl_size = 0,free_space = 0,already_dl_size = 0;
- gchar buf[512];
-
- summary_treeview = GTK_TREE_VIEW(gtk_builder_get_object(b,"transaction_summary_treeview"));
- store = gtk_tree_store_new (1,G_TYPE_STRING);
- sum_pkg_num = GTK_LABEL(gtk_builder_get_object(b,"summary_pkg_numbers"));
- sum_dl_size = GTK_LABEL(gtk_builder_get_object(b,"summary_dl_size"));
- sum_free_space = GTK_LABEL(gtk_builder_get_object(b,"summary_free_space"));
-
- /* setup the store */
- if ( trans->missing_err->size > 0 ) {
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("Packages with unmet dependencies"),-1);
-
- slapt_vector_t_foreach(slapt_pkg_err_t *, missing_err, trans->missing_err) {
- gchar *err = g_strdup_printf("%s: Depends: %s", missing_err->pkg, missing_err->error);
-
- gtk_tree_store_append (store, &child_iter, &iter);
- gtk_tree_store_set(store,&child_iter,0,err,-1);
- g_free(err);
+ GtkTreeView *summary_treeview;
+ GtkTreeStore *store;
+ GtkTreeIter iter, child_iter;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkLabel *sum_pkg_num, *sum_dl_size, *sum_free_space;
+ double dl_size = 0, free_space = 0, already_dl_size = 0;
+ gchar buf[512];
+
+ summary_treeview = GTK_TREE_VIEW(gtk_builder_get_object(b, "transaction_summary_treeview"));
+ store = gtk_tree_store_new(1, G_TYPE_STRING);
+ sum_pkg_num = GTK_LABEL(gtk_builder_get_object(b, "summary_pkg_numbers"));
+ sum_dl_size = GTK_LABEL(gtk_builder_get_object(b, "summary_dl_size"));
+ sum_free_space = GTK_LABEL(gtk_builder_get_object(b, "summary_free_space"));
+
+ /* setup the store */
+ if (trans->missing_err->size > 0) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("Packages with unmet dependencies"), -1);
+
+ slapt_vector_t_foreach (slapt_pkg_err_t *, missing_err, trans->missing_err) {
+ gchar *err = g_strdup_printf("%s: Depends: %s", missing_err->pkg, missing_err->error);
+
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, err, -1);
+ g_free(err);
+ }
}
- }
-
- if ( trans->conflict_err->size > 0 ) {
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("Package conflicts"),-1);
-
- slapt_vector_t_foreach(slapt_pkg_err_t *, conflict_err, trans->conflict_err) {
- gchar *err = g_strdup_printf("%s%s%s%s",
- conflict_err->error,
- (gchar *)_(", which is required by "),
- conflict_err->pkg,
- (gchar *)_(", is excluded")
- );
-
- gtk_tree_store_append (store, &child_iter, &iter);
- gtk_tree_store_set(store,&child_iter,0,err,-1);
- g_free(err);
+
+ if (trans->conflict_err->size > 0) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("Package conflicts"), -1);
+
+ slapt_vector_t_foreach (slapt_pkg_err_t *, conflict_err, trans->conflict_err) {
+ gchar *err = g_strdup_printf("%s%s%s%s",
+ conflict_err->error,
+ (gchar *)_(", which is required by "),
+ conflict_err->pkg,
+ (gchar *)_(", is excluded"));
+
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, err, -1);
+ g_free(err);
+ }
}
- }
- if ( trans->exclude_pkgs->size > 0 ) {
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("Packages excluded"),-1);
+ if (trans->exclude_pkgs->size > 0) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("Packages excluded"), -1);
- slapt_vector_t_foreach(slapt_pkg_info_t *, exclude_pkg, trans->exclude_pkgs) {
- gchar *detail = g_strdup_printf("%s %s", exclude_pkg->name, exclude_pkg->version);
+ slapt_vector_t_foreach (slapt_pkg_info_t *, exclude_pkg, trans->exclude_pkgs) {
+ gchar *detail = g_strdup_printf("%s %s", exclude_pkg->name, exclude_pkg->version);
- gtk_tree_store_append (store, &child_iter, &iter);
- gtk_tree_store_set(store, &child_iter, 0, detail, -1);
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, detail, -1);
- g_free(detail);
+ g_free(detail);
+ }
}
- }
- if ( trans->install_pkgs->size > 0 ) {
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("Packages to be installed"),-1);
+ if (trans->install_pkgs->size > 0) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("Packages to be installed"), -1);
- slapt_vector_t_foreach(slapt_pkg_info_t *, install_pkg, trans->install_pkgs) {
- gchar *detail = g_strdup_printf("%s %s", install_pkg->name, install_pkg->version);
+ slapt_vector_t_foreach (slapt_pkg_info_t *, install_pkg, trans->install_pkgs) {
+ gchar *detail = g_strdup_printf("%s %s", install_pkg->name, install_pkg->version);
- gtk_tree_store_append (store, &child_iter, &iter);
- gtk_tree_store_set(store, &child_iter, 0, detail, -1);
- dl_size += install_pkg->size_c;
- already_dl_size += slapt_get_pkg_file_size(global_config, install_pkg)/1024;
- free_space += install_pkg->size_u;
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, detail, -1);
+ dl_size += install_pkg->size_c;
+ already_dl_size += slapt_get_pkg_file_size(global_config, install_pkg) / 1024;
+ free_space += install_pkg->size_u;
- g_free(detail);
+ g_free(detail);
+ }
}
- }
- if (trans->upgrade_pkgs->size > 0) {
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("Packages to be upgraded"),-1);
+ if (trans->upgrade_pkgs->size > 0) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("Packages to be upgraded"), -1);
- slapt_vector_t_foreach(slapt_pkg_upgrade_t *, upgrade_pkg, trans->upgrade_pkgs) {
- gchar *detail = g_strdup_printf("%s (%s) -> %s",
- upgrade_pkg->installed->name,
- upgrade_pkg->installed->version,
- upgrade_pkg->upgrade->version
- );
+ slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade_pkg, trans->upgrade_pkgs) {
+ gchar *detail = g_strdup_printf("%s (%s) -> %s",
+ upgrade_pkg->installed->name,
+ upgrade_pkg->installed->version,
+ upgrade_pkg->upgrade->version);
- gtk_tree_store_append (store, &child_iter, &iter);
- gtk_tree_store_set(store, &child_iter, 0, detail, -1);
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, detail, -1);
- dl_size += upgrade_pkg->upgrade->size_c;
- already_dl_size += slapt_get_pkg_file_size(global_config, upgrade_pkg->upgrade)/1024;
- free_space += upgrade_pkg->upgrade->size_u;
- free_space -= upgrade_pkg->installed->size_u;
+ dl_size += upgrade_pkg->upgrade->size_c;
+ already_dl_size += slapt_get_pkg_file_size(global_config, upgrade_pkg->upgrade) / 1024;
+ free_space += upgrade_pkg->upgrade->size_u;
+ free_space -= upgrade_pkg->installed->size_u;
- g_free(detail);
+ g_free(detail);
+ }
}
- }
- if ( trans->reinstall_pkgs->size > 0 ) {
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("Packages to be reinstalled"),-1);
- slapt_vector_t_foreach(slapt_pkg_upgrade_t *, reinstall_pkg, trans->reinstall_pkgs) {
- gchar *detail = g_strdup_printf("%s %s", reinstall_pkg->upgrade->name, reinstall_pkg->upgrade->version);
+ if (trans->reinstall_pkgs->size > 0) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("Packages to be reinstalled"), -1);
+ slapt_vector_t_foreach (slapt_pkg_upgrade_t *, reinstall_pkg, trans->reinstall_pkgs) {
+ gchar *detail = g_strdup_printf("%s %s", reinstall_pkg->upgrade->name, reinstall_pkg->upgrade->version);
- gtk_tree_store_append (store, &child_iter, &iter);
- gtk_tree_store_set(store, &child_iter, 0, detail, -1);
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, detail, -1);
- dl_size += reinstall_pkg->upgrade->size_c;
- already_dl_size += slapt_get_pkg_file_size(global_config, reinstall_pkg->upgrade)/1024;
- free_space += reinstall_pkg->upgrade->size_u;
- free_space -= reinstall_pkg->installed->size_u;
+ dl_size += reinstall_pkg->upgrade->size_c;
+ already_dl_size += slapt_get_pkg_file_size(global_config, reinstall_pkg->upgrade) / 1024;
+ free_space += reinstall_pkg->upgrade->size_u;
+ free_space -= reinstall_pkg->installed->size_u;
- g_free(detail);
+ g_free(detail);
+ }
}
- }
- if ( trans->remove_pkgs->size > 0 ) {
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set(store,&iter,0,_("Packages to be removed"),-1);
+ if (trans->remove_pkgs->size > 0) {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, _("Packages to be removed"), -1);
- slapt_vector_t_foreach(slapt_pkg_info_t *, remove_pkg, trans->remove_pkgs) {
- gchar *detail = g_strdup_printf("%s %s", remove_pkg->name, remove_pkg->version);
+ slapt_vector_t_foreach (slapt_pkg_info_t *, remove_pkg, trans->remove_pkgs) {
+ gchar *detail = g_strdup_printf("%s %s", remove_pkg->name, remove_pkg->version);
- gtk_tree_store_append (store, &child_iter, &iter);
- gtk_tree_store_set(store, &child_iter, 0, detail, -1);
- free_space -= remove_pkg->size_u;
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, detail, -1);
+ free_space -= remove_pkg->size_u;
- g_free(detail);
+ g_free(detail);
+ }
}
- }
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(summary_treeview),GTK_TREE_MODEL(store));
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Package"), renderer,
- "text", 0, NULL);
- gtk_tree_view_column_set_sort_column_id (column, 0);
- gtk_tree_view_append_column (GTK_TREE_VIEW(summary_treeview), column);
-
- char fmt[512];
- snprintf(fmt, 512, "%s%s%s%s%s",
- P_("%d upgraded, ", "%d upgraded, ", trans->upgrade_pkgs->size),
- P_("%d reinstalled, ", "%d reinstalled, ", trans->reinstall_pkgs->size),
- P_("%d newly installed, ", "%d newly installed, ", trans->install_pkgs->size),
- P_("%d to remove ", "%d to remove ", trans->remove_pkgs->size),
- P_("and %d not upgraded.", "and %d not upgraded.", trans->exclude_pkgs->size));
- snprintf(buf,512,fmt,
- trans->upgrade_pkgs->size,
- trans->reinstall_pkgs->size,
- trans->install_pkgs->size,
- trans->remove_pkgs->size,
- trans->exclude_pkgs->size
- );
- gtk_label_set_text(GTK_LABEL(sum_pkg_num),buf);
-
- /* if we don't have enough free space to download */
- if (slapt_disk_space_check(global_config->working_dir,dl_size - already_dl_size) == false) {
- notify((gchar *)_("Error"),(gchar *)_("<span weight=\"bold\" size=\"large\">You don't have enough free space</span>"));
- return -1;
- }
- /* if we don't have enough free space to install on / */
- if (slapt_disk_space_check("/",free_space) == false) {
- notify((gchar *)_("Error"),(gchar *)_("<span weight=\"bold\" size=\"large\">You don't have enough free space</span>"));
- return -1;
- }
-
- if ( already_dl_size > 0 ) {
- double need_to_dl = dl_size - already_dl_size;
- snprintf(buf,512,(gchar *)_("Need to get %.0f%s/%.0f%s of archives.\n"),
- (need_to_dl > 1024 ) ? need_to_dl / 1024
- : need_to_dl,
- (need_to_dl > 1024 ) ? "MB" : "kB",
- (dl_size > 1024 ) ? dl_size / 1024 : dl_size,
- (dl_size > 1024 ) ? "MB" : "kB"
- );
- }else{
- snprintf(buf,512,(gchar *)_("Need to get %.0f%s of archives."),
- (dl_size > 1024 ) ? dl_size / 1024 : dl_size,
- (dl_size > 1024 ) ? "MB" : "kB"
- );
- }
- gtk_label_set_text(GTK_LABEL(sum_dl_size),buf);
-
- if ( free_space < 0 ) {
- free_space *= -1;
- snprintf(buf,512,(gchar *)_("After unpacking %.0f%s disk space will be freed."),
- (free_space > 1024 ) ? free_space / 1024
- : free_space,
- (free_space > 1024 ) ? "MB" : "kB"
- );
- }else{
- snprintf(buf,512,(gchar *)_("After unpacking %.0f%s of additional disk space will be used."),
- (free_space > 1024 ) ? free_space / 1024 : free_space,
- (free_space > 1024 ) ? "MB" : "kB"
- );
- }
- gtk_label_set_text(GTK_LABEL(sum_free_space),buf);
-
- return 0;
-}
+ gtk_tree_view_set_model(GTK_TREE_VIEW(summary_treeview), GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Package"), renderer, "text", 0, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, 0);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(summary_treeview), column);
+
+ char fmt[512];
+ snprintf(fmt, 512, "%s%s%s%s%s",
+ P_("%d upgraded, ", "%d upgraded, ", trans->upgrade_pkgs->size),
+ P_("%d reinstalled, ", "%d reinstalled, ", trans->reinstall_pkgs->size),
+ P_("%d newly installed, ", "%d newly installed, ", trans->install_pkgs->size),
+ P_("%d to remove ", "%d to remove ", trans->remove_pkgs->size),
+ P_("and %d not upgraded.", "and %d not upgraded.", trans->exclude_pkgs->size));
+ snprintf(buf, 512, fmt,
+ trans->upgrade_pkgs->size,
+ trans->reinstall_pkgs->size,
+ trans->install_pkgs->size,
+ trans->remove_pkgs->size,
+ trans->exclude_pkgs->size);
+ gtk_label_set_text(GTK_LABEL(sum_pkg_num), buf);
+
+ /* if we don't have enough free space to download */
+ if (slapt_disk_space_check(global_config->working_dir, dl_size - already_dl_size) == false) {
+ notify((gchar *)_("Error"), (gchar *)_("<span weight=\"bold\" size=\"large\">You don't have enough free space</span>"));
+ return -1;
+ }
+ /* if we don't have enough free space to install on / */
+ if (slapt_disk_space_check("/", free_space) == false) {
+ notify((gchar *)_("Error"), (gchar *)_("<span weight=\"bold\" size=\"large\">You don't have enough free space</span>"));
+ return -1;
+ }
+
+ if (already_dl_size > 0) {
+ double need_to_dl = dl_size - already_dl_size;
+ snprintf(buf, 512, (gchar *)_("Need to get %.0f%s/%.0f%s of archives.\n"),
+ (need_to_dl > 1024) ? need_to_dl / 1024
+ : need_to_dl,
+ (need_to_dl > 1024) ? "MB" : "kB",
+ (dl_size > 1024) ? dl_size / 1024 : dl_size,
+ (dl_size > 1024) ? "MB" : "kB");
+ } else {
+ snprintf(buf, 512, (gchar *)_("Need to get %.0f%s of archives."),
+ (dl_size > 1024) ? dl_size / 1024 : dl_size,
+ (dl_size > 1024) ? "MB" : "kB");
+ }
+ gtk_label_set_text(GTK_LABEL(sum_dl_size), buf);
+
+ if (free_space < 0) {
+ free_space *= -1;
+ snprintf(buf, 512, (gchar *)_("After unpacking %.0f%s disk space will be freed."),
+ (free_space > 1024) ? free_space / 1024
+ : free_space,
+ (free_space > 1024) ? "MB" : "kB");
+ } else {
+ snprintf(buf, 512, (gchar *)_("After unpacking %.0f%s of additional disk space will be used."),
+ (free_space > 1024) ? free_space / 1024 : free_space,
+ (free_space > 1024) ? "MB" : "kB");
+ }
+ gtk_label_set_text(GTK_LABEL(sum_free_space), buf);
+
+ return 0;
+}
-static void mark_upgrade_packages (void)
+static void mark_upgrade_packages(void)
{
- GtkTreeIter iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- guint mark_count = 0;
- GtkTreeModelSort *package_model;
- GtkTreeView *treeview;
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
-
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- slapt_vector_t_foreach(slapt_pkg_info_t *, installed_pkg, installed) {
- slapt_pkg_info_t *update_pkg = NULL;
- slapt_pkg_info_t *newer_installed_pkg = NULL;
-
- /*
- we need to see if there is another installed
- package that is newer than this one
- */
- if ( (newer_installed_pkg = slapt_get_newest_pkg(installed, installed_pkg->name)) != NULL ) {
+ GtkTreeIter iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ guint mark_count = 0;
+ GtkTreeModelSort *package_model;
+ GtkTreeView *treeview;
- if ( slapt_cmp_pkgs(installed_pkg, newer_installed_pkg) < 0 )
- continue;
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- }
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
- /* see if we have an available update for the pkg */
- update_pkg = slapt_get_newest_pkg(all, installed_pkg->name);
- if ( update_pkg != NULL ) {
- int cmp_r = 0;
-
- /* if the update has a newer version, attempt to upgrade */
- cmp_r = slapt_cmp_pkgs(installed_pkg, update_pkg);
- /* either it's greater, or we want to reinstall */
- if ( cmp_r < 0 || (global_config->re_install == TRUE) ) {
-
- if ((slapt_is_excluded(global_config,update_pkg) == 1)
- || (slapt_is_excluded(global_config, installed_pkg) == 1)
- ) {
- slapt_add_exclude_to_transaction(trans,update_pkg);
- }else{
- slapt_vector_t *conflicts = slapt_is_conflicted(trans,all,installed,update_pkg);
-
- /* if all deps are added and there is no conflicts, add on */
- if (
- (ladd_deps_to_trans(trans,all,installed,update_pkg) == 0)
- && (conflicts->size == 0)
- ) {
-
- if (global_config->re_install == TRUE)
- slapt_add_reinstall_to_transaction(trans, installed_pkg, update_pkg);
- else
- slapt_add_upgrade_to_transaction(trans, installed_pkg, update_pkg);
+ slapt_vector_t_foreach (slapt_pkg_info_t *, installed_pkg, installed) {
+ slapt_pkg_info_t *update_pkg = NULL;
+ slapt_pkg_info_t *newer_installed_pkg = NULL;
- if (set_iter_to_pkg(base_model,&iter,update_pkg)) {
- set_iter_for_upgrade(base_model, &iter, update_pkg);
- }
- ++mark_count;
- }else{
- /* otherwise exclude */
- slapt_add_exclude_to_transaction(trans,update_pkg);
- }
- slapt_vector_t_free(conflicts);
+ /* we need to see if there is another installed package that is newer than this one */
+ if ((newer_installed_pkg = slapt_get_newest_pkg(installed, installed_pkg->name)) != NULL) {
+ if (slapt_cmp_pkgs(installed_pkg, newer_installed_pkg) < 0)
+ continue;
}
- }
+ /* see if we have an available update for the pkg */
+ update_pkg = slapt_get_newest_pkg(all, installed_pkg->name);
+ if (update_pkg != NULL) {
+ int cmp_r = 0;
+
+ /* if the update has a newer version, attempt to upgrade */
+ cmp_r = slapt_cmp_pkgs(installed_pkg, update_pkg);
+ /* either it's greater, or we want to reinstall */
+ if (cmp_r < 0 || (global_config->re_install == TRUE)) {
+ if ((slapt_is_excluded(global_config, update_pkg) == 1) || (slapt_is_excluded(global_config, installed_pkg) == 1)) {
+ slapt_add_exclude_to_transaction(trans, update_pkg);
+ } else {
+ slapt_vector_t *conflicts = slapt_is_conflicted(trans, all, installed, update_pkg);
+
+ /* if all deps are added and there is no conflicts, add on */
+ if ((ladd_deps_to_trans(trans, all, installed, update_pkg) == 0) && (conflicts->size == 0)) {
+ if (global_config->re_install == TRUE)
+ slapt_add_reinstall_to_transaction(trans, installed_pkg, update_pkg);
+ else
+ slapt_add_upgrade_to_transaction(trans, installed_pkg, update_pkg);
+
+ if (set_iter_to_pkg(base_model, &iter, update_pkg)) {
+ set_iter_for_upgrade(base_model, &iter, update_pkg);
+ }
+ ++mark_count;
+ } else {
+ /* otherwise exclude */
+ slapt_add_exclude_to_transaction(trans, update_pkg);
+ }
+ slapt_vector_t_free(conflicts);
+ }
+ }
- }/* end upgrade pkg found */
+ } /* end upgrade pkg found */
- }/* end for */
+ } /* end for */
- if (mark_count == 0) {
- notify((gchar *)_("Up to Date"),
- (gchar *)_("<span weight=\"bold\" size=\"large\">No updates available</span>"));
- }
+ if (mark_count == 0) {
+ notify((gchar *)_("Up to Date"), (gchar *)_("<span weight=\"bold\" size=\"large\">No updates available</span>"));
+ }
}
-char *download_packages (void)
+char *download_packages(void)
{
- GtkLabel *progress_action_label,*progress_message_label,*progress_pkg_desc;
- GtkProgressBar *p_bar;
- guint context_id;
- gfloat pkgs_to_dl = 0.0,count = 0.0;
- const char *err = NULL;
-
- pkgs_to_dl += trans->install_pkgs->size;
- pkgs_to_dl += trans->upgrade_pkgs->size;
- pkgs_to_dl += trans->reinstall_pkgs->size;
+ GtkLabel *progress_action_label, *progress_message_label, *progress_pkg_desc;
+ GtkProgressBar *p_bar;
+ guint context_id;
+ gfloat pkgs_to_dl = 0.0, count = 0.0;
+ const char *err = NULL;
- if (progress_window_builder == NULL)
- progress_window_builder = gtk_builder_new ();
+ pkgs_to_dl += trans->install_pkgs->size;
+ pkgs_to_dl += trans->upgrade_pkgs->size;
+ pkgs_to_dl += trans->reinstall_pkgs->size;
- gslapt_load_ui (progress_window_builder, "dl_progress_window.ui");
- progress_window = GTK_WIDGET (gtk_builder_get_object (progress_window_builder, "dl_progress_window"));
- gtk_builder_connect_signals (progress_window_builder, NULL);
- gtk_window_set_transient_for (GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
+ if (progress_window_builder == NULL)
+ progress_window_builder = gtk_builder_new();
- gtk_window_set_title(GTK_WINDOW(progress_window),(gchar *)_("Progress"));
+ gslapt_load_ui(progress_window_builder, "dl_progress_window.ui");
+ progress_window = GTK_WIDGET(gtk_builder_get_object(progress_window_builder, "dl_progress_window"));
+ gtk_builder_connect_signals(progress_window_builder, NULL);
+ gtk_window_set_transient_for(GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
- p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress_progressbar"));
- progress_action_label = GTK_LABEL(gtk_builder_get_object (progress_window_builder,"dl_progress_action"));
- progress_message_label = GTK_LABEL(gtk_builder_get_object (progress_window_builder,"dl_progress_message"));
- progress_pkg_desc = GTK_LABEL(gtk_builder_get_object (progress_window_builder,"dl_progress_package_description"));
+ gtk_window_set_title(GTK_WINDOW(progress_window), (gchar *)_("Progress"));
- gdk_threads_enter();
- gtk_widget_show_all(progress_window);
- context_id = gslapt_set_status((gchar *)_("Downloading packages..."));
- gdk_threads_leave();
+ p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress_progressbar"));
+ progress_action_label = GTK_LABEL(gtk_builder_get_object(progress_window_builder, "dl_progress_action"));
+ progress_message_label = GTK_LABEL(gtk_builder_get_object(progress_window_builder, "dl_progress_message"));
+ progress_pkg_desc = GTK_LABEL(gtk_builder_get_object(progress_window_builder, "dl_progress_package_description"));
- if (_cancelled == 1) {
gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
- return NULL;
- }
-
- slapt_vector_t_foreach(slapt_pkg_info_t *, install_pkg, trans->install_pkgs) {
-
- guint msg_len = strlen(install_pkg->name)
- + strlen("-") + strlen(install_pkg->version)
- + strlen(".") + strlen(install_pkg->file_ext);
- gchar *msg = slapt_malloc(msg_len * sizeof *msg);
- gchar dl_size[20];
-
- snprintf(msg,
- strlen(install_pkg->name)
- + strlen("-")
- + strlen(install_pkg->version)
- + strlen(".") + strlen(install_pkg->file_ext),
- "%s-%s%s",
- install_pkg->name,
- install_pkg->version,
- install_pkg->file_ext
- );
- sprintf(dl_size,"%d K",install_pkg->size_c);
-
- gdk_threads_enter();
- gtk_label_set_text(progress_pkg_desc,install_pkg->mirror);
- gtk_label_set_text(progress_action_label,(gchar *)_("Downloading..."));
- gtk_label_set_text(progress_message_label,msg);
- gtk_progress_bar_set_fraction(p_bar,((count * 100)/pkgs_to_dl)/100);
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress")),0.0);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress")),dl_size);
+ gtk_widget_show_all(progress_window);
+ context_id = gslapt_set_status((gchar *)_("Downloading packages..."));
gdk_threads_leave();
- free(msg);
-
if (_cancelled == 1) {
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
- return NULL;
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
+ return NULL;
}
- err = slapt_download_pkg(global_config, install_pkg, NULL);
- if (err) {
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
- return g_strdup_printf(_("Failed to download %s: %s"),
- install_pkg->name, err);
- }
- ++count;
- }
-
- slapt_vector_t_foreach(slapt_pkg_upgrade_t *, upgrade_pkg, trans->upgrade_pkgs) {
-
- guint msg_len = strlen(upgrade_pkg->upgrade->name)
- + strlen("-") + strlen(upgrade_pkg->upgrade->version)
- + strlen(".") + strlen(upgrade_pkg->upgrade->file_ext);
- gchar *msg = slapt_malloc( sizeof *msg * msg_len);
- gchar dl_size[20];
-
- snprintf(msg,
- strlen(upgrade_pkg->upgrade->name)
- + strlen("-")
- + strlen(upgrade_pkg->upgrade->version)
- + strlen(".") + strlen(upgrade_pkg->upgrade->file_ext),
- "%s-%s%s",
- upgrade_pkg->upgrade->name,
- upgrade_pkg->upgrade->version,
- upgrade_pkg->upgrade->file_ext
- );
- sprintf(dl_size,"%d K",upgrade_pkg->upgrade->size_c);
+ slapt_vector_t_foreach (slapt_pkg_info_t *, install_pkg, trans->install_pkgs) {
+ guint msg_len = strlen(install_pkg->name) + strlen("-") + strlen(install_pkg->version) + strlen(".") + strlen(install_pkg->file_ext);
+ gchar *msg = slapt_malloc(msg_len * sizeof *msg);
+ gchar dl_size[20];
- gdk_threads_enter();
- gtk_label_set_text(progress_pkg_desc,upgrade_pkg->upgrade->mirror);
- gtk_label_set_text(progress_action_label,(gchar *)_("Downloading..."));
- gtk_label_set_text(progress_message_label,msg);
- gtk_progress_bar_set_fraction(p_bar,((count * 100)/pkgs_to_dl)/100);
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress")),0.0);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress")),dl_size);
- gdk_threads_leave();
+ snprintf(msg,
+ strlen(install_pkg->name) + strlen("-") + strlen(install_pkg->version) + strlen(".") + strlen(install_pkg->file_ext),
+ "%s-%s%s",
+ install_pkg->name,
+ install_pkg->version,
+ install_pkg->file_ext);
+ sprintf(dl_size, "%d K", install_pkg->size_c);
+
+ gdk_threads_enter();
+ gtk_label_set_text(progress_pkg_desc, install_pkg->mirror);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Downloading..."));
+ gtk_label_set_text(progress_message_label, msg);
+ gtk_progress_bar_set_fraction(p_bar, ((count * 100) / pkgs_to_dl) / 100);
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress")), 0.0);
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress")), dl_size);
+ gdk_threads_leave();
- free(msg);
+ free(msg);
- if (_cancelled == 1) {
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
- return NULL;
- }
+ if (_cancelled == 1) {
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
+ return NULL;
+ }
- err = slapt_download_pkg(global_config,upgrade_pkg->upgrade, NULL);
- if (err) {
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
- return g_strdup_printf(_("Failed to download %s: %s"),
- upgrade_pkg->upgrade->name, err);
+ err = slapt_download_pkg(global_config, install_pkg, NULL);
+ if (err) {
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
+ return g_strdup_printf(_("Failed to download %s: %s"), install_pkg->name, err);
+ }
+ ++count;
}
- ++count;
- }
-
- slapt_vector_t_foreach(slapt_pkg_upgrade_t *, reinstall_pkg, trans->reinstall_pkgs) {
-
- guint msg_len = strlen(reinstall_pkg->upgrade->name)
- + strlen("-") + strlen(reinstall_pkg->upgrade->version)
- + strlen(".") + strlen(reinstall_pkg->upgrade->file_ext);
- gchar *msg = slapt_malloc( sizeof *msg * msg_len);
- gchar dl_size[20];
-
- snprintf(msg,
- strlen(reinstall_pkg->upgrade->name)
- + strlen("-")
- + strlen(reinstall_pkg->upgrade->version)
- + strlen(".") + strlen(reinstall_pkg->upgrade->file_ext),
- "%s-%s%s",
- reinstall_pkg->upgrade->name,
- reinstall_pkg->upgrade->version,
- reinstall_pkg->upgrade->file_ext
- );
- sprintf(dl_size,"%d K",reinstall_pkg->upgrade->size_c);
- gdk_threads_enter();
- gtk_label_set_text(progress_pkg_desc,reinstall_pkg->upgrade->mirror);
- gtk_label_set_text(progress_action_label,(gchar *)_("Downloading..."));
- gtk_label_set_text(progress_message_label,msg);
- gtk_progress_bar_set_fraction(p_bar,((count * 100)/pkgs_to_dl)/100);
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress")),0.0);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gtk_builder_get_object (progress_window_builder,"dl_progress")),dl_size);
- gdk_threads_leave();
+ slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade_pkg, trans->upgrade_pkgs) {
+ guint msg_len = strlen(upgrade_pkg->upgrade->name) + strlen("-") + strlen(upgrade_pkg->upgrade->version) + strlen(".") + strlen(upgrade_pkg->upgrade->file_ext);
+ gchar *msg = slapt_malloc(sizeof *msg * msg_len);
+ gchar dl_size[20];
- free(msg);
+ snprintf(msg,
+ strlen(upgrade_pkg->upgrade->name) + strlen("-") + strlen(upgrade_pkg->upgrade->version) + strlen(".") + strlen(upgrade_pkg->upgrade->file_ext),
+ "%s-%s%s",
+ upgrade_pkg->upgrade->name,
+ upgrade_pkg->upgrade->version,
+ upgrade_pkg->upgrade->file_ext);
+ sprintf(dl_size, "%d K", upgrade_pkg->upgrade->size_c);
- if (_cancelled == 1) {
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
- return NULL;
- }
+ gdk_threads_enter();
+ gtk_label_set_text(progress_pkg_desc, upgrade_pkg->upgrade->mirror);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Downloading..."));
+ gtk_label_set_text(progress_message_label, msg);
+ gtk_progress_bar_set_fraction(p_bar, ((count * 100) / pkgs_to_dl) / 100);
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress")), 0.0);
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress")), dl_size);
+ gdk_threads_leave();
- err = slapt_download_pkg(global_config,reinstall_pkg->upgrade, NULL);
- if (err) {
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
- return g_strdup_printf(_("Failed to download %s: %s"),
- reinstall_pkg->upgrade->name, err);
- }
- ++count;
- }
+ free(msg);
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gslapt_clear_status(context_id);
- gdk_threads_leave();
+ if (_cancelled == 1) {
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
+ return NULL;
+ }
- g_object_unref (G_OBJECT (progress_window_builder));
- progress_window_builder = NULL;
+ err = slapt_download_pkg(global_config, upgrade_pkg->upgrade, NULL);
+ if (err) {
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
+ return g_strdup_printf(_("Failed to download %s: %s"),
+ upgrade_pkg->upgrade->name, err);
+ }
+ ++count;
+ }
- return NULL;
-}
+ slapt_vector_t_foreach (slapt_pkg_upgrade_t *, reinstall_pkg, trans->reinstall_pkgs) {
+ guint msg_len = strlen(reinstall_pkg->upgrade->name) + strlen("-") + strlen(reinstall_pkg->upgrade->version) + strlen(".") + strlen(reinstall_pkg->upgrade->file_ext);
+ gchar *msg = slapt_malloc(sizeof *msg * msg_len);
+ gchar dl_size[20];
-static gboolean install_packages (void)
-{
- GtkBuilder *builder = gtk_builder_new ();
- GtkLabel *progress_action_label,*progress_message_label,*progress_pkg_desc;
- GtkProgressBar *p_bar;
- guint context_id;
- gfloat count = 0.0;
+ snprintf(msg,
+ strlen(reinstall_pkg->upgrade->name) + strlen("-") + strlen(reinstall_pkg->upgrade->version) + strlen(".") + strlen(reinstall_pkg->upgrade->file_ext),
+ "%s-%s%s",
+ reinstall_pkg->upgrade->name,
+ reinstall_pkg->upgrade->version,
+ reinstall_pkg->upgrade->file_ext);
+ sprintf(dl_size, "%d K", reinstall_pkg->upgrade->size_c);
- /* begin removing, installing, and upgrading */
+ gdk_threads_enter();
+ gtk_label_set_text(progress_pkg_desc, reinstall_pkg->upgrade->mirror);
+ gtk_label_set_text(progress_action_label, (gchar *)_("Downloading..."));
+ gtk_label_set_text(progress_message_label, msg);
+ gtk_progress_bar_set_fraction(p_bar, ((count * 100) / pkgs_to_dl) / 100);
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress")), 0.0);
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gtk_builder_get_object(progress_window_builder, "dl_progress")), dl_size);
+ gdk_threads_leave();
- gslapt_load_ui (builder, "pkgtools_progress_window.ui");
- progress_window = GTK_WIDGET (gtk_builder_get_object (builder, "pkgtools_progress_window"));
- gtk_builder_connect_signals (builder, NULL);
- gtk_window_set_transient_for (GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
+ free(msg);
- gtk_window_set_title(GTK_WINDOW(progress_window),(gchar *)_("Progress"));
+ if (_cancelled == 1) {
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
+ return NULL;
+ }
- p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object (builder,"progress_progressbar"));
- progress_action_label = GTK_LABEL(gtk_builder_get_object (builder,"progress_action"));
- progress_message_label = GTK_LABEL(gtk_builder_get_object (builder,"progress_message"));
- progress_pkg_desc = GTK_LABEL(gtk_builder_get_object (builder,"progress_package_description"));
+ err = slapt_download_pkg(global_config, reinstall_pkg->upgrade, NULL);
+ if (err) {
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
+ return g_strdup_printf(_("Failed to download %s: %s"), reinstall_pkg->upgrade->name, err);
+ }
+ ++count;
+ }
- gdk_threads_enter();
- gtk_widget_show_all(progress_window);
- gdk_threads_leave();
+ gdk_threads_enter();
+ gtk_widget_destroy(progress_window);
+ gslapt_clear_status(context_id);
+ gdk_threads_leave();
- g_object_unref (G_OBJECT (builder));
+ g_object_unref(G_OBJECT(progress_window_builder));
+ progress_window_builder = NULL;
+ return NULL;
+}
- slapt_vector_t_foreach(slapt_pkg_info_t *, remove_pkg, trans->remove_pkgs) {
- char *clean_desc = strdup(remove_pkg->description);
- slapt_clean_description(clean_desc,remove_pkg->name);
+static gboolean install_packages(void)
+{
+ GtkBuilder *builder = gtk_builder_new();
+ GtkLabel *progress_action_label, *progress_message_label, *progress_pkg_desc;
+ GtkProgressBar *p_bar;
+ guint context_id;
+ gfloat count = 0.0;
- gdk_threads_enter();
+ /* begin removing, installing, and upgrading */
- context_id = gslapt_set_status((gchar *)_("Removing packages..."));
- gtk_label_set_text(progress_pkg_desc,clean_desc);
+ gslapt_load_ui(builder, "pkgtools_progress_window.ui");
+ progress_window = GTK_WIDGET(gtk_builder_get_object(builder, "pkgtools_progress_window"));
+ gtk_builder_connect_signals(builder, NULL);
+ gtk_window_set_transient_for(GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
- if ( clean_desc != NULL)
- free(clean_desc);
+ gtk_window_set_title(GTK_WINDOW(progress_window), (gchar *)_("Progress"));
- gtk_label_set_text(progress_action_label,(gchar *)_("Uninstalling..."));
- gtk_label_set_text(progress_message_label,remove_pkg->name);
- gtk_progress_bar_set_fraction(p_bar,((count * 100)/trans->remove_pkgs->size)/100);
- gdk_threads_leave();
+ p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progress_progressbar"));
+ progress_action_label = GTK_LABEL(gtk_builder_get_object(builder, "progress_action"));
+ progress_message_label = GTK_LABEL(gtk_builder_get_object(builder, "progress_message"));
+ progress_pkg_desc = GTK_LABEL(gtk_builder_get_object(builder, "progress_package_description"));
- if (slapt_remove_pkg(global_config,remove_pkg) == -1) {
- gdk_threads_enter();
- gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
- gdk_threads_leave();
- return FALSE;
- }
gdk_threads_enter();
- gslapt_clear_status(context_id);
+ gtk_widget_show_all(progress_window);
gdk_threads_leave();
- ++count;
- }
- /* reset progress bar */
- gdk_threads_enter();
- gtk_progress_bar_set_fraction(p_bar,0.0);
- gdk_threads_leave();
+ g_object_unref(G_OBJECT(builder));
- /* now for the installs and upgrades */
- count = 0.0;
- slapt_vector_t_foreach(slapt_queue_i *, qi, trans->queue) {
- gdk_threads_enter();
- context_id = gslapt_set_status((gchar *)_("Installing packages..."));
- gdk_threads_leave();
+ slapt_vector_t_foreach (slapt_pkg_info_t *, remove_pkg, trans->remove_pkgs) {
+ char *clean_desc = strdup(remove_pkg->description);
+ slapt_clean_description(clean_desc, remove_pkg->name);
- if ( qi->type == INSTALL ) {
- char *clean_desc = strdup(qi->pkg.i->description);
- slapt_clean_description(clean_desc,qi->pkg.i->name);
+ gdk_threads_enter();
- gdk_threads_enter();
+ context_id = gslapt_set_status((gchar *)_("Removing packages..."));
+ gtk_label_set_text(progress_pkg_desc, clean_desc);
- gtk_label_set_text(progress_pkg_desc,clean_desc);
- if ( clean_desc != NULL )
- free(clean_desc);
+ if (clean_desc != NULL)
+ free(clean_desc);
- gtk_label_set_text(progress_action_label,(gchar *)_("Installing..."));
- gtk_label_set_text(progress_message_label,qi->pkg.i->name);
- gtk_progress_bar_set_fraction(p_bar,((count * 100)/trans->queue->size)/100);
- gdk_threads_leave();
+ gtk_label_set_text(progress_action_label, (gchar *)_("Uninstalling..."));
+ gtk_label_set_text(progress_message_label, remove_pkg->name);
+ gtk_progress_bar_set_fraction(p_bar, ((count * 100) / trans->remove_pkgs->size) / 100);
+ gdk_threads_leave();
- if (slapt_install_pkg(global_config,qi->pkg.i) == -1) {
+ if (slapt_remove_pkg(global_config, remove_pkg) == -1) {
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ gdk_threads_leave();
+ return FALSE;
+ }
gdk_threads_enter();
gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
gdk_threads_leave();
- return FALSE;
- }
- }else if ( qi->type == UPGRADE ) {
- char *clean_desc = strdup(qi->pkg.u->upgrade->description);
- slapt_clean_description(clean_desc,qi->pkg.u->upgrade->name);
+ ++count;
+ }
+
+ /* reset progress bar */
+ gdk_threads_enter();
+ gtk_progress_bar_set_fraction(p_bar, 0.0);
+ gdk_threads_leave();
- gdk_threads_enter();
+ /* now for the installs and upgrades */
+ count = 0.0;
+ slapt_vector_t_foreach (slapt_queue_i *, qi, trans->queue) {
+ gdk_threads_enter();
+ context_id = gslapt_set_status((gchar *)_("Installing packages..."));
+ gdk_threads_leave();
- gtk_label_set_text(progress_pkg_desc,clean_desc);
- if ( clean_desc != NULL )
- free(clean_desc);
+ if (qi->type == INSTALL) {
+ char *clean_desc = strdup(qi->pkg.i->description);
+ slapt_clean_description(clean_desc, qi->pkg.i->name);
- gtk_label_set_text(progress_action_label,(gchar *)_("Upgrading..."));
- gtk_label_set_text(progress_message_label,qi->pkg.u->upgrade->name);
- gtk_progress_bar_set_fraction(p_bar,((count * 100)/trans->queue->size)/100);
- gdk_threads_leave();
+ gdk_threads_enter();
- if (slapt_upgrade_pkg(global_config,
- qi->pkg.u->upgrade) == -1) {
+ gtk_label_set_text(progress_pkg_desc, clean_desc);
+ if (clean_desc != NULL)
+ free(clean_desc);
+
+ gtk_label_set_text(progress_action_label, (gchar *)_("Installing..."));
+ gtk_label_set_text(progress_message_label, qi->pkg.i->name);
+ gtk_progress_bar_set_fraction(p_bar, ((count * 100) / trans->queue->size) / 100);
+ gdk_threads_leave();
+
+ if (slapt_install_pkg(global_config, qi->pkg.i) == -1) {
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ gdk_threads_leave();
+ return FALSE;
+ }
+ } else if (qi->type == UPGRADE) {
+ char *clean_desc = strdup(qi->pkg.u->upgrade->description);
+ slapt_clean_description(clean_desc, qi->pkg.u->upgrade->name);
+
+ gdk_threads_enter();
+
+ gtk_label_set_text(progress_pkg_desc, clean_desc);
+ if (clean_desc != NULL)
+ free(clean_desc);
+
+ gtk_label_set_text(progress_action_label, (gchar *)_("Upgrading..."));
+ gtk_label_set_text(progress_message_label, qi->pkg.u->upgrade->name);
+ gtk_progress_bar_set_fraction(p_bar, ((count * 100) / trans->queue->size) / 100);
+ gdk_threads_leave();
+
+ if (slapt_upgrade_pkg(global_config, qi->pkg.u->upgrade) == -1) {
+ gdk_threads_enter();
+ gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
+ gdk_threads_leave();
+ return FALSE;
+ }
+ }
gdk_threads_enter();
gslapt_clear_status(context_id);
- gtk_widget_destroy(progress_window);
gdk_threads_leave();
- return FALSE;
- }
+ ++count;
}
+
gdk_threads_enter();
- gslapt_clear_status(context_id);
+ gtk_widget_destroy(progress_window);
gdk_threads_leave();
- ++count;
- }
-
- gdk_threads_enter();
- gtk_widget_destroy(progress_window);
- gdk_threads_leave();
- return TRUE;
+ return TRUE;
}
-
-void clean_callback (GtkWidget *widget, gpointer *user_data)
+void clean_callback(GtkWidget *widget, gpointer *user_data)
{
- GThread *gpd;
+ GThread *gpd;
-#if !GLIB_CHECK_VERSION (2, 31, 0)
- gpd = g_thread_create((GThreadFunc)slapt_clean_pkg_dir,global_config->working_dir,FALSE,NULL);
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+ gpd = g_thread_create((GThreadFunc)slapt_clean_pkg_dir, global_config->working_dir, FALSE, NULL);
#else
- gpd = g_thread_new("GslaptCleanCallback", (GThreadFunc)slapt_clean_pkg_dir,global_config->working_dir);
+ gpd = g_thread_new("GslaptCleanCallback", (GThreadFunc)slapt_clean_pkg_dir, global_config->working_dir);
#endif
-
}
-
-void preferences_sources_add (GtkWidget *w, gpointer *user_data)
+void preferences_sources_add(GtkWidget *w, gpointer *user_data)
{
- GtkBuilder *builder;
- GtkWidget *source_window;
+ GtkBuilder *builder;
+ GtkWidget *source_window;
- builder = gtk_builder_new ();
- gslapt_load_ui (builder, "source_window.ui");
- source_window = GTK_WIDGET (gtk_builder_get_object (builder, "source_window"));
- gtk_builder_connect_signals (builder, builder);
+ builder = gtk_builder_new();
+ gslapt_load_ui(builder, "source_window.ui");
+ source_window = GTK_WIDGET(gtk_builder_get_object(builder, "source_window"));
+ gtk_builder_connect_signals(builder, builder);
- gtk_widget_show_all(source_window);
+ gtk_widget_show_all(source_window);
}
-void preferences_sources_remove (GtkWidget *w, gpointer *user_data)
+void preferences_sources_remove(GtkWidget *w, gpointer *user_data)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data),"preferences_sources_treeview"));
- GtkTreeSelection *select = gtk_tree_view_get_selection (GTK_TREE_VIEW (source_tree));
- GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(source_tree));
-
- if ( gtk_tree_selection_get_selected(select,&model,&iter)) {
- gtk_list_store_remove(store, &iter);
- sources_modified = TRUE;
- }
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data), "preferences_sources_treeview"));
+ GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(source_tree));
+ GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(source_tree));
+ if (gtk_tree_selection_get_selected(select, &model, &iter)) {
+ gtk_list_store_remove(store, &iter);
+ sources_modified = TRUE;
+ }
}
-void preferences_sources_edit (GtkWidget *w, gpointer *user_data)
+void preferences_sources_edit(GtkWidget *w, gpointer *user_data)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data),"preferences_sources_treeview"));
- GtkTreeSelection *select = gtk_tree_view_get_selection (GTK_TREE_VIEW (source_tree));
-
- if ( gtk_tree_selection_get_selected(select,&model,&iter)) {
- guint priority;
- gchar *source;
-
- gtk_tree_model_get(model,&iter,1,&source,4,&priority,-1);
-
- if (source) {
- GtkBuilder *builder = gtk_builder_new ();
- GtkWidget *source_window;
- GtkEntry *source_entry;
- GtkComboBox *source_priority;
-
- gslapt_load_ui (builder, "source_window.ui");
- source_window = GTK_WIDGET (gtk_builder_get_object (builder, "source_window"));
- gtk_builder_connect_signals (builder, builder);
-
- source_entry = GTK_ENTRY(gtk_builder_get_object (builder,"source_entry"));
- source_priority = GTK_COMBO_BOX(gtk_builder_get_object (builder,"source_priority"));
-
- g_object_set_data ( G_OBJECT(source_window), "original_url", source);
- gtk_entry_set_text(source_entry,source);
- gtk_combo_box_set_active (source_priority,convert_slapt_priority_to_gslapt_priority(priority));
- gtk_widget_show_all(source_window);
- }
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data), "preferences_sources_treeview"));
+ GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(source_tree));
- }
+ if (gtk_tree_selection_get_selected(select, &model, &iter)) {
+ guint priority;
+ gchar *source;
+ gtk_tree_model_get(model, &iter, 1, &source, 4, &priority, -1);
+
+ if (source) {
+ GtkBuilder *builder = gtk_builder_new();
+ GtkWidget *source_window;
+ GtkEntry *source_entry;
+ GtkComboBox *source_priority;
+
+ gslapt_load_ui(builder, "source_window.ui");
+ source_window = GTK_WIDGET(gtk_builder_get_object(builder, "source_window"));
+ gtk_builder_connect_signals(builder, builder);
+
+ source_entry = GTK_ENTRY(gtk_builder_get_object(builder, "source_entry"));
+ source_priority = GTK_COMBO_BOX(gtk_builder_get_object(builder, "source_priority"));
+
+ g_object_set_data(G_OBJECT(source_window), "original_url", source);
+ gtk_entry_set_text(source_entry, source);
+ gtk_combo_box_set_active(source_priority, convert_slapt_priority_to_gslapt_priority(priority));
+ gtk_widget_show_all(source_window);
+ }
+ }
}
-void preferences_on_ok_clicked (GtkWidget *w, gpointer *user_data)
+void preferences_on_ok_clicked(GtkWidget *w, gpointer *user_data)
{
- GtkEntry *preferences_working_dir_entry = GTK_ENTRY(gtk_builder_get_object(GTK_BUILDER(user_data),"preferences_working_dir_entry"));
- const gchar *working_dir = gtk_entry_get_text(preferences_working_dir_entry);
- GtkTreeModel *model;
- GtkTreeView *tree;
- GtkTreeIter iter;
- gboolean valid;
-
- strcpy(global_config->working_dir, working_dir);
- slapt_working_dir_init(global_config);
- chdir(global_config->working_dir);
-
- slapt_vector_t_free(global_config->exclude_list);
- slapt_vector_t_free(global_config->sources);
-
- global_config->exclude_list = slapt_vector_t_init(free);
- global_config->sources = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_source);
-
- tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data),"preferences_sources_treeview"));
- model = gtk_tree_view_get_model(tree);
- valid = gtk_tree_model_get_iter_first(model,&iter);
- while (valid)
- {
- gchar *source = NULL;
- gboolean status;
- SLAPT_PRIORITY_T priority;
- gtk_tree_model_get(model, &iter, 1, &source, 2, &status, 4, &priority, -1);
-
- if (source != NULL) {
- slapt_source_t *src = slapt_init_source(source);
- if (src != NULL) {
-
- if (status)
- src->disabled = false;
- else
- src->disabled = true;
-
- src->priority = priority;
-
- slapt_vector_t_add(global_config->sources,src);
- }
- g_free(source);
+ GtkEntry *preferences_working_dir_entry = GTK_ENTRY(gtk_builder_get_object(GTK_BUILDER(user_data), "preferences_working_dir_entry"));
+ const gchar *working_dir = gtk_entry_get_text(preferences_working_dir_entry);
+ GtkTreeModel *model;
+ GtkTreeView *tree;
+ GtkTreeIter iter;
+ gboolean valid;
+
+ strcpy(global_config->working_dir, working_dir);
+ slapt_working_dir_init(global_config);
+ chdir(global_config->working_dir);
+
+ slapt_vector_t_free(global_config->exclude_list);
+ slapt_vector_t_free(global_config->sources);
+
+ global_config->exclude_list = slapt_vector_t_init(free);
+ global_config->sources = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_source);
+
+ tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data), "preferences_sources_treeview"));
+ model = gtk_tree_view_get_model(tree);
+ valid = gtk_tree_model_get_iter_first(model, &iter);
+ while (valid) {
+ gchar *source = NULL;
+ gboolean status;
+ SLAPT_PRIORITY_T priority;
+ gtk_tree_model_get(model, &iter, 1, &source, 2, &status, 4, &priority, -1);
+
+ if (source != NULL) {
+ slapt_source_t *src = slapt_init_source(source);
+ if (src != NULL) {
+ if (status)
+ src->disabled = false;
+ else
+ src->disabled = true;
+
+ src->priority = priority;
+
+ slapt_vector_t_add(global_config->sources, src);
+ }
+ g_free(source);
+ }
+
+ valid = gtk_tree_model_iter_next(model, &iter);
}
- valid = gtk_tree_model_iter_next(model, &iter);
- }
-
- tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data),"preferences_exclude_treeview"));
- model = gtk_tree_view_get_model(tree);
- valid = gtk_tree_model_get_iter_first(model,&iter);
- while (valid)
- {
- gchar *exclude = NULL;
- gtk_tree_model_get(model, &iter, 0, &exclude, -1);
-
- slapt_vector_t_add(global_config->exclude_list, strdup(exclude));
- g_free(exclude);
-
- valid = gtk_tree_model_iter_next(model, &iter);
- }
-
- if ( slapt_write_rc_config(global_config, rc_location) != 0) {
- notify((gchar *)_("Error"),(gchar *)_("Failed to commit preferences"));
- on_gslapt_destroy(NULL,NULL);
- }
-
- preferences_window = NULL;
- gtk_widget_destroy(GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER(user_data), "window_preferences")));
- g_object_unref(G_OBJECT(user_data));
- preferences_window_builder = NULL;
-
- /* dialog to resync package sources */
- if (sources_modified == TRUE) {
- GtkBuilder *builder = gtk_builder_new ();
- GtkWidget *rc;
- sources_modified = FALSE;
-
- if (excludes_modified == TRUE)
- excludes_modified = FALSE;
-
- gslapt_load_ui (builder, "repositories_changed.ui");
- rc = GTK_WIDGET (gtk_builder_get_object (builder, "repositories_changed"));
- gtk_builder_connect_signals (builder, NULL);
- g_object_unref (G_OBJECT (builder));
-
- gtk_widget_show_all(rc);
- } else {
- /* rebuild package list */
- if (excludes_modified == TRUE) {
- excludes_modified = FALSE;
- rebuild_treeviews(NULL,FALSE);
+ tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data), "preferences_exclude_treeview"));
+ model = gtk_tree_view_get_model(tree);
+ valid = gtk_tree_model_get_iter_first(model, &iter);
+ while (valid) {
+ gchar *exclude = NULL;
+ gtk_tree_model_get(model, &iter, 0, &exclude, -1);
+
+ slapt_vector_t_add(global_config->exclude_list, strdup(exclude));
+ g_free(exclude);
+
+ valid = gtk_tree_model_iter_next(model, &iter);
}
- }
-}
+ if (slapt_write_rc_config(global_config, rc_location) != 0) {
+ notify((gchar *)_("Error"), (gchar *)_("Failed to commit preferences"));
+ on_gslapt_destroy(NULL, NULL);
+ }
-void preferences_exclude_add(GtkWidget *w, gpointer *user_data)
-{
- GtkEntry *new_exclude_entry = GTK_ENTRY(gtk_builder_get_object(GTK_BUILDER(user_data),"new_exclude_entry"));
- const gchar *new_exclude = gtk_entry_get_text(new_exclude_entry);
- GtkTreeView *exclude_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data),"preferences_exclude_treeview"));
- GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(exclude_tree));
- GtkTreeIter iter;
+ preferences_window = NULL;
+ gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data), "window_preferences")));
+ g_object_unref(G_OBJECT(user_data));
+ preferences_window_builder = NULL;
- if ( new_exclude == NULL || strlen(new_exclude) < 1 )
- return;
+ /* dialog to resync package sources */
+ if (sources_modified == TRUE) {
+ GtkBuilder *builder = gtk_builder_new();
+ GtkWidget *rc;
+ sources_modified = FALSE;
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, 0, new_exclude, -1);
+ if (excludes_modified == TRUE)
+ excludes_modified = FALSE;
- gtk_entry_set_text(new_exclude_entry,"");
+ gslapt_load_ui(builder, "repositories_changed.ui");
+ rc = GTK_WIDGET(gtk_builder_get_object(builder, "repositories_changed"));
+ gtk_builder_connect_signals(builder, NULL);
+ g_object_unref(G_OBJECT(builder));
+ gtk_widget_show_all(rc);
+ } else {
+ /* rebuild package list */
+ if (excludes_modified == TRUE) {
+ excludes_modified = FALSE;
+ rebuild_treeviews(NULL, FALSE);
+ }
+ }
}
-
-void preferences_exclude_remove(GtkWidget *w, gpointer *user_data)
+void preferences_exclude_add(GtkWidget *w, gpointer *user_data)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeView *exclude_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data),"preferences_exclude_treeview"));
- GtkTreeSelection *select = gtk_tree_view_get_selection (GTK_TREE_VIEW (exclude_tree));
- GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(exclude_tree));
+ GtkEntry *new_exclude_entry = GTK_ENTRY(gtk_builder_get_object(GTK_BUILDER(user_data), "new_exclude_entry"));
+ const gchar *new_exclude = gtk_entry_get_text(new_exclude_entry);
+ GtkTreeView *exclude_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data), "preferences_exclude_treeview"));
+ GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(exclude_tree));
+ GtkTreeIter iter;
- if ( gtk_tree_selection_get_selected(select,&model,&iter)) {
- gtk_list_store_remove(store, &iter);
- }
+ if (new_exclude == NULL || strlen(new_exclude) < 1)
+ return;
-}
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, 0, new_exclude, -1);
+ gtk_entry_set_text(new_exclude_entry, "");
+}
-void cancel_preferences (GtkWidget *w, gpointer *user_data)
+void preferences_exclude_remove(GtkWidget *w, gpointer *user_data)
{
- preferences_window = NULL;
- gtk_widget_destroy(GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER(user_data), "window_preferences")));
- g_object_unref(G_OBJECT(user_data));
- preferences_window_builder = NULL;
-}
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeView *exclude_tree = GTK_TREE_VIEW(gtk_builder_get_object(GTK_BUILDER(user_data), "preferences_exclude_treeview"));
+ GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(exclude_tree));
+ GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(exclude_tree));
+ if (gtk_tree_selection_get_selected(select, &model, &iter)) {
+ gtk_list_store_remove(store, &iter);
+ }
+}
-void cancel_transaction (GtkWidget *w, gpointer *user_data)
+void cancel_preferences(GtkWidget *w, gpointer *user_data)
{
- gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data),"transaction_window")));
- g_object_unref (G_OBJECT (user_data));
+ preferences_window = NULL;
+ gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data), "window_preferences")));
+ g_object_unref(G_OBJECT(user_data));
+ preferences_window_builder = NULL;
}
-void add_pkg_for_reinstall (GtkWidget *gslapt, gpointer *user_data)
+void cancel_transaction(GtkWidget *w, gpointer *user_data)
{
-
- global_config->re_install = TRUE;
- add_pkg_for_install(gslapt,user_data);
- global_config->re_install = FALSE;
-
+ gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data), "transaction_window")));
+ g_object_unref(G_OBJECT(user_data));
}
-static void set_execute_active (void)
+void add_pkg_for_reinstall(GtkWidget *gslapt, gpointer *user_data)
{
-
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"action_bar_execute_button")),TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"execute1")),TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"unmark_all1")),TRUE);
-
- if (pending_trans_context_id == 0) {
- pending_trans_context_id = gslapt_set_status((gchar *)_("Pending changes. Click execute when ready."));
- }
-
+ global_config->re_install = TRUE;
+ add_pkg_for_install(gslapt, user_data);
+ global_config->re_install = FALSE;
}
-static void clear_execute_active (void)
+static void set_execute_active(void)
{
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_execute_button")), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "execute1")), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "unmark_all1")), TRUE);
- if ( pending_trans_context_id > 0 ) {
- gtk_statusbar_pop(
- GTK_STATUSBAR(gtk_builder_get_object(gslapt_builder,"bottom_statusbar")),
- pending_trans_context_id
- );
- pending_trans_context_id = 0;
- }
+ if (pending_trans_context_id == 0) {
+ pending_trans_context_id = gslapt_set_status((gchar *)_("Pending changes. Click execute when ready."));
+ }
+}
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"action_bar_execute_button")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"execute1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"unmark_all1")),FALSE);
+static void clear_execute_active(void)
+{
+ if (pending_trans_context_id > 0) {
+ gtk_statusbar_pop(GTK_STATUSBAR(gtk_builder_get_object(gslapt_builder, "bottom_statusbar")), pending_trans_context_id);
+ pending_trans_context_id = 0;
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_execute_button")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "execute1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "unmark_all1")), FALSE);
}
-static void notify (const char *title,const char *message)
+static void notify(const char *title, const char *message)
{
- GtkBuilder *builder;
- GtkWidget *w;
-
- builder = gtk_builder_new ();
- gslapt_load_ui (builder, "notification.ui");
- w = GTK_WIDGET (gtk_builder_get_object (builder, "notification"));
- gtk_builder_connect_signals (builder, NULL);
-
- gtk_window_set_title (GTK_WINDOW (w), title);
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder,"notification_label")),message);
- gtk_label_set_use_markup (GTK_LABEL(gtk_builder_get_object(builder,"notification_label")),
- TRUE);
- g_object_unref (G_OBJECT (builder));
- gtk_widget_show_all(w);
+ GtkBuilder *builder;
+ GtkWidget *w;
+
+ builder = gtk_builder_new();
+ gslapt_load_ui(builder, "notification.ui");
+ w = GTK_WIDGET(gtk_builder_get_object(builder, "notification"));
+ gtk_builder_connect_signals(builder, NULL);
+
+ gtk_window_set_title(GTK_WINDOW(w), title);
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder, "notification_label")), message);
+ gtk_label_set_use_markup(GTK_LABEL(gtk_builder_get_object(builder, "notification_label")), TRUE);
+ g_object_unref(G_OBJECT(builder));
+ gtk_widget_show_all(w);
}
-static gboolean pkg_action_popup_menu (GtkTreeView *treeview, gpointer data)
+static gboolean pkg_action_popup_menu(GtkTreeView *treeview, gpointer data)
{
- GtkMenu *menu;
- GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
- GtkTreeViewColumn *column;
- GtkTreePath *path;
+ GtkMenu *menu;
+ GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
+ GtkTreeViewColumn *column;
+ GtkTreePath *path;
- if (event == NULL)
- return FALSE;
+ if (event == NULL)
+ return FALSE;
- if (event->type != GDK_BUTTON_PRESS)
- return FALSE;
+ if (event->type != GDK_BUTTON_PRESS)
+ return FALSE;
- if (!gtk_tree_view_get_path_at_pos(treeview,event->x,event->y,&path,&column,NULL,NULL))
- return FALSE;
+ if (!gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, &path, &column, NULL, NULL))
+ return FALSE;
- if (event->button != 3 && (event->button == 1 && strcmp(gtk_tree_view_column_get_title(column),(gchar *)_("Status")) != 0))
- return FALSE;
+ if (event->button != 3 && (event->button == 1 && strcmp(gtk_tree_view_column_get_title(column), (gchar *)_("Status")) != 0))
+ return FALSE;
- gtk_tree_path_free(path);
+ gtk_tree_path_free(path);
- menu = GTK_MENU(gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"package1"))));
+ menu = GTK_MENU(gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "package1"))));
- gtk_menu_popup(
- menu,
- NULL,
- NULL,
- NULL,
- NULL,
- event->button,
- gtk_get_current_event_time()
- );
+ gtk_menu_popup(
+ menu,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ event->button,
+ gtk_get_current_event_time());
- return TRUE;
+ return TRUE;
}
-void unmark_package(GtkWidget *gslapt, gpointer *user_data)
+void unmark_package(GtkWidget *gslapt, gpointer *user_data)
{
- GtkTreeView *treeview;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- slapt_pkg_info_t *pkg = NULL;
- guint is_installed = 0;
- GtkTreeModelSort *package_model;
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- selection = gtk_tree_view_get_selection(treeview);
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
-
- if (gtk_tree_selection_get_selected(selection,(GtkTreeModel **)&package_model,&iter) == TRUE) {
- gchar *pkg_name;
- gchar *pkg_version;
- gchar *pkg_location;
- gchar *status = NULL;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *model;
- GtkTreeIter actual_iter, filter_iter;
-
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
+ GtkTreeView *treeview;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ slapt_pkg_info_t *pkg = NULL;
+ guint is_installed = 0;
+ GtkTreeModelSort *package_model;
- if (pkg_name == NULL || pkg_version == NULL || pkg_location == NULL) {
- fprintf(stderr,"failed to get package name and version from selection\n");
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ selection = gtk_tree_view_get_selection(treeview);
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- if (pkg_name != NULL)
- g_free(pkg_name);
+ if (gtk_tree_selection_get_selected(selection, (GtkTreeModel **)&package_model, &iter) == TRUE) {
+ gchar *pkg_name;
+ gchar *pkg_version;
+ gchar *pkg_location;
+ gchar *status = NULL;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *model;
+ GtkTreeIter actual_iter, filter_iter;
- if (pkg_version != NULL)
- g_free(pkg_version);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
- if (pkg_location != NULL)
- g_free(pkg_location);
+ if (pkg_name == NULL || pkg_version == NULL || pkg_location == NULL) {
+ fprintf(stderr, "failed to get package name and version from selection\n");
- return;
- }
+ if (pkg_name != NULL)
+ g_free(pkg_name);
- if (slapt_get_exact_pkg(installed,pkg_name,pkg_version) != NULL)
- is_installed = 1;
+ if (pkg_version != NULL)
+ g_free(pkg_version);
- if (((pkg = slapt_get_pkg_by_details(all,pkg_name,pkg_version,pkg_location)) == NULL)) {
- pkg = slapt_get_exact_pkg(installed,pkg_name,pkg_version);
- }
+ if (pkg_location != NULL)
+ g_free(pkg_location);
- if (pkg == NULL) {
- fprintf(stderr,"Failed to find package: %s-%s@%s\n",pkg_name,pkg_version,pkg_location);
- g_free(pkg_name);
- g_free(pkg_version);
- g_free(pkg_location);
- return;
- }
- g_free(pkg_name);
- g_free(pkg_version);
- g_free(pkg_location);
-
- /* convert sort model and iter to filter */
- gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(package_model),&filter_iter,&iter);
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- /* convert filter to regular tree */
- gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(filter_model),&actual_iter,&filter_iter);
- model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- if (is_installed == 1) {
- GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
- gtk_list_store_set(GTK_LIST_STORE(model),&actual_iter,STATUS_ICON_COLUMN,status_icon,-1);
- status = g_strdup_printf("a%s",pkg->name);
- } else {
- GdkPixbuf *status_icon = gslapt_img("pkg_action_available.png");
- gtk_list_store_set(GTK_LIST_STORE(model),&actual_iter,STATUS_ICON_COLUMN,status_icon,-1);
- status = g_strdup_printf("z%s",pkg->name);
- }
- gtk_list_store_set(GTK_LIST_STORE(model),&actual_iter,STATUS_COLUMN,status,-1);
- g_free(status);
+ return;
+ }
- gtk_list_store_set(GTK_LIST_STORE(model),&actual_iter,MARKED_COLUMN,FALSE,-1);
+ if (slapt_get_exact_pkg(installed, pkg_name, pkg_version) != NULL)
+ is_installed = 1;
- /* clear the installed version as well if this was an upgrade */
- slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, trans->upgrade_pkgs) {
- if (strcmp(upgrade->installed->name,pkg->name) == 0) {
- slapt_pkg_info_t *installed_pkg = upgrade->installed;
- slapt_pkg_info_t *upgrade_pkg = upgrade->upgrade;
+ if (((pkg = slapt_get_pkg_by_details(all, pkg_name, pkg_version, pkg_location)) == NULL)) {
+ pkg = slapt_get_exact_pkg(installed, pkg_name, pkg_version);
+ }
- if (installed_pkg == NULL)
- continue;
+ if (pkg == NULL) {
+ fprintf(stderr, "Failed to find package: %s-%s@%s\n", pkg_name, pkg_version, pkg_location);
+ g_free(pkg_name);
+ g_free(pkg_version);
+ g_free(pkg_location);
+ return;
+ }
+ g_free(pkg_name);
+ g_free(pkg_version);
+ g_free(pkg_location);
- if (set_iter_to_pkg(model,&actual_iter,installed_pkg)) {
- gchar *istatus = g_strdup_printf("i%s",installed_pkg->name);
- GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
- gtk_list_store_set(GTK_LIST_STORE(model),&actual_iter,STATUS_ICON_COLUMN,status_icon,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),&actual_iter,STATUS_COLUMN,istatus,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),&actual_iter,MARKED_COLUMN,FALSE,-1);
- g_free(istatus);
+ /* convert sort model and iter to filter */
+ gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(package_model), &filter_iter, &iter);
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ /* convert filter to regular tree */
+ gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(filter_model), &actual_iter, &filter_iter);
+ model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ if (is_installed == 1) {
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), &actual_iter, STATUS_ICON_COLUMN, status_icon, -1);
+ status = g_strdup_printf("a%s", pkg->name);
} else {
- fprintf(stderr,"failed to find iter for installed package %s-%s to unmark\n",upgrade->installed->name,upgrade->installed->version);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_available.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), &actual_iter, STATUS_ICON_COLUMN, status_icon, -1);
+ status = g_strdup_printf("z%s", pkg->name);
}
-
- if (upgrade_pkg != NULL) {
- trans = slapt_remove_from_transaction(trans,upgrade_pkg);
+ gtk_list_store_set(GTK_LIST_STORE(model), &actual_iter, STATUS_COLUMN, status, -1);
+ g_free(status);
+
+ gtk_list_store_set(GTK_LIST_STORE(model), &actual_iter, MARKED_COLUMN, FALSE, -1);
+
+ /* clear the installed version as well if this was an upgrade */
+ slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, trans->upgrade_pkgs) {
+ if (strcmp(upgrade->installed->name, pkg->name) == 0) {
+ slapt_pkg_info_t *installed_pkg = upgrade->installed;
+ slapt_pkg_info_t *upgrade_pkg = upgrade->upgrade;
+
+ if (installed_pkg == NULL)
+ continue;
+
+ if (set_iter_to_pkg(model, &actual_iter, installed_pkg)) {
+ gchar *istatus = g_strdup_printf("i%s", installed_pkg->name);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), &actual_iter, STATUS_ICON_COLUMN, status_icon, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &actual_iter, STATUS_COLUMN, istatus, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &actual_iter, MARKED_COLUMN, FALSE, -1);
+ g_free(istatus);
+ } else {
+ fprintf(stderr, "failed to find iter for installed package %s-%s to unmark\n", upgrade->installed->name, upgrade->installed->version);
+ }
+
+ if (upgrade_pkg != NULL) {
+ trans = slapt_remove_from_transaction(trans, upgrade_pkg);
+ }
+ }
}
- }
- }
-
- trans = slapt_remove_from_transaction(trans,pkg);
- if (trans->install_pkgs->size == 0 &&
- trans->remove_pkgs->size == 0 &&
- trans->upgrade_pkgs->size == 0 &&
- trans->reinstall_pkgs->size == 0
- ) {
- clear_execute_active();
+ trans = slapt_remove_from_transaction(trans, pkg);
+ if (trans->install_pkgs->size == 0 &&
+ trans->remove_pkgs->size == 0 &&
+ trans->upgrade_pkgs->size == 0 &&
+ trans->reinstall_pkgs->size == 0) {
+ clear_execute_active();
+ }
}
- }
-
- rebuild_package_action_menu();
+ rebuild_package_action_menu();
}
/* parse the dependencies for a package, and add them to the transaction as */
/* needed check to see if a package is conflicted */
-static int ladd_deps_to_trans (slapt_transaction_t *tran, slapt_vector_t *avail_pkgs,
- slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg)
+static int ladd_deps_to_trans(slapt_transaction_t *tran, slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg)
{
- int dep_return = -1;
- slapt_vector_t *deps = NULL;
- GtkTreeIter iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- GtkTreeModelSort *package_model;
- GtkTreeView *treeview;
-
- if ( global_config->disable_dep_check == TRUE )
- return 0;
- if ( pkg == NULL )
- return 0;
+ int dep_return = -1;
+ slapt_vector_t *deps = NULL;
+ GtkTreeIter iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ GtkTreeModelSort *package_model;
+ GtkTreeView *treeview;
- deps = slapt_vector_t_init(NULL);
+ if (global_config->disable_dep_check == TRUE)
+ return 0;
+ if (pkg == NULL)
+ return 0;
- dep_return = slapt_get_pkg_dependencies(
- global_config,avail_pkgs,installed_pkgs,pkg,
- deps,tran->conflict_err,tran->missing_err
- );
+ deps = slapt_vector_t_init(NULL);
- /* check to see if there where issues with dep checking */
- /* exclude the package if dep check barfed */
- if ( (dep_return == -1) && (global_config->ignore_dep == FALSE) &&
- (slapt_get_exact_pkg(tran->exclude_pkgs,pkg->name,pkg->version) == NULL)
- ) {
- /* don't add exclude here... later we offer an option to install anyway */
- /* slapt_add_exclude_to_transaction(tran,pkg); */
- slapt_vector_t_free(deps);
- return -1;
- }
+ dep_return = slapt_get_pkg_dependencies(global_config, avail_pkgs, installed_pkgs, pkg, deps, tran->conflict_err, tran->missing_err);
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
+ /* check to see if there where issues with dep checking */
+ /* exclude the package if dep check barfed */
+ if ((dep_return == -1) && (global_config->ignore_dep == FALSE) && (slapt_get_exact_pkg(tran->exclude_pkgs, pkg->name, pkg->version) == NULL)) {
+ /* don't add exclude here... later we offer an option to install anyway */
+ /* slapt_add_exclude_to_transaction(tran,pkg); */
+ slapt_vector_t_free(deps);
+ return -1;
+ }
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- /* loop through the deps */
- slapt_vector_t_foreach(slapt_pkg_info_t *, dep, deps) {
- slapt_pkg_info_t *dep_installed;
- slapt_vector_t *conflicts = slapt_is_conflicted(tran,avail_pkgs, installed_pkgs,dep);
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
- /*
- * the dep wouldn't get this far if it where excluded,
- * so we don't check for that here
- */
-
- if ( conflicts->size > 1 ) {
- slapt_vector_t_foreach(slapt_pkg_info_t *, conflicted_pkg, conflicts) {
- slapt_add_remove_to_transaction(tran,conflicted_pkg);
- if (set_iter_to_pkg(GTK_TREE_MODEL(base_model),&iter,conflicted_pkg)) {
- set_iter_for_remove(base_model, &iter, conflicted_pkg);
+ /* loop through the deps */
+ slapt_vector_t_foreach (slapt_pkg_info_t *, dep, deps) {
+ slapt_pkg_info_t *dep_installed;
+ slapt_vector_t *conflicts = slapt_is_conflicted(tran, avail_pkgs, installed_pkgs, dep);
+
+ /* the dep wouldn't get this far if it where excluded, so we don't check for that here */
+
+ if (conflicts->size > 1) {
+ slapt_vector_t_foreach (slapt_pkg_info_t *, conflicted_pkg, conflicts) {
+ slapt_add_remove_to_transaction(tran, conflicted_pkg);
+ if (set_iter_to_pkg(GTK_TREE_MODEL(base_model), &iter, conflicted_pkg)) {
+ set_iter_for_remove(base_model, &iter, conflicted_pkg);
+ }
+ }
}
- }
- }
- dep_installed = slapt_get_newest_pkg(installed_pkgs,dep->name);
- if ( dep_installed == NULL ) {
- slapt_add_install_to_transaction(tran,dep);
- if (set_iter_to_pkg(GTK_TREE_MODEL(base_model),&iter,dep)) {
- set_iter_for_install(base_model, &iter, dep);
- }
- } else {
- /* add only if its a valid upgrade */
- if (slapt_cmp_pkgs(dep_installed,dep) < 0 ) {
- slapt_add_upgrade_to_transaction(tran,dep_installed,dep);
- if (set_iter_to_pkg(GTK_TREE_MODEL(base_model),&iter,dep)) {
- set_iter_for_upgrade(base_model, &iter, dep);
+ dep_installed = slapt_get_newest_pkg(installed_pkgs, dep->name);
+ if (dep_installed == NULL) {
+ slapt_add_install_to_transaction(tran, dep);
+ if (set_iter_to_pkg(GTK_TREE_MODEL(base_model), &iter, dep)) {
+ set_iter_for_install(base_model, &iter, dep);
+ }
+ } else {
+ /* add only if its a valid upgrade */
+ if (slapt_cmp_pkgs(dep_installed, dep) < 0) {
+ slapt_add_upgrade_to_transaction(tran, dep_installed, dep);
+ if (set_iter_to_pkg(GTK_TREE_MODEL(base_model), &iter, dep)) {
+ set_iter_for_upgrade(base_model, &iter, dep);
+ }
+ }
}
- }
}
- }
-
- slapt_vector_t_free(deps);
+ slapt_vector_t_free(deps);
- return 0;
+ return 0;
}
-static int set_iter_to_pkg (GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg)
+static int set_iter_to_pkg(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg)
{
- gboolean valid;
-
- valid = gtk_tree_model_get_iter_first(model,iter);
- while (valid) {
- gchar *name,*version,*location;
- gtk_tree_model_get(model,iter,
- NAME_COLUMN,&name,
- VERSION_COLUMN,&version,
- LOCATION_COLUMN,&location,
- -1
- );
-
- if (name == NULL || version == NULL || location == NULL) {
- valid = gtk_tree_model_iter_next(model,iter);
- continue;
- }
+ gboolean valid;
- if (strcmp(name,pkg->name) == 0 &&
- strcmp(version,pkg->version) == 0 &&
- strcmp(location,pkg->location) == 0) {
- g_free(name);
- g_free(version);
- g_free(location);
- return 1;
- }
- g_free(name);
- g_free(version);
- g_free(location);
+ valid = gtk_tree_model_get_iter_first(model, iter);
+ while (valid) {
+ gchar *name, *version, *location;
+ gtk_tree_model_get(model, iter, NAME_COLUMN, &name, VERSION_COLUMN, &version, LOCATION_COLUMN, &location, -1);
- valid = gtk_tree_model_iter_next(model,iter);
- }
- return 0;
-}
+ if (name == NULL || version == NULL || location == NULL) {
+ valid = gtk_tree_model_iter_next(model, iter);
+ continue;
+ }
-void build_treeview_columns (GtkWidget *treeview)
-{
- GtkTreeSelection *select;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- /* column for installed status */
- renderer = gtk_cell_renderer_pixbuf_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Status"), renderer,
- "pixbuf", STATUS_ICON_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id (column, STATUS_COLUMN);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- /* column for name */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Name"), renderer,
- "text", NAME_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id (column, NAME_COLUMN);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- /* column for version */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Version"), renderer,
- "text", VERSION_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id (column, VERSION_COLUMN);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- /* column for series */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Location"), renderer,
- "text", SERIES_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id (column, SERIES_COLUMN);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- /* column for short description */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Description"), renderer,
- "text", DESC_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id (column, DESC_COLUMN);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- /* column for installed size */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Installed Size"), renderer,
- "text", SIZE_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id (column, SIZE_COLUMN);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- /* invisible column to sort installed by */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Installed"), renderer,
- "text", STATUS_COLUMN, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_visible(column,FALSE);
-
- /* column to set visibility */
- renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes((gchar *)_("Visible"),renderer,
- "radio",VISIBLE_COLUMN,NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_column_set_visible(column,FALSE);
-
- select = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
- g_signal_connect (G_OBJECT (select), "changed",
- G_CALLBACK (show_pkg_details), NULL);
-
- g_signal_connect(G_OBJECT(treeview),"cursor-changed",
- G_CALLBACK(pkg_action_popup_menu),NULL);
+ if (strcmp(name, pkg->name) == 0 &&
+ strcmp(version, pkg->version) == 0 &&
+ strcmp(location, pkg->location) == 0) {
+ g_free(name);
+ g_free(version);
+ g_free(location);
+ return 1;
+ }
+ g_free(name);
+ g_free(version);
+ g_free(location);
+ valid = gtk_tree_model_iter_next(model, iter);
+ }
+ return 0;
}
-static slapt_pkg_upgrade_t *lsearch_upgrade_transaction (slapt_transaction_t *tran,slapt_pkg_info_t *pkg)
+void build_treeview_columns(GtkWidget *treeview)
+{
+ GtkTreeSelection *select;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ /* column for installed status */
+ renderer = gtk_cell_renderer_pixbuf_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Status"), renderer, "pixbuf", STATUS_ICON_COLUMN, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, STATUS_COLUMN);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ /* column for name */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Name"), renderer, "text", NAME_COLUMN, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, NAME_COLUMN);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ /* column for version */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Version"), renderer, "text", VERSION_COLUMN, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, VERSION_COLUMN);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ /* column for series */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Location"), renderer, "text", SERIES_COLUMN, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, SERIES_COLUMN);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ /* column for short description */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Description"), renderer, "text", DESC_COLUMN, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, DESC_COLUMN);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ /* column for installed size */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Installed Size"), renderer, "text", SIZE_COLUMN, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, SIZE_COLUMN);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ /* invisible column to sort installed by */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Installed"), renderer, "text", STATUS_COLUMN, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_visible(column, FALSE);
+
+ /* column to set visibility */
+ renderer = gtk_cell_renderer_toggle_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Visible"), renderer, "radio", VISIBLE_COLUMN, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_visible(column, FALSE);
+
+ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+ gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
+ g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(show_pkg_details), NULL);
+
+ g_signal_connect(G_OBJECT(treeview), "cursor-changed", G_CALLBACK(pkg_action_popup_menu), NULL);
+}
+
+static slapt_pkg_upgrade_t *lsearch_upgrade_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
{
- /*
+ /*
lookup the package in the upgrade list, checking for the same name,version
or location (in the case of location, either the same location for upgrade
or installed)
- */
- slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, tran->upgrade_pkgs) {
- if (strcmp(pkg->name,upgrade->upgrade->name) == 0 &&
- strcmp(pkg->version,upgrade->upgrade->version) == 0 &&
- (strcmp(pkg->location,upgrade->upgrade->location) == 0) ||
- (strcmp(pkg->location,upgrade->installed->location) == 0)) {
- return upgrade;
+ */
+ slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, tran->upgrade_pkgs) {
+ if (strcmp(pkg->name, upgrade->upgrade->name) == 0 &&
+ strcmp(pkg->version, upgrade->upgrade->version) == 0 &&
+ (strcmp(pkg->location, upgrade->upgrade->location) == 0) ||
+ (strcmp(pkg->location, upgrade->installed->location) == 0)) {
+ return upgrade;
+ }
}
- }
-
- return NULL;
+
+ return NULL;
}
-void open_icon_legend (GObject *object, gpointer *user_data)
+void open_icon_legend(GObject *object, gpointer *user_data)
{
- GtkBuilder *builder;
- GtkWidget *icon_legend;
+ GtkBuilder *builder;
+ GtkWidget *icon_legend;
- builder = gtk_builder_new ();
- gslapt_load_ui (builder, "icon_legend.ui");
- icon_legend = GTK_WIDGET (gtk_builder_get_object (builder, "icon_legend"));
- gtk_builder_connect_signals (builder, NULL);
- g_object_unref (G_OBJECT (builder));
+ builder = gtk_builder_new();
+ gslapt_load_ui(builder, "icon_legend.ui");
+ icon_legend = GTK_WIDGET(gtk_builder_get_object(builder, "icon_legend"));
+ gtk_builder_connect_signals(builder, NULL);
+ g_object_unref(G_OBJECT(builder));
- gtk_widget_show_all(icon_legend);
+ gtk_widget_show_all(icon_legend);
}
-
-void on_button_cancel_clicked (GtkButton *button, gpointer *user_data)
+void on_button_cancel_clicked(GtkButton *button, gpointer *user_data)
{
- G_LOCK(_cancelled);
- _cancelled = 1;
- G_UNLOCK(_cancelled);
+ G_LOCK(_cancelled);
+ _cancelled = 1;
+ G_UNLOCK(_cancelled);
}
-static void build_package_action_menu (slapt_pkg_info_t *pkg)
-{
- GtkMenu *menu;
- slapt_pkg_info_t *newest_installed = NULL, *upgrade_pkg = NULL;
- guint is_installed = 0,is_newest = 1,is_exclude = 0,is_downloadable = 0,is_downgrade = 0;
-
- if (slapt_get_exact_pkg(installed,pkg->name,pkg->version) != NULL)
- is_installed = 1;
-
- /* in order to know if a package is re-installable, we have to just look at the
- name and version, not the location */
- if (slapt_get_exact_pkg(all,pkg->name,pkg->version) != NULL)
- is_downloadable = 1;
-
- /* find out if there is a newer available package */
- upgrade_pkg = slapt_get_newest_pkg(all,pkg->name);
- if (upgrade_pkg != NULL && slapt_cmp_pkgs(pkg,upgrade_pkg) < 0)
- is_newest = 0;
-
- if ((newest_installed = slapt_get_newest_pkg(installed,pkg->name)) != NULL) {
- /* this will always be true for high priority package sources */
- if (slapt_cmp_pkgs(pkg,newest_installed) < 0) {
- is_downgrade = 1;
- } else if (is_newest == 0 && slapt_cmp_pkg_versions(pkg->version,newest_installed->version) < 0) {
- /* if pkg is not the newest available version and the version is actually
- less (and does not have a higher priority or would have been handled
- above) then we consider this a downgrade */
- is_downgrade = 1;
- } else if (slapt_cmp_pkgs(pkg,newest_installed) == 0) {
- /* maybe this isn't the exact installed package, but it's different enough
- to warrant reinstall-ability... it is questionable if this is ever
- reached */
- is_installed = 1;
- }
- }
-
- if ( slapt_is_excluded(global_config,pkg) == 1
- || slapt_get_exact_pkg(trans->exclude_pkgs,pkg->name,pkg->version) != NULL) {
- is_exclude = 1;
- }
-
- menu = GTK_MENU(gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"package1"))));
-
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"upgrade1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"re-install1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"downgrade1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"install1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"remove1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"unmark1")),FALSE);
-
- g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder,"upgrade1")),add_pkg_for_install,G_OBJECT(gslapt));
- g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder,"re-install1")),add_pkg_for_reinstall,G_OBJECT(gslapt));
- g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder,"downgrade1")),add_pkg_for_reinstall,G_OBJECT(gslapt));
- g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder,"install1")),add_pkg_for_install,G_OBJECT(gslapt));
- g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder,"remove1")),add_pkg_for_removal,G_OBJECT(gslapt));
- g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder,"unmark1")),unmark_package,G_OBJECT(gslapt));
-
- g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder,"upgrade1")),
- "activate", G_CALLBACK (add_pkg_for_install), GTK_WIDGET(gslapt));
- g_signal_connect_swapped((gpointer)gtk_builder_get_object(gslapt_builder,"re-install1"),
- "activate", G_CALLBACK(add_pkg_for_reinstall),G_OBJECT(gslapt));
- g_signal_connect_swapped((gpointer)gtk_builder_get_object(gslapt_builder,"downgrade1"),
- "activate", G_CALLBACK(add_pkg_for_reinstall),G_OBJECT(gslapt));
- g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder,"install1")),
- "activate", G_CALLBACK (add_pkg_for_install), GTK_WIDGET(gslapt));
- g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder,"remove1")),
- "activate",G_CALLBACK (add_pkg_for_removal), GTK_WIDGET(gslapt));
- g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder,"unmark1")),
- "activate",G_CALLBACK (unmark_package), GTK_WIDGET(gslapt));
-
- if ( slapt_search_transaction(trans,pkg->name) == 0 ) {
- if ( is_exclude == 0 ) {
- /* upgrade */
- if ( is_installed == 1 && is_newest == 0 && (slapt_search_transaction_by_pkg(trans,upgrade_pkg) == 0 ) ) {
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"upgrade1")),TRUE);
- /* re-install */
- }else if ( is_installed == 1 && is_newest == 1 && is_downloadable == 1 ) {
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"re-install1")),TRUE);
- /* this is for downgrades */
- }else if ( is_installed == 0 && is_downgrade == 1 && is_downloadable == 1 ) {
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"downgrade1")),TRUE);
- /* straight up install */
- }else if ( is_installed == 0 && is_downloadable == 1 ) {
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"install1")),TRUE);
- }
+static void build_package_action_menu(slapt_pkg_info_t *pkg)
+{
+ GtkMenu *menu;
+ slapt_pkg_info_t *newest_installed = NULL, *upgrade_pkg = NULL;
+ guint is_installed = 0, is_newest = 1, is_exclude = 0, is_downloadable = 0, is_downgrade = 0;
+
+ if (slapt_get_exact_pkg(installed, pkg->name, pkg->version) != NULL)
+ is_installed = 1;
+
+ /* in order to know if a package is re-installable, we have to just look at the name and version, not the location */
+ if (slapt_get_exact_pkg(all, pkg->name, pkg->version) != NULL)
+ is_downloadable = 1;
+
+ /* find out if there is a newer available package */
+ upgrade_pkg = slapt_get_newest_pkg(all, pkg->name);
+ if (upgrade_pkg != NULL && slapt_cmp_pkgs(pkg, upgrade_pkg) < 0)
+ is_newest = 0;
+
+ if ((newest_installed = slapt_get_newest_pkg(installed, pkg->name)) != NULL) {
+ /* this will always be true for high priority package sources */
+ if (slapt_cmp_pkgs(pkg, newest_installed) < 0) {
+ is_downgrade = 1;
+ } else if (is_newest == 0 && slapt_cmp_pkg_versions(pkg->version, newest_installed->version) < 0) {
+ /* if pkg is not the newest available version and the version is actually
+ less (and does not have a higher priority or would have been handled
+ above) then we consider this a downgrade */
+ is_downgrade = 1;
+ } else if (slapt_cmp_pkgs(pkg, newest_installed) == 0) {
+ /* maybe this isn't the exact installed package, but it's different enough
+ to warrant reinstall-ability... it is questionable if this is ever
+ reached */
+ is_installed = 1;
+ }
}
- }
-
- if (
- is_installed == 1 && is_exclude != 1 &&
- (slapt_search_transaction(trans,pkg->name) == 0)
- ) {
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"remove1")),TRUE);
- }
+ if (slapt_is_excluded(global_config, pkg) == 1 || slapt_get_exact_pkg(trans->exclude_pkgs, pkg->name, pkg->version) != NULL) {
+ is_exclude = 1;
+ }
+
+ menu = GTK_MENU(gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "package1"))));
+
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "upgrade1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "re-install1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "downgrade1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "install1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "remove1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "unmark1")), FALSE);
+
+ g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder, "upgrade1")), add_pkg_for_install, G_OBJECT(gslapt));
+ g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder, "re-install1")), add_pkg_for_reinstall, G_OBJECT(gslapt));
+ g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder, "downgrade1")), add_pkg_for_reinstall, G_OBJECT(gslapt));
+ g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder, "install1")), add_pkg_for_install, G_OBJECT(gslapt));
+ g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder, "remove1")), add_pkg_for_removal, G_OBJECT(gslapt));
+ g_signal_handlers_disconnect_by_func(G_OBJECT(gtk_builder_get_object(gslapt_builder, "unmark1")), unmark_package, G_OBJECT(gslapt));
+
+ g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder, "upgrade1")), "activate", G_CALLBACK(add_pkg_for_install), GTK_WIDGET(gslapt));
+ g_signal_connect_swapped((gpointer)gtk_builder_get_object(gslapt_builder, "re-install1"), "activate", G_CALLBACK(add_pkg_for_reinstall), G_OBJECT(gslapt));
+ g_signal_connect_swapped((gpointer)gtk_builder_get_object(gslapt_builder, "downgrade1"), "activate", G_CALLBACK(add_pkg_for_reinstall), G_OBJECT(gslapt));
+ g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder, "install1")), "activate", G_CALLBACK(add_pkg_for_install), GTK_WIDGET(gslapt));
+ g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder, "remove1")), "activate", G_CALLBACK(add_pkg_for_removal), GTK_WIDGET(gslapt));
+ g_signal_connect_swapped(G_OBJECT(gtk_builder_get_object(gslapt_builder, "unmark1")), "activate", G_CALLBACK(unmark_package), GTK_WIDGET(gslapt));
+
+ if (slapt_search_transaction(trans, pkg->name) == 0) {
+ if (is_exclude == 0) {
+ /* upgrade */
+ if (is_installed == 1 && is_newest == 0 && (slapt_search_transaction_by_pkg(trans, upgrade_pkg) == 0)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "upgrade1")), TRUE);
+ /* re-install */
+ } else if (is_installed == 1 && is_newest == 1 && is_downloadable == 1) {
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "re-install1")), TRUE);
+ /* this is for downgrades */
+ } else if (is_installed == 0 && is_downgrade == 1 && is_downloadable == 1) {
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "downgrade1")), TRUE);
+ /* straight up install */
+ } else if (is_installed == 0 && is_downloadable == 1) {
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "install1")), TRUE);
+ }
+ }
+ }
- if ((slapt_get_exact_pkg(trans->exclude_pkgs,pkg->name,pkg->version) == NULL) &&
- (slapt_search_transaction_by_pkg(trans,pkg) == 1)
- ) {
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"unmark1")),TRUE);
- }
+ if (is_installed == 1 && is_exclude != 1 && (slapt_search_transaction(trans, pkg->name) == 0)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "remove1")), TRUE);
+ }
+ if ((slapt_get_exact_pkg(trans->exclude_pkgs, pkg->name, pkg->version) == NULL) && (slapt_search_transaction_by_pkg(trans, pkg) == 1)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "unmark1")), TRUE);
+ }
}
-static void rebuild_package_action_menu (void)
+static void rebuild_package_action_menu(void)
{
- GtkTreeView *treeview;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GtkTreeModelSort *package_model;
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- selection = gtk_tree_view_get_selection(treeview);
-
- if (gtk_tree_selection_get_selected(selection,(GtkTreeModel **)&package_model,&iter) == TRUE) {
- gchar *pkg_name;
- gchar *pkg_version;
- gchar *pkg_location;
- slapt_pkg_info_t *pkg = NULL;
+ GtkTreeView *treeview;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeModelSort *package_model;
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
+ selection = gtk_tree_view_get_selection(treeview);
- if (pkg_name == NULL || pkg_version == NULL || pkg_location == NULL) {
- if (pkg_name != NULL)
- g_free(pkg_name);
+ if (gtk_tree_selection_get_selected(selection, (GtkTreeModel **)&package_model, &iter) == TRUE) {
+ gchar *pkg_name;
+ gchar *pkg_version;
+ gchar *pkg_location;
+ slapt_pkg_info_t *pkg = NULL;
- if (pkg_version != NULL)
- g_free(pkg_version);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, NAME_COLUMN, &pkg_name, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, VERSION_COLUMN, &pkg_version, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(package_model), &iter, LOCATION_COLUMN, &pkg_location, -1);
- if (pkg_location != NULL)
- g_free(pkg_location);
+ if (pkg_name == NULL || pkg_version == NULL || pkg_location == NULL) {
+ if (pkg_name != NULL)
+ g_free(pkg_name);
- return;
- }
+ if (pkg_version != NULL)
+ g_free(pkg_version);
- pkg = slapt_get_pkg_by_details(all,pkg_name,pkg_version,pkg_location);
- if (pkg == NULL) {
- pkg = slapt_get_pkg_by_details(installed,pkg_name,pkg_version,pkg_location);
- }
- g_free(pkg_name);
- g_free(pkg_version);
- g_free(pkg_location);
+ if (pkg_location != NULL)
+ g_free(pkg_location);
- if (pkg != NULL) {
- build_package_action_menu(pkg);
- }
+ return;
+ }
- } else {
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"upgrade1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"re-install1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"downgrade1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"install1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"remove1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder,"unmark1")),FALSE);
- }
+ pkg = slapt_get_pkg_by_details(all, pkg_name, pkg_version, pkg_location);
+ if (pkg == NULL) {
+ pkg = slapt_get_pkg_by_details(installed, pkg_name, pkg_version, pkg_location);
+ }
+ g_free(pkg_name);
+ g_free(pkg_version);
+ g_free(pkg_location);
-}
+ if (pkg != NULL) {
+ build_package_action_menu(pkg);
+ }
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "upgrade1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "re-install1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "downgrade1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "install1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "remove1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "unmark1")), FALSE);
+ }
+}
-void unmark_all_activate (GtkMenuItem *menuitem, gpointer *user_data)
+void unmark_all_activate(GtkMenuItem *menuitem, gpointer *user_data)
{
+ lock_toolbar_buttons();
- lock_toolbar_buttons();
-
- /* reset our currently selected packages */
- slapt_free_transaction(trans);
- trans = slapt_init_transaction();
-
- rebuild_package_action_menu();
- rebuild_treeviews(NULL,FALSE);
- unlock_toolbar_buttons();
- clear_execute_active();
+ /* reset our currently selected packages */
+ slapt_free_transaction(trans);
+ trans = slapt_init_transaction();
+ rebuild_package_action_menu();
+ rebuild_treeviews(NULL, FALSE);
+ unlock_toolbar_buttons();
+ clear_execute_active();
}
-static void reset_search_list (void)
+static void reset_search_list(void)
{
- gboolean view_list_all = FALSE, view_list_installed = FALSE,
- view_list_available = FALSE, view_list_marked = FALSE,
- view_list_upgradeable = FALSE;
-
- view_list_all = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_all_packages_menu")));
- view_list_available = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_available_packages_menu")));
- view_list_installed = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_installed_packages_menu")));
- view_list_marked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_marked_packages_menu")));
- view_list_upgradeable = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder,"view_upgradeable_packages_menu")));
-
- if (view_list_all) {
- view_all_packages(NULL,NULL);
- } else if (view_list_installed) {
- view_installed_packages(NULL,NULL);
- } else if (view_list_available) {
- view_available_packages(NULL,NULL);
- } else if (view_list_marked) {
- view_marked_packages(NULL,NULL);
- } else if (view_list_upgradeable) {
- view_upgradeable_packages(NULL,NULL);
- }
+ gboolean view_list_all = FALSE, view_list_installed = FALSE,
+ view_list_available = FALSE, view_list_marked = FALSE,
+ view_list_upgradeable = FALSE;
+ view_list_all = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_all_packages_menu")));
+ view_list_available = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_available_packages_menu")));
+ view_list_installed = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_installed_packages_menu")));
+ view_list_marked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_marked_packages_menu")));
+ view_list_upgradeable = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(gslapt_builder, "view_upgradeable_packages_menu")));
+
+ if (view_list_all) {
+ view_all_packages(NULL, NULL);
+ } else if (view_list_installed) {
+ view_installed_packages(NULL, NULL);
+ } else if (view_list_available) {
+ view_available_packages(NULL, NULL);
+ } else if (view_list_marked) {
+ view_marked_packages(NULL, NULL);
+ } else if (view_list_upgradeable) {
+ view_upgradeable_packages(NULL, NULL);
+ }
}
-GtkEntryCompletion *build_search_completions (void)
+GtkEntryCompletion *build_search_completions(void)
{
- GtkTreeModel *completions;
- GtkEntryCompletion *completion;
+ GtkTreeModel *completions;
+ GtkEntryCompletion *completion;
- completions = GTK_TREE_MODEL(gtk_list_store_new(1,G_TYPE_STRING));
+ completions = GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_STRING));
- completion = gtk_entry_completion_new();
- gtk_entry_completion_set_model(completion,completions);
- gtk_entry_completion_set_text_column(completion,0);
+ completion = gtk_entry_completion_new();
+ gtk_entry_completion_set_model(completion, completions);
+ gtk_entry_completion_set_text_column(completion, 0);
- return completion;
+ return completion;
}
-
-void repositories_changed_callback (GtkWidget *repositories_changed,
- gpointer *user_data)
+void repositories_changed_callback(GtkWidget *repositories_changed, gpointer *user_data)
{
- gtk_widget_destroy(GTK_WIDGET(repositories_changed));
- g_signal_emit_by_name(gtk_builder_get_object(gslapt_builder,"action_bar_update_button"),
- "clicked");
+ gtk_widget_destroy(GTK_WIDGET(repositories_changed));
+ g_signal_emit_by_name(gtk_builder_get_object(gslapt_builder, "action_bar_update_button"), "clicked");
}
-
-void update_activate (GtkMenuItem *menuitem, gpointer *user_data)
+void update_activate(GtkMenuItem *menuitem, gpointer *user_data)
{
- return update_callback(NULL,NULL);
+ return update_callback(NULL, NULL);
}
-void mark_all_upgrades_activate (GtkMenuItem *menuitem, gpointer *user_data)
+void mark_all_upgrades_activate(GtkMenuItem *menuitem, gpointer *user_data)
{
- return upgrade_callback(NULL,NULL);
+ return upgrade_callback(NULL, NULL);
}
-void execute_activate (GtkMenuItem *menuitem, gpointer *user_data)
+void execute_activate(GtkMenuItem *menuitem, gpointer *user_data)
{
- return execute_callback(NULL,NULL);
+ return execute_callback(NULL, NULL);
}
-slapt_vector_t *parse_disabled_package_sources (const char *file_name)
+slapt_vector_t *parse_disabled_package_sources(const char *file_name)
{
- FILE *rc = NULL;
- char *getline_buffer = NULL;
- size_t gb_length = 0;
- ssize_t g_size;
- slapt_vector_t *list = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_source);
-
- rc = slapt_open_file(file_name,"r");
- if (rc == NULL)
- return list;
+ FILE *rc = NULL;
+ char *getline_buffer = NULL;
+ size_t gb_length = 0;
+ ssize_t g_size;
+ slapt_vector_t *list = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_source);
- while ( (g_size = getline(&getline_buffer,&gb_length,rc) ) != EOF ) {
- char *nl = NULL;
- if ((nl = strchr(getline_buffer,'\n')) != NULL) {
- nl[0] = '\0';
- }
+ rc = slapt_open_file(file_name, "r");
+ if (rc == NULL)
+ return list;
+
+ while ((g_size = getline(&getline_buffer, &gb_length, rc)) != EOF) {
+ char *nl = NULL;
+ if ((nl = strchr(getline_buffer, '\n')) != NULL) {
+ nl[0] = '\0';
+ }
- if (strstr(getline_buffer,"#DISABLED=") != NULL) {
- if (g_size > 10) {
- slapt_source_t *src = slapt_init_source(getline_buffer + 10);
- if (src != NULL)
- slapt_vector_t_add(list,src);
- }
+ if (strstr(getline_buffer, "#DISABLED=") != NULL) {
+ if (g_size > 10) {
+ slapt_source_t *src = slapt_init_source(getline_buffer + 10);
+ if (src != NULL)
+ slapt_vector_t_add(list, src);
+ }
+ }
}
- }
- if (getline_buffer)
- free(getline_buffer);
+ if (getline_buffer)
+ free(getline_buffer);
- fclose(rc);
+ fclose(rc);
- return list;
+ return list;
}
-static gboolean toggle_source_status (GtkTreeView *treeview, gpointer data)
+static gboolean toggle_source_status(GtkTreeView *treeview, gpointer data)
{
- GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
- GtkTreePath *path;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- if (event == NULL)
- return FALSE;
+ GdkEventButton *event = (GdkEventButton *)gtk_get_current_event();
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
+ GtkTreePath *path;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- if (event->type != GDK_BUTTON_PRESS)
- return FALSE;
+ if (event == NULL)
+ return FALSE;
- if (!gtk_tree_view_get_path_at_pos(treeview,event->x,event->y,&path,&column,NULL,NULL))
- return FALSE;
+ if (event->type != GDK_BUTTON_PRESS)
+ return FALSE;
- if (strcmp(gtk_tree_view_column_get_title(column),(gchar *)_("Enabled")) != 0)
- return FALSE;
+ if (!gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, &path, &column, NULL, NULL))
+ return FALSE;
- gtk_tree_path_free(path);
-
- if ( gtk_tree_selection_get_selected(selection,&model,&iter)) {
- gchar *source;
- gboolean status;
-
- gtk_tree_model_get(model,&iter,1,&source,2,&status,-1 );
-
- if (status) { /* is active */
- GdkPixbuf *status_icon = gslapt_img("pkg_action_available.png");
- gtk_list_store_set(GTK_LIST_STORE(model),&iter,
- 0,status_icon,
- 2,FALSE,
- -1);
- } else { /* is not active */
- GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
- gtk_list_store_set(GTK_LIST_STORE(model),&iter,
- 0,status_icon,
- 2,TRUE,
- -1);
- }
+ if (strcmp(gtk_tree_view_column_get_title(column), (gchar *)_("Enabled")) != 0)
+ return FALSE;
- sources_modified = TRUE;
- g_free(source);
- }
+ gtk_tree_path_free(path);
- return FALSE;
-}
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ gchar *source;
+ gboolean status;
-static void display_dep_error_dialog (slapt_pkg_info_t *pkg)
-{
- GtkBuilder *builder;
- GtkWidget *w;
- GtkTextBuffer *error_buf = NULL;
- gchar *msg = g_strdup_printf((gchar *)_("<b>Excluding %s due to dependency failure</b>"),pkg->name);
-
- builder = gtk_builder_new ();
- gslapt_load_ui (builder, "dep_error_dialog.ui");
- w = GTK_WIDGET (gtk_builder_get_object (builder, "dep_error_dialog"));
- gtk_builder_connect_signals (builder, NULL);
-
- gtk_window_set_title (GTK_WINDOW(w),(char *)_("Error"));
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder,"dep_error_label")),msg);
- g_free(msg);
-
- gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder,"dep_error_install_anyway_warning_label")),
- (char *)_("Missing dependencies may mean the software in this package will not function correctly. Do you want to continue without the required packages?"));
-
- gtk_label_set_use_markup (GTK_LABEL(gtk_builder_get_object(builder,"dep_error_label")),
- TRUE);
- gtk_label_set_use_markup (GTK_LABEL(gtk_builder_get_object(builder,"dep_error_install_anyway_warning_label")),
- TRUE);
- error_buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(builder,"dep_error_text")));
-
- slapt_vector_t_foreach(slapt_pkg_err_t *, missing_err, trans->missing_err) {
- unsigned int len = strlen(missing_err->pkg) +
- strlen((gchar *)_(": Depends: ")) +
- strlen(missing_err->error) + 2;
- char *err = slapt_malloc(sizeof *err * len);
- snprintf(err,len,"%s: Depends: %s\n",missing_err->pkg,
- missing_err->error);
- gtk_text_buffer_insert_at_cursor(error_buf,err,-1);
- free(err);
- }
-
- slapt_vector_t_foreach(slapt_pkg_err_t *, conflict_err, trans->conflict_err) {
- unsigned int len = strlen(conflict_err->error) +
- strlen((gchar *)_(", which is required by ")) +
- strlen(conflict_err->pkg) +
- strlen((gchar *)_(", is excluded")) + 2;
- char *err = slapt_malloc(sizeof *err * len);
- snprintf(err,len,"%s, which is required by %s, is excluded\n",
- conflict_err->error,
- conflict_err->pkg);
- gtk_text_buffer_insert_at_cursor(error_buf,err,-1);
- free(err);
- }
-
- gtk_widget_show_all(w);
- gint result = gtk_dialog_run(GTK_DIALOG(w));
- if (result == GTK_RESPONSE_OK) {
- GtkTreeIter iter;
- slapt_pkg_info_t *installed_pkg = slapt_get_newest_pkg(installed, pkg->name);
+ gtk_tree_model_get(model, &iter, 1, &source, 2, &status, -1);
- GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
- GtkTreeModelSort *package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- GtkTreeModelFilter *filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- GtkTreeModel *model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
- if (installed_pkg == NULL) {
- slapt_add_install_to_transaction(trans, pkg);
- set_iter_for_install(model, &iter, pkg);
- } else {
- int ver_cmp = slapt_cmp_pkgs(installed_pkg, pkg);
- slapt_add_upgrade_to_transaction(trans, installed_pkg, pkg);
- if (ver_cmp == 0) {
- set_iter_for_reinstall(model, &iter, pkg);
- } else if (ver_cmp > 1) {
- printf("Adding upgrade for %s\n", pkg->name);
- set_iter_for_upgrade(model, &iter, pkg);
- } else if (ver_cmp < 1) {
- printf("Adding downupgrade for %s\n", pkg->name);
- set_iter_for_downgrade(model, &iter, pkg);
+ if (status) { /* is active */
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_available.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, status_icon, 2, FALSE, -1);
+ } else { /* is not active */
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, status_icon, 2, TRUE, -1);
}
+
+ sources_modified = TRUE;
+ g_free(source);
}
- set_execute_active();
- } else if (result == GTK_RESPONSE_CANCEL) {
- slapt_add_exclude_to_transaction(trans, pkg);
- }
- rebuild_package_action_menu();
- gtk_widget_destroy(w);
- g_object_unref(G_OBJECT(builder));
+ return FALSE;
}
-void view_all_packages (GtkMenuItem *menuitem, gpointer *user_data)
+static void display_dep_error_dialog(slapt_pkg_info_t *pkg)
{
- gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
- GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- GtkTreeIter iter;
- gboolean valid;
- GtkTreeModelSort *package_model;
-
- if (pattern && strlen(pattern) > 0)
- return build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
-
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- valid = gtk_tree_model_get_iter_first(base_model,&iter);
- while (valid) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- valid = gtk_tree_model_iter_next(base_model,&iter);
- }
+ GtkBuilder *builder;
+ GtkWidget *w;
+ GtkTextBuffer *error_buf = NULL;
+ gchar *msg = g_strdup_printf((gchar *)_("<b>Excluding %s due to dependency failure</b>"), pkg->name);
+
+ builder = gtk_builder_new();
+ gslapt_load_ui(builder, "dep_error_dialog.ui");
+ w = GTK_WIDGET(gtk_builder_get_object(builder, "dep_error_dialog"));
+ gtk_builder_connect_signals(builder, NULL);
+
+ gtk_window_set_title(GTK_WINDOW(w), (char *)_("Error"));
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder, "dep_error_label")), msg);
+ g_free(msg);
+
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder, "dep_error_install_anyway_warning_label")),
+ (char *)_("Missing dependencies may mean the software in this package will not function correctly. Do you want to continue without the required packages?"));
+
+ gtk_label_set_use_markup(GTK_LABEL(gtk_builder_get_object(builder, "dep_error_label")), TRUE);
+ gtk_label_set_use_markup(GTK_LABEL(gtk_builder_get_object(builder, "dep_error_install_anyway_warning_label")), TRUE);
+ error_buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtk_builder_get_object(builder, "dep_error_text")));
+
+ slapt_vector_t_foreach (slapt_pkg_err_t *, missing_err, trans->missing_err) {
+ unsigned int len = strlen(missing_err->pkg) + strlen((gchar *)_(": Depends: ")) + strlen(missing_err->error) + 2;
+ char *err = slapt_malloc(sizeof *err * len);
+ snprintf(err, len, "%s: Depends: %s\n", missing_err->pkg, missing_err->error);
+ gtk_text_buffer_insert_at_cursor(error_buf, err, -1);
+ free(err);
+ }
+
+ slapt_vector_t_foreach (slapt_pkg_err_t *, conflict_err, trans->conflict_err) {
+ unsigned int len = strlen(conflict_err->error) + strlen((gchar *)_(", which is required by ")) + strlen(conflict_err->pkg) + strlen((gchar *)_(", is excluded")) + 2;
+ char *err = slapt_malloc(sizeof *err * len);
+ snprintf(err, len, "%s, which is required by %s, is excluded\n", conflict_err->error, conflict_err->pkg);
+ gtk_text_buffer_insert_at_cursor(error_buf, err, -1);
+ free(err);
+ }
+
+ gtk_widget_show_all(w);
+ gint result = gtk_dialog_run(GTK_DIALOG(w));
+ if (result == GTK_RESPONSE_OK) {
+ GtkTreeIter iter;
+ slapt_pkg_info_t *installed_pkg = slapt_get_newest_pkg(installed, pkg->name);
+
+ GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ GtkTreeModelSort *package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
+ GtkTreeModelFilter *filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ GtkTreeModel *model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+ if (installed_pkg == NULL) {
+ slapt_add_install_to_transaction(trans, pkg);
+ set_iter_for_install(model, &iter, pkg);
+ } else {
+ int ver_cmp = slapt_cmp_pkgs(installed_pkg, pkg);
+ slapt_add_upgrade_to_transaction(trans, installed_pkg, pkg);
+ if (ver_cmp == 0) {
+ set_iter_for_reinstall(model, &iter, pkg);
+ } else if (ver_cmp > 1) {
+ printf("Adding upgrade for %s\n", pkg->name);
+ set_iter_for_upgrade(model, &iter, pkg);
+ } else if (ver_cmp < 1) {
+ printf("Adding downupgrade for %s\n", pkg->name);
+ set_iter_for_downgrade(model, &iter, pkg);
+ }
+ }
+ set_execute_active();
+ } else if (result == GTK_RESPONSE_CANCEL) {
+ slapt_add_exclude_to_transaction(trans, pkg);
+ }
+ rebuild_package_action_menu();
+ gtk_widget_destroy(w);
+ g_object_unref(G_OBJECT(builder));
}
-void view_available_packages (GtkMenuItem *menuitem, gpointer *user_data)
+void view_all_packages(GtkMenuItem *menuitem, gpointer *user_data)
{
- gboolean show_installed = FALSE, show_available = TRUE;
- gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
- GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
+ gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
+ GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ GtkTreeIter iter;
+ gboolean valid;
+ GtkTreeModelSort *package_model;
- view_installed_or_available_packages(show_installed, show_available);
+ if (pattern && strlen(pattern) > 0)
+ return build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
- if (pattern && strlen(pattern) > 0)
- build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
+
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ valid = gtk_tree_model_get_iter_first(base_model, &iter);
+ while (valid) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ valid = gtk_tree_model_iter_next(base_model, &iter);
+ }
}
-void view_installed_packages (GtkMenuItem *menuitem, gpointer *user_data)
+void view_available_packages(GtkMenuItem *menuitem, gpointer *user_data)
{
- gboolean show_installed = TRUE, show_available = FALSE;
- gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
- GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
+ gboolean show_installed = FALSE, show_available = TRUE;
+ gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
+ GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
- view_installed_or_available_packages(show_installed, show_available);
+ view_installed_or_available_packages(show_installed, show_available);
- if (pattern && strlen(pattern) > 0)
- build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
+ if (pattern && strlen(pattern) > 0)
+ build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
}
-void view_installed_or_available_packages (gboolean show_installed, gboolean show_available)
+void view_installed_packages(GtkMenuItem *menuitem, gpointer *user_data)
{
- gboolean valid;
- GtkTreeIter iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- GtkTreeModelSort *package_model;
- GtkTreeView *treeview;
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
-
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- valid = gtk_tree_model_get_iter_first(base_model,&iter);
- while (valid) {
- gboolean from_installed_set = FALSE;
-
- gtk_tree_model_get(base_model,&iter,
- INST_COLUMN, &from_installed_set,
- -1
- );
-
- if (from_installed_set && show_installed) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else if (!from_installed_set && show_available) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,FALSE,-1);
- }
+ gboolean show_installed = TRUE, show_available = FALSE;
+ gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
+ GtkTreeView *treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
- valid = gtk_tree_model_iter_next(base_model,&iter);
- }
+ view_installed_or_available_packages(show_installed, show_available);
+ if (pattern && strlen(pattern) > 0)
+ build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
}
-
-void view_marked_packages (GtkMenuItem *menuitem, gpointer *user_data)
+void view_installed_or_available_packages(gboolean show_installed, gboolean show_available)
{
- gboolean valid;
- GtkTreeIter iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- GtkTreeModelSort *package_model;
- GtkTreeView *treeview;
- gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
-
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- valid = gtk_tree_model_get_iter_first(base_model,&iter);
- while (valid) {
- gboolean marked = FALSE;
-
- gtk_tree_model_get(base_model,&iter,
- MARKED_COLUMN, &marked,
- -1
- );
-
- if (marked) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,FALSE,-1);
- }
+ gboolean valid;
+ GtkTreeIter iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ GtkTreeModelSort *package_model;
+ GtkTreeView *treeview;
- valid = gtk_tree_model_iter_next(base_model,&iter);
- }
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
- if (pattern && strlen(pattern) > 0)
- build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ valid = gtk_tree_model_get_iter_first(base_model, &iter);
+ while (valid) {
+ gboolean from_installed_set = FALSE;
+
+ gtk_tree_model_get(base_model, &iter, INST_COLUMN, &from_installed_set, -1);
+
+ if (from_installed_set && show_installed) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else if (!from_installed_set && show_available) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, FALSE, -1);
+ }
+
+ valid = gtk_tree_model_iter_next(base_model, &iter);
+ }
}
-static int set_iter_for_install(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg)
+void view_marked_packages(GtkMenuItem *menuitem, gpointer *user_data)
{
- gchar *status = g_strdup_printf("i%s",pkg->name);
- GdkPixbuf *status_icon = gslapt_img("pkg_action_install.png");
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_ICON_COLUMN,status_icon,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_COLUMN,status,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,MARKED_COLUMN,TRUE,-1);
- g_free(status);
- return 0;
+ gboolean valid;
+ GtkTreeIter iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ GtkTreeModelSort *package_model;
+ GtkTreeView *treeview;
+ gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
+
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
+
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ valid = gtk_tree_model_get_iter_first(base_model, &iter);
+ while (valid) {
+ gboolean marked = FALSE;
+
+ gtk_tree_model_get(base_model, &iter, MARKED_COLUMN, &marked, -1);
+
+ if (marked) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, FALSE, -1);
+ }
+
+ valid = gtk_tree_model_iter_next(base_model, &iter);
+ }
+
+ if (pattern && strlen(pattern) > 0)
+ build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
}
-static int set_iter_for_reinstall(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg)
+static int set_iter_for_install(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg)
{
- gchar *status = g_strdup_printf("u%s",pkg->name);
- GdkPixbuf *status_icon = gslapt_img("pkg_action_reinstall.png");
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_ICON_COLUMN,status_icon,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_COLUMN,status,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,MARKED_COLUMN,TRUE,-1);
- g_free(status);
- return 0;
+ gchar *status = g_strdup_printf("i%s", pkg->name);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_install.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_ICON_COLUMN, status_icon, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_COLUMN, status, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, MARKED_COLUMN, TRUE, -1);
+ g_free(status);
+ return 0;
}
-static int set_iter_for_downgrade(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg)
+static int set_iter_for_reinstall(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg)
{
- gchar *status = g_strdup_printf("u%s",pkg->name);
- GdkPixbuf *status_icon = gslapt_img("pkg_action_downgrade.png");
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_ICON_COLUMN,status_icon,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_COLUMN,status,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,MARKED_COLUMN,TRUE,-1);
- g_free(status);
- return 0;
+ gchar *status = g_strdup_printf("u%s", pkg->name);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_reinstall.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_ICON_COLUMN, status_icon, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_COLUMN, status, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, MARKED_COLUMN, TRUE, -1);
+ g_free(status);
+ return 0;
}
-static int set_iter_for_upgrade(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg)
+static int set_iter_for_downgrade(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg)
{
- gchar *status = g_strdup_printf("u%s",pkg->name);
- GdkPixbuf *status_icon = gslapt_img("pkg_action_upgrade.png");
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_ICON_COLUMN,status_icon,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_COLUMN,status,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,MARKED_COLUMN,TRUE,-1);
- g_free(status);
- return 0;
+ gchar *status = g_strdup_printf("u%s", pkg->name);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_downgrade.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_ICON_COLUMN, status_icon, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_COLUMN, status, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, MARKED_COLUMN, TRUE, -1);
+ g_free(status);
+ return 0;
}
-static int set_iter_for_remove(GtkTreeModel *model, GtkTreeIter *iter,
- slapt_pkg_info_t *pkg)
+static int set_iter_for_upgrade(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg)
{
- gchar *status = g_strdup_printf("r%s",pkg->name);
- GdkPixbuf *status_icon = gslapt_img("pkg_action_remove.png");
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_ICON_COLUMN,status_icon,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,STATUS_COLUMN,status,-1);
- gtk_list_store_set(GTK_LIST_STORE(model),iter,MARKED_COLUMN,TRUE,-1);
- g_free(status);
- return 0;
+ gchar *status = g_strdup_printf("u%s", pkg->name);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_upgrade.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_ICON_COLUMN, status_icon, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_COLUMN, status, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, MARKED_COLUMN, TRUE, -1);
+ g_free(status);
+ return 0;
}
+static int set_iter_for_remove(GtkTreeModel *model, GtkTreeIter *iter, slapt_pkg_info_t *pkg)
+{
+ gchar *status = g_strdup_printf("r%s", pkg->name);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_remove.png");
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_ICON_COLUMN, status_icon, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, STATUS_COLUMN, status, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), iter, MARKED_COLUMN, TRUE, -1);
+ g_free(status);
+ return 0;
+}
-void mark_obsolete_packages (GtkMenuItem *menuitem, gpointer *user_data)
+void mark_obsolete_packages(GtkMenuItem *menuitem, gpointer *user_data)
{
- GtkTreeIter iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- GtkTreeModelSort *package_model;
- GtkTreeView *treeview;
+ GtkTreeIter iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ GtkTreeModelSort *package_model;
+ GtkTreeView *treeview;
- set_busy_cursor();
+ set_busy_cursor();
- slapt_vector_t *obsolete = slapt_get_obsolete_pkgs(global_config, all, installed);
+ slapt_vector_t *obsolete = slapt_get_obsolete_pkgs(global_config, all, installed);
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(treeview));
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- slapt_vector_t_foreach(slapt_pkg_info_t *, obsolete_pkg, obsolete) {
- if (slapt_is_excluded(global_config, obsolete_pkg) == 1) {
- slapt_add_exclude_to_transaction(trans, obsolete_pkg);
- } else {
- slapt_add_remove_to_transaction(trans, obsolete_pkg);
- set_iter_to_pkg(base_model, &iter, obsolete_pkg);
- set_iter_for_remove(base_model, &iter, obsolete_pkg);
- set_execute_active();
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+ slapt_vector_t_foreach (slapt_pkg_info_t *, obsolete_pkg, obsolete) {
+ if (slapt_is_excluded(global_config, obsolete_pkg) == 1) {
+ slapt_add_exclude_to_transaction(trans, obsolete_pkg);
+ } else {
+ slapt_add_remove_to_transaction(trans, obsolete_pkg);
+ set_iter_to_pkg(base_model, &iter, obsolete_pkg);
+ set_iter_for_remove(base_model, &iter, obsolete_pkg);
+ set_execute_active();
+ }
}
- }
-
- unset_busy_cursor();
- slapt_vector_t_free(obsolete);
+ unset_busy_cursor();
+ slapt_vector_t_free(obsolete);
}
-static void set_busy_cursor (void)
+static void set_busy_cursor(void)
{
- GdkCursor *c = gdk_cursor_new(GDK_WATCH);
- gdk_window_set_cursor(gtk_widget_get_window(gslapt),c);
- gdk_cursor_unref(c);
- gdk_flush();
+ GdkCursor *c = gdk_cursor_new(GDK_WATCH);
+ gdk_window_set_cursor(gtk_widget_get_window(gslapt), c);
+ gdk_cursor_unref(c);
+ gdk_flush();
}
-static void unset_busy_cursor (void)
+static void unset_busy_cursor(void)
{
- gdk_window_set_cursor(gtk_widget_get_window(gslapt),NULL);
- gdk_flush();
+ gdk_window_set_cursor(gtk_widget_get_window(gslapt), NULL);
+ gdk_flush();
}
-
-static void build_verification_sources_treeviewlist (GtkWidget *treeview)
+static void build_verification_sources_treeviewlist(GtkWidget *treeview)
{
- GtkListStore *store;
- GtkTreeIter iter;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *select;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *select;
- store = gtk_list_store_new (
- 1,
- G_TYPE_STRING
- );
+ store = gtk_list_store_new(1, G_TYPE_STRING);
- slapt_vector_t_foreach(slapt_source_t *, src, global_config->sources) {
- if (src->url == NULL)
- continue;
+ slapt_vector_t_foreach (slapt_source_t *, src, global_config->sources) {
+ if (src->url == NULL)
+ continue;
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store,&iter, 0,src->url, -1);
- }
-
- /* column for url */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Source"), renderer,
- "text", 0, NULL);
- gtk_tree_view_column_set_sort_column_id (column, 0);
- gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview),GTK_TREE_MODEL(store));
- select = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, 0, src->url, -1);
+ }
+
+ /* column for url */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes((gchar *)_("Source"), renderer, "text", 0, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, 0);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+
+ gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
+ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+ gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
}
#ifdef SLAPT_HAS_GPGME
static void get_gpg_key(GtkBuilder *b)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(b,"preferences_verification_sources_treeview"));
- GtkTreeSelection *select = gtk_tree_view_get_selection (GTK_TREE_VIEW (source_tree));
-
- if ( gtk_tree_selection_get_selected(select,&model,&iter)) {
- GtkBuilder *builder;
- GtkLabel *progress_action_label, *progress_message_label;
- GtkProgressBar *p_bar, *dl_bar;
- bool compressed = false;
- FILE *gpg_key= NULL;
- slapt_code_t result;
- gchar *url;
- gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &url, -1);
-
- builder = gtk_builder_new ();
- gslapt_load_ui (builder, "dl_progress_window.ui");
- progress_window = GTK_WIDGET (gtk_builder_get_object (builder, "dl_progress_window"));
- gtk_builder_connect_signals (builder, NULL);
- gtk_window_set_transient_for (GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
-
- gtk_window_set_title(GTK_WINDOW(progress_window),(gchar *)_("Progress"));
- p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder,"dl_progress_progressbar"));
- dl_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder,"dl_progress"));
- progress_action_label = GTK_LABEL(gtk_builder_get_object(builder,"dl_progress_action"));
- progress_message_label = GTK_LABEL(gtk_builder_get_object(builder,"dl_progress_message"));
- gtk_progress_bar_set_fraction(dl_bar,0.0);
- gtk_label_set_text(progress_message_label,url);
- gtk_label_set_text(progress_action_label,(gchar *)SLAPT_GPG_KEY);
-
- gdk_threads_enter();
- gtk_widget_show_all(progress_window);
- gdk_threads_leave();
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(b, "preferences_verification_sources_treeview"));
+ GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(source_tree));
+
+ if (gtk_tree_selection_get_selected(select, &model, &iter)) {
+ GtkBuilder *builder;
+ GtkLabel *progress_action_label, *progress_message_label;
+ GtkProgressBar *p_bar, *dl_bar;
+ bool compressed = false;
+ FILE *gpg_key = NULL;
+ slapt_code_t result;
+ gchar *url;
+ gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &url, -1);
+
+ builder = gtk_builder_new();
+ gslapt_load_ui(builder, "dl_progress_window.ui");
+ progress_window = GTK_WIDGET(gtk_builder_get_object(builder, "dl_progress_window"));
+ gtk_builder_connect_signals(builder, NULL);
+ gtk_window_set_transient_for(GTK_WINDOW(progress_window), GTK_WINDOW(gslapt));
+
+ gtk_window_set_title(GTK_WINDOW(progress_window), (gchar *)_("Progress"));
+ p_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "dl_progress_progressbar"));
+ dl_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "dl_progress"));
+ progress_action_label = GTK_LABEL(gtk_builder_get_object(builder, "dl_progress_action"));
+ progress_message_label = GTK_LABEL(gtk_builder_get_object(builder, "dl_progress_message"));
+ gtk_progress_bar_set_fraction(dl_bar, 0.0);
+ gtk_label_set_text(progress_message_label, url);
+ gtk_label_set_text(progress_action_label, (gchar *)SLAPT_GPG_KEY);
- gpg_key = slapt_get_pkg_source_gpg_key(global_config, url, &compressed);
-
- if (_cancelled == 1)
- {
- G_LOCK(_cancelled);
- _cancelled = 0;
- G_UNLOCK(_cancelled);
- if (gpg_key) {
- fclose(gpg_key);
- gpg_key = NULL;
- }
- }
+ gdk_threads_enter();
+ gtk_widget_show_all(progress_window);
+ gdk_threads_leave();
- if (gpg_key)
- {
- result = slapt_add_pkg_source_gpg_key (gpg_key);
- gdk_threads_enter();
- notify(_("Import"),slapt_strerror(result));
- gdk_threads_leave();
- } else {
- gdk_threads_enter();
- notify(_("Import"),_("No key found"));
- gdk_threads_leave();
- }
+ gpg_key = slapt_get_pkg_source_gpg_key(global_config, url, &compressed);
- g_free(url);
+ if (_cancelled == 1) {
+ G_LOCK(_cancelled);
+ _cancelled = 0;
+ G_UNLOCK(_cancelled);
+ if (gpg_key) {
+ fclose(gpg_key);
+ gpg_key = NULL;
+ }
+ }
- gdk_threads_enter();
- g_object_unref (G_OBJECT (builder));
- gtk_widget_destroy(progress_window);
- gdk_threads_leave();
+ if (gpg_key) {
+ result = slapt_add_pkg_source_gpg_key(gpg_key);
+ gdk_threads_enter();
+ notify(_("Import"), slapt_strerror(result));
+ gdk_threads_leave();
+ } else {
+ gdk_threads_enter();
+ notify(_("Import"), _("No key found"));
+ gdk_threads_leave();
+ }
- }
+ g_free(url);
+ gdk_threads_enter();
+ g_object_unref(G_OBJECT(builder));
+ gtk_widget_destroy(progress_window);
+ gdk_threads_leave();
+ }
}
-void preferences_sources_add_key (GtkWidget *w, gpointer *user_data)
+void preferences_sources_add_key(GtkWidget *w, gpointer *user_data)
{
- GThread *gdp;
+ GThread *gdp;
-#if !GLIB_CHECK_VERSION (2, 31, 0)
- gdp = g_thread_create((GThreadFunc)get_gpg_key,GTK_BUILDER(user_data),FALSE,NULL);
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+ gdp = g_thread_create((GThreadFunc)get_gpg_key, GTK_BUILDER(user_data), FALSE, NULL);
#else
- gdp = g_thread_new("GslaptPrefAddSource", (GThreadFunc)get_gpg_key,GTK_BUILDER(user_data));
+ gdp = g_thread_new("GslaptPrefAddSource", (GThreadFunc)get_gpg_key, GTK_BUILDER(user_data));
#endif
- return;
+ return;
}
#endif
-void view_upgradeable_packages (GtkMenuItem *menuitem, gpointer *user_data)
+void view_upgradeable_packages(GtkMenuItem *menuitem, gpointer *user_data)
{
- gboolean valid;
- GtkTreeIter iter;
- GtkTreeModelFilter *filter_model;
- GtkTreeModel *base_model;
- GtkTreeModelSort *package_model;
- GtkTreeView *treeview;
- gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder,"search_entry")));
-
- treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder,"pkg_listing_treeview"));
- package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
-
- filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
- base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
-
- valid = gtk_tree_model_get_iter_first(base_model,&iter);
- while (valid) {
- gboolean upgradeable = FALSE;
-
- gtk_tree_model_get(base_model,&iter,
- UPGRADEABLE_COLUMN, &upgradeable,
- -1
- );
-
- if (upgradeable) {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,TRUE,-1);
- } else {
- gtk_list_store_set(GTK_LIST_STORE(base_model),&iter,VISIBLE_COLUMN,FALSE,-1);
- }
+ gboolean valid;
+ GtkTreeIter iter;
+ GtkTreeModelFilter *filter_model;
+ GtkTreeModel *base_model;
+ GtkTreeModelSort *package_model;
+ GtkTreeView *treeview;
+ gchar *pattern = (gchar *)gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")));
- valid = gtk_tree_model_iter_next(base_model,&iter);
- }
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview"));
+ package_model = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
- if (pattern && strlen(pattern) > 0)
- build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
+ filter_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(package_model)));
+ base_model = GTK_TREE_MODEL(gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(filter_model)));
+
+ valid = gtk_tree_model_get_iter_first(base_model, &iter);
+ while (valid) {
+ gboolean upgradeable = FALSE;
+
+ gtk_tree_model_get(base_model, &iter, UPGRADEABLE_COLUMN, &upgradeable, -1);
+
+ if (upgradeable) {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, TRUE, -1);
+ } else {
+ gtk_list_store_set(GTK_LIST_STORE(base_model), &iter, VISIBLE_COLUMN, FALSE, -1);
+ }
+
+ valid = gtk_tree_model_iter_next(base_model, &iter);
+ }
+
+ if (pattern && strlen(pattern) > 0)
+ build_searched_treeviewlist(GTK_WIDGET(treeview), pattern);
}
-void view_changelogs (GtkMenuItem *menuitem, gpointer *user_data)
+void view_changelogs(GtkMenuItem *menuitem, gpointer *user_data)
{
- GtkBuilder *builder = gtk_builder_new ();
- int changelogs = 0;
- GtkWidget *changelog_window;
- GtkWidget *changelog_notebook;
-
- gslapt_load_ui (builder, "changelog_window.ui");
- changelog_window = GTK_WIDGET (gtk_builder_get_object (builder, "changelog_window"));
- gtk_builder_connect_signals (builder, NULL);
- gtk_window_set_transient_for (GTK_WINDOW(changelog_window), GTK_WINDOW(gslapt));
-
- changelog_notebook = GTK_WIDGET(gtk_builder_get_object(builder, "changelog_notebook"));
-
- g_object_unref (G_OBJECT (builder));
-
- if ((gslapt_settings->cl_x == gslapt_settings->cl_y == gslapt_settings->cl_width == gslapt_settings->cl_height == 0)) {
- gtk_window_set_default_size(GTK_WINDOW(changelog_window),
- gslapt_settings->cl_width, gslapt_settings->cl_height);
- gtk_window_move(GTK_WINDOW(changelog_window),
- gslapt_settings->cl_x, gslapt_settings->cl_y);
- }
-
- slapt_vector_t_foreach(slapt_source_t *, src, global_config->sources) {
- char *changelog_filename, *changelog_data;
- gchar *source_url, *path_and_file, *changelog_txt;
- struct stat stat_buf;
- size_t pls = 1;
- FILE *changelog_f = NULL;
- GtkWidget *textview, *scrolledwindow, *label;
- GtkTextBuffer *changelog_buffer;
-
- if (src->url == NULL )
- continue;
- if (src->disabled == true)
- continue;
-
- source_url = g_strdup (src->url);
-
- changelog_filename = slapt_gen_filename_from_url(source_url,SLAPT_CHANGELOG_FILE);
- path_and_file = g_strjoin("/", global_config->working_dir, changelog_filename, NULL);
-
- if ((changelog_f = fopen(path_and_file,"rb")) == NULL) {
- free(changelog_filename);
- g_free(path_and_file);
- g_free(source_url);
- continue;
- }
+ GtkBuilder *builder = gtk_builder_new();
+ int changelogs = 0;
+ GtkWidget *changelog_window;
+ GtkWidget *changelog_notebook;
- if (stat(changelog_filename,&stat_buf) == -1) {
- fclose(changelog_f);
- free(changelog_filename);
- g_free(path_and_file);
- g_free(source_url);
- continue;
- }
+ gslapt_load_ui(builder, "changelog_window.ui");
+ changelog_window = GTK_WIDGET(gtk_builder_get_object(builder, "changelog_window"));
+ gtk_builder_connect_signals(builder, NULL);
+ gtk_window_set_transient_for(GTK_WINDOW(changelog_window), GTK_WINDOW(gslapt));
+
+ changelog_notebook = GTK_WIDGET(gtk_builder_get_object(builder, "changelog_notebook"));
- free(changelog_filename);
- g_free(path_and_file);
+ g_object_unref(G_OBJECT(builder));
- /* don't mmap empty files */
- if ((int)stat_buf.st_size < 1) {
- fclose(changelog_f);
- g_free(source_url);
- continue;
+ if ((gslapt_settings->cl_x == gslapt_settings->cl_y == gslapt_settings->cl_width == gslapt_settings->cl_height == 0)) {
+ gtk_window_set_default_size(GTK_WINDOW(changelog_window), gslapt_settings->cl_width, gslapt_settings->cl_height);
+ gtk_window_move(GTK_WINDOW(changelog_window), gslapt_settings->cl_x, gslapt_settings->cl_y);
}
- pls = (size_t)stat_buf.st_size;
+ slapt_vector_t_foreach (slapt_source_t *, src, global_config->sources) {
+ char *changelog_filename, *changelog_data;
+ gchar *source_url, *path_and_file, *changelog_txt;
+ struct stat stat_buf;
+ size_t pls = 1;
+ FILE *changelog_f = NULL;
+ GtkWidget *textview, *scrolledwindow, *label;
+ GtkTextBuffer *changelog_buffer;
- changelog_data = (char *)mmap(0, pls,
- PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(changelog_f), 0);
+ if (src->url == NULL)
+ continue;
+ if (src->disabled == true)
+ continue;
- fclose(changelog_f);
+ source_url = g_strdup(src->url);
- if (changelog_data == (void *)-1) {
- g_free(source_url);
- continue;
- }
+ changelog_filename = slapt_gen_filename_from_url(source_url, SLAPT_CHANGELOG_FILE);
+ path_and_file = g_strjoin("/", global_config->working_dir, changelog_filename, NULL);
- changelog_data[pls - 1] = '\0';
+ if ((changelog_f = fopen(path_and_file, "rb")) == NULL) {
+ free(changelog_filename);
+ g_free(path_and_file);
+ g_free(source_url);
+ continue;
+ }
- changelog_txt = g_strdup(changelog_data);
+ if (stat(changelog_filename, &stat_buf) == -1) {
+ fclose(changelog_f);
+ free(changelog_filename);
+ g_free(path_and_file);
+ g_free(source_url);
+ continue;
+ }
- /* munmap now that we are done */
- if (munmap(changelog_data,pls) == -1) {
- g_free(changelog_txt);
- g_free(source_url);
- continue;
- }
+ free(changelog_filename);
+ g_free(path_and_file);
+
+ /* don't mmap empty files */
+ if ((int)stat_buf.st_size < 1) {
+ fclose(changelog_f);
+ g_free(source_url);
+ continue;
+ }
+
+ pls = (size_t)stat_buf.st_size;
- scrolledwindow = gtk_scrolled_window_new ( NULL, NULL );
- textview = gtk_text_view_new ();
- label = gtk_label_new ( source_url );
+ changelog_data = (char *)mmap(0, pls, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno(changelog_f), 0);
+
+ fclose(changelog_f);
+
+ if (changelog_data == (void *)-1) {
+ g_free(source_url);
+ continue;
+ }
+
+ changelog_data[pls - 1] = '\0';
+
+ changelog_txt = g_strdup(changelog_data);
+
+ /* munmap now that we are done */
+ if (munmap(changelog_data, pls) == -1) {
+ g_free(changelog_txt);
+ g_free(source_url);
+ continue;
+ }
+
+ scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
+ textview = gtk_text_view_new();
+ label = gtk_label_new(source_url);
+
+ if (!g_utf8_validate(changelog_txt, -1, NULL)) {
+ gchar *converted = g_convert(changelog_txt, strlen(changelog_txt), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+ if (converted != NULL) {
+ g_free(changelog_txt);
+ changelog_txt = converted;
+ }
+ }
+
+ changelog_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ gtk_text_buffer_set_text(changelog_buffer, changelog_txt, -1);
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
+
+ gtk_widget_show_all(scrolledwindow);
+ gtk_widget_show_all(textview);
+ gtk_widget_show_all(label);
+
+ gtk_container_add(GTK_CONTAINER(changelog_notebook), scrolledwindow);
+ gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow), 2);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_container_add(GTK_CONTAINER(scrolledwindow), textview);
+ gtk_notebook_set_tab_label(GTK_NOTEBOOK(changelog_notebook), gtk_notebook_get_nth_page(GTK_NOTEBOOK(changelog_notebook), changelogs), label);
- if (!g_utf8_validate(changelog_txt, -1, NULL)) {
- gchar *converted = g_convert(changelog_txt, strlen(changelog_txt), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
- if (converted != NULL) {
g_free(changelog_txt);
- changelog_txt = converted;
- }
+ g_free(source_url);
+ changelogs++;
}
- changelog_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_set_text(changelog_buffer, changelog_txt, -1);
- gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
-
- gtk_widget_show_all( scrolledwindow );
- gtk_widget_show_all( textview );
- gtk_widget_show_all( label );
-
- gtk_container_add ( GTK_CONTAINER(changelog_notebook), scrolledwindow );
- gtk_container_set_border_width ( GTK_CONTAINER(scrolledwindow), 2 );
- gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
-
- gtk_container_add ( GTK_CONTAINER(scrolledwindow), textview );
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (changelog_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (changelog_notebook), changelogs), label);
-
- g_free(changelog_txt);
- g_free(source_url);
- changelogs++;
- }
-
- if (changelogs > 0) {
- gtk_widget_show_all(changelog_window);
- } else {
- gtk_widget_destroy(changelog_window);
- notify((gchar *)_("ChangeLogs"),_("No changelogs found."));
- }
+ if (changelogs > 0) {
+ gtk_widget_show_all(changelog_window);
+ } else {
+ gtk_widget_destroy(changelog_window);
+ notify((gchar *)_("ChangeLogs"), _("No changelogs found."));
+ }
}
-void cancel_source_edit (GtkWidget *w, gpointer *user_data)
+void cancel_source_edit(GtkWidget *w, gpointer *user_data)
{
- gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data),"source_window")));
- g_object_unref(G_OBJECT(user_data));
+ gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data), "source_window")));
+ g_object_unref(G_OBJECT(user_data));
}
-void source_edit_ok (GtkWidget *w, gpointer *user_data)
+void source_edit_ok(GtkWidget *w, gpointer *user_data)
{
- SLAPT_PRIORITY_T priority;
- const char *original_url = NULL;
- const gchar *source = NULL;
- GtkEntry *source_entry = GTK_ENTRY(gtk_builder_get_object(GTK_BUILDER(user_data),"source_entry"));
- GtkComboBox *source_priority = GTK_COMBO_BOX(gtk_builder_get_object(GTK_BUILDER(user_data),"source_priority"));
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder,"preferences_sources_treeview"));
- GtkTreeSelection *select = gtk_tree_view_get_selection (GTK_TREE_VIEW (source_tree));
- GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(source_tree));
-
- source = gtk_entry_get_text(source_entry);
-
- if ( source == NULL || strlen(source) < 1 )
- return;
+ SLAPT_PRIORITY_T priority;
+ const char *original_url = NULL;
+ const gchar *source = NULL;
+ GtkEntry *source_entry = GTK_ENTRY(gtk_builder_get_object(GTK_BUILDER(user_data), "source_entry"));
+ GtkComboBox *source_priority = GTK_COMBO_BOX(gtk_builder_get_object(GTK_BUILDER(user_data), "source_priority"));
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeView *source_tree = GTK_TREE_VIEW(gtk_builder_get_object(preferences_window_builder, "preferences_sources_treeview"));
+ GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(source_tree));
+ GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(source_tree));
+
+ source = gtk_entry_get_text(source_entry);
- priority = convert_gslapt_priority_to_slapt_priority(gtk_combo_box_get_active(source_priority));
+ if (source == NULL || strlen(source) < 1)
+ return;
- if ((original_url = g_object_get_data( G_OBJECT(gtk_builder_get_object(GTK_BUILDER(user_data),"source_window")), "original_url")) != NULL) {
- const char *priority_str = slapt_priority_to_str(priority);
+ priority = convert_gslapt_priority_to_slapt_priority(gtk_combo_box_get_active(source_priority));
- if ( gtk_tree_selection_get_selected(select,&model,&iter))
- gtk_list_store_set(store, &iter, 1, source, 3, priority_str, 4, priority, -1);
+ if ((original_url = g_object_get_data(G_OBJECT(gtk_builder_get_object(GTK_BUILDER(user_data), "source_window")), "original_url")) != NULL) {
+ const char *priority_str = slapt_priority_to_str(priority);
- } else {
- const char *priority_str = slapt_priority_to_str(priority);
- GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- 0, status_icon,
- 1, source,
- 2, TRUE,
- 3, priority_str,
- 4, priority,
- -1);
- g_object_unref(status_icon);
- }
-
- sources_modified = TRUE;
- gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data),"source_window")));
- g_object_unref(G_OBJECT(user_data));
+ if (gtk_tree_selection_get_selected(select, &model, &iter))
+ gtk_list_store_set(store, &iter, 1, source, 3, priority_str, 4, priority, -1);
+
+ } else {
+ const char *priority_str = slapt_priority_to_str(priority);
+ GdkPixbuf *status_icon = gslapt_img("pkg_action_installed.png");
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, status_icon,
+ 1, source,
+ 2, TRUE,
+ 3, priority_str,
+ 4, priority,
+ -1);
+ g_object_unref(status_icon);
+ }
+
+ sources_modified = TRUE;
+ gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(user_data), "source_window")));
+ g_object_unref(G_OBJECT(user_data));
}
static SLAPT_PRIORITY_T convert_gslapt_priority_to_slapt_priority(gint p)
{
- switch (p) {
+ switch (p) {
case 1:
- return SLAPT_PRIORITY_OFFICIAL;
+ return SLAPT_PRIORITY_OFFICIAL;
case 2:
- return SLAPT_PRIORITY_PREFERRED;
+ return SLAPT_PRIORITY_PREFERRED;
case 3:
- return SLAPT_PRIORITY_CUSTOM;
+ return SLAPT_PRIORITY_CUSTOM;
case 0:
default:
- return SLAPT_PRIORITY_DEFAULT;
- };
+ return SLAPT_PRIORITY_DEFAULT;
+ };
}
static gint convert_slapt_priority_to_gslapt_priority(SLAPT_PRIORITY_T p)
{
- switch (p) {
+ switch (p) {
case SLAPT_PRIORITY_DEFAULT:
- return 0;
+ return 0;
case SLAPT_PRIORITY_OFFICIAL:
- return 1;
+ return 1;
case SLAPT_PRIORITY_PREFERRED:
- return 2;
+ return 2;
case SLAPT_PRIORITY_CUSTOM:
- return 3;
+ return 3;
default:
- return -1;
- };
+ return -1;
+ };
}
-GdkPixbuf *gslapt_img (const char *img)
+GdkPixbuf *gslapt_img(const char *img)
{
- char buffer[2048];
+ char buffer[2048];
- snprintf(buffer, 2047, "%s/%s/ui/%s", PACKAGE_DATA_DIR, PACKAGE, img);
+ snprintf(buffer, 2047, "%s/%s/ui/%s", PACKAGE_DATA_DIR, PACKAGE, img);
- GdkPixbuf *i = gdk_pixbuf_new_from_file(buffer, NULL);
- return i;
+ GdkPixbuf *i = gdk_pixbuf_new_from_file(buffer, NULL);
+ return i;
}
-void gslapt_load_ui (GtkBuilder *b, const char *f)
+void gslapt_load_ui(GtkBuilder *b, const char *f)
{
- GError *error = NULL;
- char buffer[2048];
- snprintf (buffer, 2047, "%s/%s/ui/%s", PACKAGE_DATA_DIR, PACKAGE, f);
-
- if (!gtk_builder_add_from_file (b, buffer, &error)) {
- g_warning ("Couldn't load builder file: %s", error->message);
- g_error_free (error);
- exit(1);
- }
+ GError *error = NULL;
+ char buffer[2048];
+ snprintf(buffer, 2047, "%s/%s/ui/%s", PACKAGE_DATA_DIR, PACKAGE, f);
+
+ if (!gtk_builder_add_from_file(b, buffer, &error)) {
+ g_warning("Couldn't load builder file: %s", error->message);
+ g_error_free(error);
+ exit(1);
+ }
}
diff --git a/src/callbacks.h b/src/callbacks.h
index 0d64641..1e2d58c 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -21,127 +21,119 @@
#define RC_LOCATION "/etc/slapt-get/slapt-getrc"
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
/*
* Standard gettext macros.
*/
#ifdef ENABLE_NLS
-# include <libintl.h>
-# undef _
-# define _(String) dgettext (PACKAGE, String)
-# define P_(String, String_p, n) ngettext(String, String_p, n)
-# ifdef gettext_noop
-# define N_(String) gettext_noop (String)
-# else
-# define N_(String) (String)
-# endif
+#include <libintl.h>
+#undef _
+#define _(String) dgettext(PACKAGE, String)
+#define P_(String, String_p, n) ngettext(String, String_p, n)
+#ifdef gettext_noop
+#define N_(String) gettext_noop(String)
#else
-# define textdomain(String) (String)
-# define gettext(String) (String)
-# define dgettext(Domain,Message) (Message)
-# define dcgettext(Domain,Message,Type) (Message)
-# define bindtextdomain(Domain,Directory) (Domain)
-# define _(String) (String)
-# define P_(String, String_p, n) (String_p)
-# define N_(String) (String)
+#define N_(String) (String)
+#endif
+#else
+#define textdomain(String) (String)
+#define gettext(String) (String)
+#define dgettext(Domain, Message) (Message)
+#define dcgettext(Domain, Message, Type) (Message)
+#define bindtextdomain(Domain, Directory) (Domain)
+#define _(String) (String)
+#define P_(String, String_p, n) (String_p)
+#define N_(String) (String)
#endif
-
-
enum {
- STATUS_ICON_COLUMN,
- NAME_COLUMN,
- VERSION_COLUMN,
- LOCATION_COLUMN,
- SERIES_COLUMN,
- DESC_COLUMN,
- SIZE_COLUMN,
- STATUS_COLUMN,
- VISIBLE_COLUMN,
- INST_COLUMN,
- MARKED_COLUMN,
- UPGRADEABLE_COLUMN,
- NUMBER_OF_COLUMNS
+ STATUS_ICON_COLUMN,
+ NAME_COLUMN,
+ VERSION_COLUMN,
+ LOCATION_COLUMN,
+ SERIES_COLUMN,
+ DESC_COLUMN,
+ SIZE_COLUMN,
+ STATUS_COLUMN,
+ VISIBLE_COLUMN,
+ INST_COLUMN,
+ MARKED_COLUMN,
+ UPGRADEABLE_COLUMN,
+ NUMBER_OF_COLUMNS
};
gboolean gslapt_window_resized(GtkWindow *window, GdkEvent *event, gpointer data);
-void on_gslapt_destroy (GObject *object, gpointer *user_data);
-void update_callback (GObject *object, gpointer *user_data);
-void upgrade_callback (GObject *object, gpointer *user_data);
-void execute_callback (GObject *object, gpointer *user_data);
-void search_activated (GtkWidget *gslapt, gpointer *user_data);
-void add_pkg_for_install (GtkWidget *gslapt, gpointer *user_data);
-void add_pkg_for_reinstall (GtkWidget *gslapt, gpointer *user_data);
-void add_pkg_for_removal (GtkWidget *gslapt, gpointer *user_data);
-void build_installed_treeviewlist (GtkWidget *);
-void build_available_treeviewlist (GtkWidget *);
-void build_searched_treeviewlist (GtkWidget *,gchar *pattern);
-void open_about (GObject *object, gpointer *user_data);
+void on_gslapt_destroy(GObject *object, gpointer *user_data);
+void update_callback(GObject *object, gpointer *user_data);
+void upgrade_callback(GObject *object, gpointer *user_data);
+void execute_callback(GObject *object, gpointer *user_data);
+void search_activated(GtkWidget *gslapt, gpointer *user_data);
+void add_pkg_for_install(GtkWidget *gslapt, gpointer *user_data);
+void add_pkg_for_reinstall(GtkWidget *gslapt, gpointer *user_data);
+void add_pkg_for_removal(GtkWidget *gslapt, gpointer *user_data);
+void build_installed_treeviewlist(GtkWidget *);
+void build_available_treeviewlist(GtkWidget *);
+void build_searched_treeviewlist(GtkWidget *, gchar *pattern);
+void open_about(GObject *object, gpointer *user_data);
-void show_pkg_details (GtkTreeSelection *selection, gpointer data);
+void show_pkg_details(GtkTreeSelection *selection, gpointer data);
-void preferences_sources_add (GtkWidget *w, gpointer *user_data);
-void preferences_sources_remove (GtkWidget *w, gpointer *user_data);
-void preferences_sources_edit (GtkWidget *w, gpointer *user_data);
-void preferences_sources_modify (GtkWidget *w, gpointer *user_data);
-void preferences_on_ok_clicked (GtkWidget *w, gpointer *user_data);
+void preferences_sources_add(GtkWidget *w, gpointer *user_data);
+void preferences_sources_remove(GtkWidget *w, gpointer *user_data);
+void preferences_sources_edit(GtkWidget *w, gpointer *user_data);
+void preferences_sources_modify(GtkWidget *w, gpointer *user_data);
+void preferences_on_ok_clicked(GtkWidget *w, gpointer *user_data);
-void transaction_okbutton_clicked (GtkWidget *w, gpointer *user_data);
-void preferences_exclude_add (GtkWidget *w, gpointer *user_data);
-void preferences_exclude_remove (GtkWidget *w, gpointer *user_data);
+void transaction_okbutton_clicked(GtkWidget *w, gpointer *user_data);
+void preferences_exclude_add(GtkWidget *w, gpointer *user_data);
+void preferences_exclude_remove(GtkWidget *w, gpointer *user_data);
-int gtk_progress_callback (void *data, double dltotal, double dlnow,
- double ultotal, double ulnow);
-void build_package_treeviewlist (GtkWidget *treeview);
+int gtk_progress_callback(void *data, double dltotal, double dlnow, double ultotal, double ulnow);
+void build_package_treeviewlist(GtkWidget *treeview);
-void cancel_preferences (GtkWidget *w, gpointer *user_data);
-void cancel_transaction (GtkWidget *w, gpointer *user_data);
+void cancel_preferences(GtkWidget *w, gpointer *user_data);
+void cancel_transaction(GtkWidget *w, gpointer *user_data);
-void unmark_package (GtkWidget *gslapt, gpointer *user_data);
+void unmark_package(GtkWidget *gslapt, gpointer *user_data);
-void build_treeview_columns (GtkWidget *treeview);
+void build_treeview_columns(GtkWidget *treeview);
-void on_button_cancel_clicked (GtkButton *button, gpointer *user_data);
+void on_button_cancel_clicked(GtkButton *button, gpointer *user_data);
-GtkEntryCompletion *build_search_completions (void);
-
-
-void repositories_changed_callback (GtkWidget *repositories_changed,
- gpointer *user_data);
+GtkEntryCompletion *build_search_completions(void);
+void repositories_changed_callback(GtkWidget *repositories_changed, gpointer *user_data);
/* menu callbacks */
-void clean_callback (GtkWidget *widget, gpointer *user_data);
-void open_preferences (GtkMenuItem *menuitem, gpointer *user_data);
-void open_icon_legend (GObject *object, gpointer *user_data);
-void unmark_all_activate (GtkMenuItem *menuitem, gpointer *user_data);
-void update_activate (GtkMenuItem *menuitem, gpointer *user_data);
-void mark_all_upgrades_activate (GtkMenuItem *menuitem, gpointer *user_data);
-void execute_activate (GtkMenuItem *menuitem, gpointer *user_data);
+void clean_callback(GtkWidget *widget, gpointer *user_data);
+void open_preferences(GtkMenuItem *menuitem, gpointer *user_data);
+void open_icon_legend(GObject *object, gpointer *user_data);
+void unmark_all_activate(GtkMenuItem *menuitem, gpointer *user_data);
+void update_activate(GtkMenuItem *menuitem, gpointer *user_data);
+void mark_all_upgrades_activate(GtkMenuItem *menuitem, gpointer *user_data);
+void execute_activate(GtkMenuItem *menuitem, gpointer *user_data);
-slapt_vector_t *parse_disabled_package_sources (const char *file_name);
+slapt_vector_t *parse_disabled_package_sources(const char *file_name);
+void view_all_packages(GtkMenuItem *menuitem, gpointer *user_data);
+void view_available_packages(GtkMenuItem *menuitem, gpointer *user_data);
+void view_installed_packages(GtkMenuItem *menuitem, gpointer *user_data);
-void view_all_packages (GtkMenuItem *menuitem, gpointer *user_data);
-void view_available_packages (GtkMenuItem *menuitem, gpointer *user_data);
-void view_installed_packages (GtkMenuItem *menuitem, gpointer *user_data);
+void view_marked_packages(GtkMenuItem *menuitem, gpointer *user_data);
-void view_marked_packages (GtkMenuItem *menuitem, gpointer *user_data);
-
-void mark_obsolete_packages (GtkMenuItem *menuitem, gpointer *user_data);
+void mark_obsolete_packages(GtkMenuItem *menuitem, gpointer *user_data);
#ifdef SLAPT_HAS_GPGME
-void preferences_sources_add_key (GtkWidget *w, gpointer *user_data);
+void preferences_sources_add_key(GtkWidget *w, gpointer *user_data);
#endif
+void view_upgradeable_packages(GtkMenuItem *menuitem, gpointer *user_data);
+void view_changelogs(GtkMenuItem *menuitem, gpointer *user_data);
-void view_upgradeable_packages (GtkMenuItem *menuitem, gpointer *user_data);
-void view_changelogs (GtkMenuItem *menuitem, gpointer *user_data);
-
-void cancel_source_edit (GtkWidget *w, gpointer *user_data);
-void source_edit_ok (GtkWidget *w, gpointer *user_data);
+void cancel_source_edit(GtkWidget *w, gpointer *user_data);
+void source_edit_ok(GtkWidget *w, gpointer *user_data);
-GdkPixbuf *gslapt_img (const char *img);
-void gslapt_load_ui (GtkBuilder *b, const char *f);
+GdkPixbuf *gslapt_img(const char *img);
+void gslapt_load_ui(GtkBuilder *b, const char *f);
diff --git a/src/main.c b/src/main.c
index b0cc080..6eb9b0d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtk/gtk.h>
@@ -35,217 +35,206 @@ char rc_location[1024];
GslaptSettings *gslapt_settings = NULL;
GHashTable *gslapt_series_map = NULL;
-int main (int argc, char *argv[]) {
- GtkStatusbar *bar;
- guint default_context_id;
- GtkEntryCompletion *completions;
- slapt_vector_t *pkg_names_to_install = slapt_vector_t_init(free);
- slapt_vector_t *pkg_names_to_remove = slapt_vector_t_init(free);
- gchar *rc = NULL;
- guint option_index = 0;
- guint do_upgrade = 0;
+int main(int argc, char *argv[])
+{
+ GtkStatusbar *bar;
+ guint default_context_id;
+ GtkEntryCompletion *completions;
+ slapt_vector_t *pkg_names_to_install = slapt_vector_t_init(free);
+ slapt_vector_t *pkg_names_to_remove = slapt_vector_t_init(free);
+ gchar *rc = NULL;
+ guint option_index = 0;
+ guint do_upgrade = 0;
#ifdef ENABLE_NLS
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
- textdomain (GETTEXT_PACKAGE);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ textdomain(GETTEXT_PACKAGE);
#endif
#ifdef SLAPT_HAS_GPGME
- gpgme_check_version (NULL);
+ gpgme_check_version(NULL);
#endif
- /* gtk_set_locale (); */
-#if !GLIB_CHECK_VERSION (2, 31, 0)
- g_thread_init(NULL);
+ /* gtk_set_locale (); */
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+ g_thread_init(NULL);
#endif
- gdk_threads_init();
- gtk_init (&argc, &argv);
-
- trans = slapt_init_transaction();
-
- /* series name mapping */
- gslapt_series_map = gslapt_series_map_init();
- gslapt_series_map_fill(gslapt_series_map);
-
- for (option_index = 1; option_index < argc; ++option_index) {
-
- if (strcmp(argv[option_index],"--upgrade") == 0) {
-
- do_upgrade = 1;
-
- } else if (strcmp(argv[option_index],"--config") == 0) {
-
- if (argc > (option_index + 1) &&
- strcmp(argv[option_index + 1],"--upgrade") != 0 &&
- strcmp(argv[option_index + 1],"--config") != 0 &&
- strcmp(argv[option_index + 1],"--remove") != 0)
- rc = argv[++option_index];
-
- } else if (strcmp(argv[option_index],"--install") == 0) {
- char *next_opt = NULL;
-
- if (argc > (option_index + 1) &&
- strcmp(argv[option_index + 1],"--upgrade") != 0 &&
- strcmp(argv[option_index + 1],"--config") != 0 &&
- strcmp(argv[option_index + 1],"--remove") != 0)
- next_opt = argv[++option_index];
-
- while (next_opt != NULL) {
- slapt_vector_t_add(pkg_names_to_install, strdup(next_opt));
-
- if (argc > (option_index + 1) &&
- strcmp(argv[option_index + 1],"--upgrade") != 0 &&
- strcmp(argv[option_index + 1],"--config") != 0 &&
- strcmp(argv[option_index + 1],"--remove") != 0)
- next_opt = argv[++option_index];
- else
- next_opt = NULL;
+ gdk_threads_init();
+ gtk_init(&argc, &argv);
+
+ trans = slapt_init_transaction();
+
+ /* series name mapping */
+ gslapt_series_map = gslapt_series_map_init();
+ gslapt_series_map_fill(gslapt_series_map);
+
+ for (option_index = 1; option_index < argc; ++option_index) {
+ if (strcmp(argv[option_index], "--upgrade") == 0) {
+ do_upgrade = 1;
+
+ } else if (strcmp(argv[option_index], "--config") == 0) {
+ if (argc > (option_index + 1) &&
+ strcmp(argv[option_index + 1], "--upgrade") != 0 &&
+ strcmp(argv[option_index + 1], "--config") != 0 &&
+ strcmp(argv[option_index + 1], "--remove") != 0)
+ rc = argv[++option_index];
+
+ } else if (strcmp(argv[option_index], "--install") == 0) {
+ char *next_opt = NULL;
+
+ if (argc > (option_index + 1) &&
+ strcmp(argv[option_index + 1], "--upgrade") != 0 &&
+ strcmp(argv[option_index + 1], "--config") != 0 &&
+ strcmp(argv[option_index + 1], "--remove") != 0)
+ next_opt = argv[++option_index];
+
+ while (next_opt != NULL) {
+ slapt_vector_t_add(pkg_names_to_install, strdup(next_opt));
+
+ if (argc > (option_index + 1) &&
+ strcmp(argv[option_index + 1], "--upgrade") != 0 &&
+ strcmp(argv[option_index + 1], "--config") != 0 &&
+ strcmp(argv[option_index + 1], "--remove") != 0)
+ next_opt = argv[++option_index];
+ else
+ next_opt = NULL;
+ }
- }
+ } else if (strcmp(argv[option_index], "--remove") == 0) {
+ char *next_opt = NULL;
+
+ if (argc > (option_index + 1) &&
+ strcmp(argv[option_index + 1], "--upgrade") != 0 &&
+ strcmp(argv[option_index + 1], "--config") != 0 &&
+ strcmp(argv[option_index + 1], "--install") != 0)
+ next_opt = argv[++option_index];
+
+ while (next_opt != NULL) {
+ slapt_vector_t_add(pkg_names_to_remove, strdup(next_opt));
+
+ if (argc > (option_index + 1) &&
+ strcmp(argv[option_index + 1], "--upgrade") != 0 &&
+ strcmp(argv[option_index + 1], "--config") != 0 &&
+ strcmp(argv[option_index + 1], "--install") != 0)
+ next_opt = argv[++option_index];
+ else
+ next_opt = NULL;
+ }
+ }
+ }
- } else if (strcmp(argv[option_index],"--remove") == 0) {
- char *next_opt = NULL;
+ if (rc == NULL) {
+ global_config = slapt_read_rc_config(RC_LOCATION);
+ strncpy(rc_location, RC_LOCATION, 1023);
+ } else {
+ global_config = slapt_read_rc_config(rc);
+ strncpy(rc_location, rc, 1023);
+ }
+ if (global_config == NULL)
+ exit(1);
+ slapt_working_dir_init(global_config);
+ chdir(global_config->working_dir);
+ global_config->progress_cb = gtk_progress_callback;
- if (argc > (option_index + 1) &&
- strcmp(argv[option_index + 1],"--upgrade") != 0 &&
- strcmp(argv[option_index + 1],"--config") != 0 &&
- strcmp(argv[option_index + 1],"--install") != 0)
- next_opt = argv[++option_index];
+ /* read in all pkgs and installed pkgs */
+ installed = slapt_get_installed_pkgs();
+ all = slapt_get_available_pkgs();
- while (next_opt != NULL) {
- slapt_vector_t_add(pkg_names_to_remove, strdup(next_opt));
+ gslapt_builder = gtk_builder_new();
+ gtk_builder_set_translation_domain(gslapt_builder, GETTEXT_PACKAGE);
+ gslapt_load_ui(gslapt_builder, "gslapt.ui");
- if (argc > (option_index + 1) &&
- strcmp(argv[option_index + 1],"--upgrade") != 0 &&
- strcmp(argv[option_index + 1],"--config") != 0 &&
- strcmp(argv[option_index + 1],"--install") != 0)
- next_opt = argv[++option_index];
- else
- next_opt = NULL;
+ gslapt = GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "gslapt"));
+ gtk_builder_connect_signals(gslapt_builder, NULL);
+ // g_object_unref (G_OBJECT (gslapt_builder));
- }
- }
+ completions = build_search_completions();
+ gtk_entry_set_completion(GTK_ENTRY(gtk_builder_get_object(gslapt_builder, "search_entry")), completions);
- }
-
- if (rc == NULL) {
- global_config = slapt_read_rc_config(RC_LOCATION);
- strncpy(rc_location,RC_LOCATION,1023);
- } else {
- global_config = slapt_read_rc_config(rc);
- strncpy(rc_location,rc,1023);
- }
- if (global_config == NULL)
- exit(1);
- slapt_working_dir_init(global_config);
- chdir(global_config->working_dir);
- global_config->progress_cb = gtk_progress_callback;
-
- /* read in all pkgs and installed pkgs */
- installed = slapt_get_installed_pkgs();
- all = slapt_get_available_pkgs();
-
- gslapt_builder = gtk_builder_new ();
- gtk_builder_set_translation_domain (gslapt_builder, GETTEXT_PACKAGE);
- gslapt_load_ui (gslapt_builder, "gslapt.ui");
-
- gslapt = GTK_WIDGET (gtk_builder_get_object (gslapt_builder, "gslapt"));
- gtk_builder_connect_signals (gslapt_builder, NULL);
- // g_object_unref (G_OBJECT (gslapt_builder));
-
- completions = build_search_completions();
- gtk_entry_set_completion(GTK_ENTRY(gtk_builder_get_object (gslapt_builder,"search_entry")),completions);
-
- build_treeview_columns(
- GTK_WIDGET(gtk_builder_get_object (gslapt_builder,"pkg_listing_treeview")));
- /*
+ build_treeview_columns(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview")));
+ /*
this sometimes screws up resizing of the window (why?)
- g_thread_create((GThreadFunc)build_package_treeviewlist,
+ g_thread_create((GThreadFunc)build_package_treeviewlist,
GTK_WIDGET(gtk_builder_get_object (gslapt_builder,"pkg_listing_treeview")),FALSE,NULL);
- */
- build_package_treeviewlist(GTK_WIDGET(gtk_builder_get_object (gslapt_builder,"pkg_listing_treeview")));
-
- bar = GTK_STATUSBAR(gtk_builder_get_object (gslapt_builder,"bottom_statusbar"));
- default_context_id = gtk_statusbar_get_context_id(bar,"default");
- gtk_statusbar_push(bar,default_context_id,(gchar *)_("Ready"));
-
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (gslapt_builder,
- "action_bar_execute_button")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (gslapt_builder,"execute1")),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (gslapt_builder,"unmark_all1")),FALSE);
-
- /* restore previous rc settings */
- gslapt_settings = gslapt_read_rc();
- if (gslapt_settings == NULL) {
- gslapt_settings = gslapt_new_rc();
- gtk_window_set_default_size (GTK_WINDOW (gslapt), 640, 480);
- } else {
- gtk_window_set_default_size(GTK_WINDOW(gslapt),
- gslapt_settings->width, gslapt_settings->height);
- gtk_window_move(GTK_WINDOW(gslapt),
- gslapt_settings->x, gslapt_settings->y);
- }
-
- gtk_widget_show_all (gslapt);
-
- if (do_upgrade == 1) {
- g_signal_emit_by_name(gtk_builder_get_object (gslapt_builder,"action_bar_upgrade_button"),"clicked");
- } else {
- if (pkg_names_to_install->size > 0) {
- slapt_vector_t_foreach(char *, pkg_name_to_install, pkg_names_to_install) {
- slapt_pkg_info_t *p = slapt_get_newest_pkg(all, pkg_name_to_install);
- slapt_pkg_info_t *inst_p = slapt_get_newest_pkg(installed, pkg_name_to_install);
-
- if (p == NULL)
- continue;
-
- if ( inst_p != NULL && slapt_cmp_pkgs(inst_p,p) == 0) {
- continue;
- } else if ( inst_p != NULL && slapt_cmp_pkgs(inst_p,p) < 0) {
- if (slapt_add_deps_to_trans(global_config,trans,all,installed,p) == 0) {
- slapt_add_upgrade_to_transaction(trans,inst_p,p);
- } else {
- exit(1);
- }
- } else {
- if (slapt_add_deps_to_trans(global_config,trans,all,installed,p) == 0) {
- slapt_vector_t *conflicts = slapt_is_conflicted(trans, all, installed, p);
- slapt_add_install_to_transaction(trans, p);
- if ( conflicts->size > 0) {
- slapt_vector_t_foreach(slapt_pkg_info_t *, conflict_pkg, conflicts) {
- slapt_add_remove_to_transaction(trans, conflict_pkg);
+ */
+ build_package_treeviewlist(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "pkg_listing_treeview")));
+
+ bar = GTK_STATUSBAR(gtk_builder_get_object(gslapt_builder, "bottom_statusbar"));
+ default_context_id = gtk_statusbar_get_context_id(bar, "default");
+ gtk_statusbar_push(bar, default_context_id, (gchar *)_("Ready"));
+
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "action_bar_execute_button")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "execute1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(gslapt_builder, "unmark_all1")), FALSE);
+
+ /* restore previous rc settings */
+ gslapt_settings = gslapt_read_rc();
+ if (gslapt_settings == NULL) {
+ gslapt_settings = gslapt_new_rc();
+ gtk_window_set_default_size(GTK_WINDOW(gslapt), 640, 480);
+ } else {
+ gtk_window_set_default_size(GTK_WINDOW(gslapt), gslapt_settings->width, gslapt_settings->height);
+ gtk_window_move(GTK_WINDOW(gslapt), gslapt_settings->x, gslapt_settings->y);
+ }
+
+ gtk_widget_show_all(gslapt);
+
+ if (do_upgrade == 1) {
+ g_signal_emit_by_name(gtk_builder_get_object(gslapt_builder, "action_bar_upgrade_button"), "clicked");
+ } else {
+ if (pkg_names_to_install->size > 0) {
+ slapt_vector_t_foreach (char *, pkg_name_to_install, pkg_names_to_install) {
+ slapt_pkg_info_t *p = slapt_get_newest_pkg(all, pkg_name_to_install);
+ slapt_pkg_info_t *inst_p = slapt_get_newest_pkg(installed, pkg_name_to_install);
+
+ if (p == NULL)
+ continue;
+
+ if (inst_p != NULL && slapt_cmp_pkgs(inst_p, p) == 0) {
+ continue;
+ } else if (inst_p != NULL && slapt_cmp_pkgs(inst_p, p) < 0) {
+ if (slapt_add_deps_to_trans(global_config, trans, all, installed, p) == 0) {
+ slapt_add_upgrade_to_transaction(trans, inst_p, p);
+ } else {
+ exit(1);
+ }
+ } else {
+ if (slapt_add_deps_to_trans(global_config, trans, all, installed, p) == 0) {
+ slapt_vector_t *conflicts = slapt_is_conflicted(trans, all, installed, p);
+ slapt_add_install_to_transaction(trans, p);
+ if (conflicts->size > 0) {
+ slapt_vector_t_foreach (slapt_pkg_info_t *, conflict_pkg, conflicts) {
+ slapt_add_remove_to_transaction(trans, conflict_pkg);
+ }
+ }
+ slapt_vector_t_free(conflicts);
+ } else {
+ exit(1);
+ }
}
}
- slapt_vector_t_free(conflicts);
- } else {
- exit(1);
- }
}
- }
- }
- if (pkg_names_to_remove->size > 0) {
- slapt_vector_t_foreach(char *, pkg_name_to_remove, pkg_names_to_remove) {
- slapt_pkg_info_t *r = slapt_get_newest_pkg(installed, pkg_name_to_remove);
- if (r != NULL) {
- slapt_add_remove_to_transaction(trans,r);
+ if (pkg_names_to_remove->size > 0) {
+ slapt_vector_t_foreach (char *, pkg_name_to_remove, pkg_names_to_remove) {
+ slapt_pkg_info_t *r = slapt_get_newest_pkg(installed, pkg_name_to_remove);
+ if (r != NULL) {
+ slapt_add_remove_to_transaction(trans, r);
+ }
+ }
}
- }
}
- }
+ slapt_vector_t_free(pkg_names_to_install);
+ slapt_vector_t_free(pkg_names_to_remove);
- slapt_vector_t_free(pkg_names_to_install);
- slapt_vector_t_free(pkg_names_to_remove);
-
- if ( trans->remove_pkgs->size > 0 || trans->install_pkgs->size > 0 || trans->upgrade_pkgs->size > 0) {
- g_signal_emit_by_name(gtk_builder_get_object (gslapt_builder,"action_bar_execute_button"),"clicked");
- }
+ if (trans->remove_pkgs->size > 0 || trans->install_pkgs->size > 0 || trans->upgrade_pkgs->size > 0) {
+ g_signal_emit_by_name(gtk_builder_get_object(gslapt_builder, "action_bar_execute_button"), "clicked");
+ }
- gdk_threads_enter();
- gtk_main ();
- gdk_threads_leave();
+ gdk_threads_enter();
+ gtk_main();
+ gdk_threads_leave();
- return 0;
+ return 0;
}
-
diff --git a/src/series.c b/src/series.c
index 0f61cf9..af304a7 100644
--- a/src/series.c
+++ b/src/series.c
@@ -20,90 +20,87 @@
GHashTable *gslapt_series_map_init(void)
{
- GHashTable *map = g_hash_table_new(g_str_hash, g_str_equal);
+ GHashTable *map = g_hash_table_new(g_str_hash, g_str_equal);
- return map;
+ return map;
}
void gslapt_series_map_free(GHashTable *map)
{
- g_hash_table_destroy(map);
+ g_hash_table_destroy(map);
}
int gslapt_series_map_fill(GHashTable *map)
{
- char *file = NULL;
- gchar **keys = NULL;
- int c;
-
- file = g_build_path (G_DIR_SEPARATOR_S, PACKAGE_DATA_DIR, PACKAGE, "series_map.rc", NULL);
-
- if (file == NULL)
- return -1;
-
-
- if (g_file_test(file, G_FILE_TEST_IS_REGULAR) == TRUE) {
- GKeyFile *keyfile= NULL;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GError *error = NULL;
+ char *file = NULL;
+ gchar **keys = NULL;
+ int c;
+
+ file = g_build_path(G_DIR_SEPARATOR_S, PACKAGE_DATA_DIR, PACKAGE, "series_map.rc", NULL);
+
+ if (file == NULL)
+ return -1;
+
+ if (g_file_test(file, G_FILE_TEST_IS_REGULAR) == TRUE) {
+ GKeyFile *keyfile = NULL;
+ GKeyFileFlags flags = G_KEY_FILE_NONE;
+ GError *error = NULL;
+
+ keyfile = g_key_file_new();
+ if (keyfile == NULL)
+ goto GSLAPT_SERIES_MAP_FILL_END;
+
+ if (!g_key_file_load_from_file(keyfile, file, flags, &error)) {
+ if (error != NULL)
+ g_error_free(error);
+ if (keyfile != NULL)
+ g_key_file_free(keyfile);
+ goto GSLAPT_SERIES_MAP_FILL_END;
+ }
- keyfile = g_key_file_new();
- if (keyfile == NULL)
- goto GSLAPT_SERIES_MAP_FILL_END;
+ keys = g_key_file_get_keys(keyfile, "series mappings", NULL, NULL);
+ if (keys != NULL) {
+ for (c = 0; keys[c] != NULL; c++) {
+ gchar *value = g_key_file_get_locale_string(keyfile, "series mappings", keys[c], NULL, NULL);
+ if (value != NULL) {
+ g_hash_table_insert(map, g_strdup(keys[c]), g_strdup(value));
+ g_free(value);
+ g_free(keys[c]);
+ }
+ }
+ g_free(keys);
+ }
- if (!g_key_file_load_from_file (keyfile, file, flags, &error)) {
- if (error != NULL)
- g_error_free(error);
- if (keyfile != NULL)
g_key_file_free(keyfile);
- goto GSLAPT_SERIES_MAP_FILL_END;
- }
-
- keys = g_key_file_get_keys(keyfile, "series mappings", NULL, NULL);
- if (keys != NULL) {
- for (c = 0; keys[c] != NULL; c++) {
- gchar *value = g_key_file_get_locale_string (keyfile, "series mappings", keys[c], NULL, NULL);
- if (value != NULL) {
- g_hash_table_insert(map, g_strdup(keys[c]), g_strdup(value));
- g_free(value);
- g_free(keys[c]);
- }
- }
- g_free(keys);
}
- g_key_file_free(keyfile);
-
- }
-
GSLAPT_SERIES_MAP_FILL_END:
- free(file);
+ free(file);
- return 0;
+ return 0;
}
char *gslapt_series_map_lookup(GHashTable *map, const char *key)
{
- char *value = NULL, *converted = NULL;
- void *v;
-
- if (key == NULL)
- return NULL;
-
- v = g_hash_table_lookup (map, key);
- if (v != NULL) {
- value = (char *)v;
- } else {
- if (strcmp(key,"") != 0)
- value = g_path_get_basename(key);
- }
-
- if (value != NULL) {
- converted = g_convert(value, strlen(value), "UTF-8", "UTF-8", NULL, NULL, NULL);
- if (converted != NULL)
- value = converted;
- }
-
- return value;
-}
+ char *value = NULL, *converted = NULL;
+ void *v;
+
+ if (key == NULL)
+ return NULL;
+
+ v = g_hash_table_lookup(map, key);
+ if (v != NULL) {
+ value = (char *)v;
+ } else {
+ if (strcmp(key, "") != 0)
+ value = g_path_get_basename(key);
+ }
+ if (value != NULL) {
+ converted = g_convert(value, strlen(value), "UTF-8", "UTF-8", NULL, NULL, NULL);
+ if (converted != NULL)
+ value = converted;
+ }
+
+ return value;
+}
diff --git a/src/settings.c b/src/settings.c
index e6a3802..7e1a8e0 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -18,164 +18,161 @@
#include "settings.h"
-char *gslapt_init_rc_dir (void)
+char *gslapt_init_rc_dir(void)
{
- char *dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_config_dir (), PACKAGE, NULL);
+ char *dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), PACKAGE, NULL);
- if (g_file_test(dir, G_FILE_TEST_IS_DIR) == FALSE) {
- if ( g_mkdir_with_parents(dir, 0755) !=0 ) {
- g_free(dir);
- return NULL;
+ if (g_file_test(dir, G_FILE_TEST_IS_DIR) == FALSE) {
+ if (g_mkdir_with_parents(dir, 0755) != 0) {
+ g_free(dir);
+ return NULL;
+ }
}
- }
- return dir;
+ return dir;
}
-GslaptSettings *gslapt_new_rc (void)
+GslaptSettings *gslapt_new_rc(void)
{
- GslaptSettings *g = g_slice_new(GslaptSettings);
- g->x = g->y = g->width = g->height = 0;
- g->cl_x = g->cl_y = g->cl_width = g->cl_height = 0;
- g->pref_x = g->pref_y = g->pref_width = g->pref_height = 0;
- g->tran_x = g->tran_y = g->tran_width = g->tran_height = 0;
+ GslaptSettings *g = g_slice_new(GslaptSettings);
+ g->x = g->y = g->width = g->height = 0;
+ g->cl_x = g->cl_y = g->cl_width = g->cl_height = 0;
+ g->pref_x = g->pref_y = g->pref_width = g->pref_height = 0;
+ g->tran_x = g->tran_y = g->tran_width = g->tran_height = 0;
- return g;
+ return g;
}
-GslaptSettings *gslapt_read_rc (void)
+GslaptSettings *gslapt_read_rc(void)
{
- GslaptSettings *gslapt_settings = NULL;
- char *dir = NULL, *file = NULL;
-
- dir = gslapt_init_rc_dir();
+ GslaptSettings *gslapt_settings = NULL;
+ char *dir = NULL, *file = NULL;
- if (dir == NULL)
- return NULL;
+ dir = gslapt_init_rc_dir();
- file = g_build_path (G_DIR_SEPARATOR_S, dir, "rc", NULL);
- free(dir);
+ if (dir == NULL)
+ return NULL;
- if (file == NULL)
- return NULL;
+ file = g_build_path(G_DIR_SEPARATOR_S, dir, "rc", NULL);
+ free(dir);
+ if (file == NULL)
+ return NULL;
- if (g_file_test(file, G_FILE_TEST_IS_REGULAR) == TRUE) {
- GKeyFile *keyfile= NULL;
- GKeyFileFlags flags = G_KEY_FILE_NONE;
- GError *error = NULL;
+ if (g_file_test(file, G_FILE_TEST_IS_REGULAR) == TRUE) {
+ GKeyFile *keyfile = NULL;
+ GKeyFileFlags flags = G_KEY_FILE_NONE;
+ GError *error = NULL;
- keyfile = g_key_file_new();
- if (keyfile == NULL)
- goto GSLAPT_READ_CONFIG_END;
+ keyfile = g_key_file_new();
+ if (keyfile == NULL)
+ goto GSLAPT_READ_CONFIG_END;
- if (!g_key_file_load_from_file (keyfile, file, flags, &error)) {
- if (error != NULL)
- g_error_free(error);
- if (keyfile != NULL)
- g_key_file_free(keyfile);
- goto GSLAPT_READ_CONFIG_END;
- }
-
- gslapt_settings = g_slice_new(GslaptSettings);
- if (gslapt_settings == NULL) {
- if (error != NULL)
- g_error_free(error);
- g_key_file_free(keyfile);
- goto GSLAPT_READ_CONFIG_END;
- }
+ if (!g_key_file_load_from_file(keyfile, file, flags, &error)) {
+ if (error != NULL)
+ g_error_free(error);
+ if (keyfile != NULL)
+ g_key_file_free(keyfile);
+ goto GSLAPT_READ_CONFIG_END;
+ }
- gslapt_settings->x = g_key_file_get_integer (keyfile, "main window", "x", NULL);
- gslapt_settings->y = g_key_file_get_integer (keyfile, "main window", "y", NULL);
- gslapt_settings->width = g_key_file_get_integer (keyfile, "main window", "width", NULL);
- gslapt_settings->height = g_key_file_get_integer (keyfile, "main window", "height", NULL);
+ gslapt_settings = g_slice_new(GslaptSettings);
+ if (gslapt_settings == NULL) {
+ if (error != NULL)
+ g_error_free(error);
+ g_key_file_free(keyfile);
+ goto GSLAPT_READ_CONFIG_END;
+ }
- gslapt_settings->cl_x = g_key_file_get_integer (keyfile, "changelog window", "x", NULL);
- gslapt_settings->cl_y = g_key_file_get_integer (keyfile, "changelog window", "y", NULL);
- gslapt_settings->cl_width = g_key_file_get_integer (keyfile, "changelog window", "width", NULL);
- gslapt_settings->cl_height = g_key_file_get_integer (keyfile, "changelog window", "height", NULL);
+ gslapt_settings->x = g_key_file_get_integer(keyfile, "main window", "x", NULL);
+ gslapt_settings->y = g_key_file_get_integer(keyfile, "main window", "y", NULL);
+ gslapt_settings->width = g_key_file_get_integer(keyfile, "main window", "width", NULL);
+ gslapt_settings->height = g_key_file_get_integer(keyfile, "main window", "height", NULL);
- gslapt_settings->pref_x = g_key_file_get_integer (keyfile, "preferences window", "x", NULL);
- gslapt_settings->pref_y = g_key_file_get_integer (keyfile, "preferences window", "y", NULL);
- gslapt_settings->pref_width = g_key_file_get_integer (keyfile, "preferences window", "width", NULL);
- gslapt_settings->pref_height = g_key_file_get_integer (keyfile, "preferences window", "height", NULL);
+ gslapt_settings->cl_x = g_key_file_get_integer(keyfile, "changelog window", "x", NULL);
+ gslapt_settings->cl_y = g_key_file_get_integer(keyfile, "changelog window", "y", NULL);
+ gslapt_settings->cl_width = g_key_file_get_integer(keyfile, "changelog window", "width", NULL);
+ gslapt_settings->cl_height = g_key_file_get_integer(keyfile, "changelog window", "height", NULL);
- gslapt_settings->tran_x = g_key_file_get_integer (keyfile, "transaction window", "x", NULL);
- gslapt_settings->tran_y = g_key_file_get_integer (keyfile, "transaction window", "y", NULL);
- gslapt_settings->tran_width = g_key_file_get_integer (keyfile, "transaction window", "width", NULL);
- gslapt_settings->tran_height = g_key_file_get_integer (keyfile, "transaction window", "height", NULL);
+ gslapt_settings->pref_x = g_key_file_get_integer(keyfile, "preferences window", "x", NULL);
+ gslapt_settings->pref_y = g_key_file_get_integer(keyfile, "preferences window", "y", NULL);
+ gslapt_settings->pref_width = g_key_file_get_integer(keyfile, "preferences window", "width", NULL);
+ gslapt_settings->pref_height = g_key_file_get_integer(keyfile, "preferences window", "height", NULL);
- g_key_file_free(keyfile);
+ gslapt_settings->tran_x = g_key_file_get_integer(keyfile, "transaction window", "x", NULL);
+ gslapt_settings->tran_y = g_key_file_get_integer(keyfile, "transaction window", "y", NULL);
+ gslapt_settings->tran_width = g_key_file_get_integer(keyfile, "transaction window", "width", NULL);
+ gslapt_settings->tran_height = g_key_file_get_integer(keyfile, "transaction window", "height", NULL);
- }
+ g_key_file_free(keyfile);
+ }
GSLAPT_READ_CONFIG_END:
- free(file);
+ free(file);
- return gslapt_settings;
+ return gslapt_settings;
}
void gslapt_free_rc(GslaptSettings *gslapt_settings)
{
- g_slice_free(GslaptSettings,gslapt_settings);
+ g_slice_free(GslaptSettings, gslapt_settings);
}
int gslapt_write_rc(GslaptSettings *gslapt_settings)
{
- char *dir;
- int rc = -1;
-
- if (gslapt_settings == NULL)
- return rc;
-
- dir = gslapt_init_rc_dir();
- if (dir != NULL) {
- gsize length;
- GKeyFile *keyfile= NULL;
- gchar *rc_data = NULL;
-
- keyfile = g_key_file_new();
-
- g_key_file_set_integer (keyfile, "main window", "x", gslapt_settings->x);
- g_key_file_set_integer (keyfile, "main window", "y", gslapt_settings->y);
- g_key_file_set_integer (keyfile, "main window", "width", gslapt_settings->width);
- g_key_file_set_integer (keyfile, "main window", "height", gslapt_settings->height);
-
- g_key_file_set_integer (keyfile, "changelog window", "x", gslapt_settings->cl_x);
- g_key_file_set_integer (keyfile, "changelog window", "y", gslapt_settings->cl_y);
- g_key_file_set_integer (keyfile, "changelog window", "width", gslapt_settings->cl_width);
- g_key_file_set_integer (keyfile, "changelog window", "height", gslapt_settings->cl_height);
-
- g_key_file_set_integer (keyfile, "preferences window", "x", gslapt_settings->pref_x);
- g_key_file_set_integer (keyfile, "preferences window", "y", gslapt_settings->pref_y);
- g_key_file_set_integer (keyfile, "preferences window", "width", gslapt_settings->pref_width);
- g_key_file_set_integer (keyfile, "preferences window", "height", gslapt_settings->pref_height);
-
- g_key_file_set_integer (keyfile, "transaction window", "x", gslapt_settings->tran_x);
- g_key_file_set_integer (keyfile, "transaction window", "y", gslapt_settings->tran_y);
- g_key_file_set_integer (keyfile, "transaction window", "width", gslapt_settings->tran_width);
- g_key_file_set_integer (keyfile, "transaction window", "height", gslapt_settings->tran_height);
-
- rc_data = g_key_file_to_data(keyfile, &length, NULL);
- if (length != 0) {
- char *file = g_build_path (G_DIR_SEPARATOR_S, dir, "rc", NULL);
- if (file != NULL) {
- FILE *fh = fopen(file,"wb");
- if (fh != NULL) {
- fprintf(fh, "%s", rc_data);
- rc = 0;
- fclose(fh);
+ char *dir;
+ int rc = -1;
+
+ if (gslapt_settings == NULL)
+ return rc;
+
+ dir = gslapt_init_rc_dir();
+ if (dir != NULL) {
+ gsize length;
+ GKeyFile *keyfile = NULL;
+ gchar *rc_data = NULL;
+
+ keyfile = g_key_file_new();
+
+ g_key_file_set_integer(keyfile, "main window", "x", gslapt_settings->x);
+ g_key_file_set_integer(keyfile, "main window", "y", gslapt_settings->y);
+ g_key_file_set_integer(keyfile, "main window", "width", gslapt_settings->width);
+ g_key_file_set_integer(keyfile, "main window", "height", gslapt_settings->height);
+
+ g_key_file_set_integer(keyfile, "changelog window", "x", gslapt_settings->cl_x);
+ g_key_file_set_integer(keyfile, "changelog window", "y", gslapt_settings->cl_y);
+ g_key_file_set_integer(keyfile, "changelog window", "width", gslapt_settings->cl_width);
+ g_key_file_set_integer(keyfile, "changelog window", "height", gslapt_settings->cl_height);
+
+ g_key_file_set_integer(keyfile, "preferences window", "x", gslapt_settings->pref_x);
+ g_key_file_set_integer(keyfile, "preferences window", "y", gslapt_settings->pref_y);
+ g_key_file_set_integer(keyfile, "preferences window", "width", gslapt_settings->pref_width);
+ g_key_file_set_integer(keyfile, "preferences window", "height", gslapt_settings->pref_height);
+
+ g_key_file_set_integer(keyfile, "transaction window", "x", gslapt_settings->tran_x);
+ g_key_file_set_integer(keyfile, "transaction window", "y", gslapt_settings->tran_y);
+ g_key_file_set_integer(keyfile, "transaction window", "width", gslapt_settings->tran_width);
+ g_key_file_set_integer(keyfile, "transaction window", "height", gslapt_settings->tran_height);
+
+ rc_data = g_key_file_to_data(keyfile, &length, NULL);
+ if (length != 0) {
+ char *file = g_build_path(G_DIR_SEPARATOR_S, dir, "rc", NULL);
+ if (file != NULL) {
+ FILE *fh = fopen(file, "wb");
+ if (fh != NULL) {
+ fprintf(fh, "%s", rc_data);
+ rc = 0;
+ fclose(fh);
+ }
+ g_free(file);
+ }
}
- g_free(file);
- }
- }
- if (rc_data != NULL)
- g_free(rc_data);
+ if (rc_data != NULL)
+ g_free(rc_data);
- g_key_file_free(keyfile);
- g_free(dir);
- }
+ g_key_file_free(keyfile);
+ g_free(dir);
+ }
- return rc;
+ return rc;
}
-
diff --git a/src/settings.h b/src/settings.h
index 4313841..dfb7819 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -25,15 +25,27 @@
#include "config.h"
typedef struct {
- gint x; gint y; gint width; gint height;
- gint cl_x; gint cl_y; gint cl_width; gint cl_height;
- gint pref_x; gint pref_y; gint pref_width; gint pref_height;
- gint tran_x; gint tran_y; gint tran_width; gint tran_height;
+ gint x;
+ gint y;
+ gint width;
+ gint height;
+ gint cl_x;
+ gint cl_y;
+ gint cl_width;
+ gint cl_height;
+ gint pref_x;
+ gint pref_y;
+ gint pref_width;
+ gint pref_height;
+ gint tran_x;
+ gint tran_y;
+ gint tran_width;
+ gint tran_height;
} GslaptSettings;
-char *gslapt_init_rc_dir (void);
-GslaptSettings *gslapt_new_rc (void);
-GslaptSettings *gslapt_read_rc (void);
+char *gslapt_init_rc_dir(void);
+GslaptSettings *gslapt_new_rc(void);
+GslaptSettings *gslapt_read_rc(void);
int gslapt_write_rc(GslaptSettings *gslapt_settings);
void gslapt_free_rc(GslaptSettings *gslapt_settings);