aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/callbacks.c40
-rw-r--r--src/callbacks.h1
-rw-r--r--src/main.c6
-rw-r--r--src/series.c83
-rw-r--r--src/series.h14
6 files changed, 136 insertions, 9 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 99dedc0..e857ce4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,6 +12,7 @@ gslapt_SOURCES = \
support.c support.h \
interface.c interface.h \
callbacks.c callbacks.h \
+ series.c series.h \
settings.c settings.h
gslapt_LDADD = @PACKAGE_LIBS@ $(INTLLIBS)
diff --git a/src/callbacks.c b/src/callbacks.c
index 2d4d4bb..e58141a 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -28,9 +28,11 @@
#include "interface.h"
#include "support.h"
#include "settings.h"
+#include "series.h"
extern GtkWidget *gslapt;
extern GslaptSettings *gslapt_settings;
+extern GHashTable *gslapt_series_map;
extern slapt_rc_config *global_config;
extern struct slapt_pkg_list *all;
extern struct slapt_pkg_list *installed;
@@ -139,6 +141,7 @@ void on_gslapt_destroy (GtkObject *object, gpointer user_data)
slapt_free_pkg_list(all);
slapt_free_pkg_list(installed);
slapt_free_rc_config(global_config);
+ gslapt_series_map_free(gslapt_series_map);
gslapt_write_rc(gslapt_settings);
gslapt_free_rc(gslapt_settings);
@@ -511,9 +514,18 @@ void build_package_treeviewlist (GtkWidget *treeview)
base_model = GTK_TREE_MODEL(gtk_list_store_new (
NUMBER_OF_COLUMNS,
- GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN
+ 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 */
));
for (i = 0; i < all->pkg_count; i++ ) {
@@ -524,7 +536,7 @@ void build_package_treeviewlist (GtkWidget *treeview)
GdkPixbuf *status_icon = NULL;
gchar *short_desc = slapt_gen_short_pkg_description(all->pkgs[i]);
slapt_pkg_info_t *installed_pkg = NULL, *newer_available_pkg = NULL;
- gchar *location = NULL;
+ gchar *location = NULL, *series = NULL;
installed_pkg = slapt_get_newest_pkg(installed,all->pkgs[i]->name);
if (installed_pkg != NULL) {
@@ -588,12 +600,15 @@ void build_package_treeviewlist (GtkWidget *treeview)
location = all->pkgs[i]->location;
}
+ series = gslapt_series_map_lookup(gslapt_series_map, 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,all->pkgs[i]->name,
VERSION_COLUMN,all->pkgs[i]->version,
LOCATION_COLUMN,location,
+ SERIES_COLUMN,series,
DESC_COLUMN,short_desc,
SIZE_COLUMN,all->pkgs[i]->size_u,
STATUS_COLUMN,status,
@@ -638,6 +653,7 @@ void build_package_treeviewlist (GtkWidget *treeview)
NAME_COLUMN,installed->pkgs[i]->name,
VERSION_COLUMN,installed->pkgs[i]->version,
LOCATION_COLUMN,installed->pkgs[i]->location,
+ SERIES_COLUMN,installed->pkgs[i]->location,
DESC_COLUMN,short_desc,
SIZE_COLUMN,installed->pkgs[i]->size_u,
STATUS_COLUMN,status,
@@ -800,12 +816,11 @@ static void fillin_pkg_details (slapt_pkg_info_t *pkg)
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;
+ char *clean_desc = NULL, *changelog = NULL, *filelist = NULL, *location = NULL;
const char *priority_str = NULL;
/* set package details */
gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_name")),pkg->name);
- gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_location")),pkg->location);
gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_version")),pkg->version);
gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_source")),pkg->mirror);
short_desc = slapt_gen_short_pkg_description(pkg);
@@ -815,6 +830,13 @@ static void fillin_pkg_details (slapt_pkg_info_t *pkg)
} else {
gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_description")),"");
}
+ location = gslapt_series_map_lookup(gslapt_series_map, pkg->location);
+ if (location != NULL) {
+ gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_location")),location);
+ free(location);
+ } else {
+ gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_location")),pkg->location);
+ }
priority_str = slapt_priority_to_str(pkg->priority);
gtk_label_set_text(GTK_LABEL(lookup_widget(gslapt,"pkg_info_priority")),priority_str);
@@ -2863,11 +2885,11 @@ void build_treeview_columns (GtkWidget *treeview)
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
gtk_tree_view_column_set_resizable(column, TRUE);
- /* column for location */
+ /* column for series */
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes ((gchar *)_("Location"), renderer,
- "text", LOCATION_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id (column, LOCATION_COLUMN);
+ "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);
diff --git a/src/callbacks.h b/src/callbacks.h
index 44a26b4..66005b4 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -25,6 +25,7 @@ enum {
NAME_COLUMN,
VERSION_COLUMN,
LOCATION_COLUMN,
+ SERIES_COLUMN,
DESC_COLUMN,
SIZE_COLUMN,
STATUS_COLUMN,
diff --git a/src/main.c b/src/main.c
index 8ba943f..8e824e2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,6 +25,7 @@
#include "interface.h"
#include "support.h"
#include "settings.h"
+#include "series.h"
slapt_rc_config *global_config; /* our config struct */
struct slapt_pkg_list *installed;
@@ -33,6 +34,7 @@ GtkWidget *gslapt;
slapt_transaction_t *trans = NULL;
char rc_location[1024];
GslaptSettings *gslapt_settings = NULL;
+GHashTable *gslapt_series_map = NULL;
int main (int argc, char *argv[]) {
GtkStatusbar *bar;
@@ -59,6 +61,10 @@ int main (int argc, char *argv[]) {
trans = slapt_init_transaction();
+ /* series name mapping */
+ gslapt_series_map = gslapt_series_map_init();
+ gslapt_series_map_fill(gslapt_series_map);
+
add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
for (option_index = 1; option_index < argc; ++option_index) {
diff --git a/src/series.c b/src/series.c
new file mode 100644
index 0000000..665989c
--- /dev/null
+++ b/src/series.c
@@ -0,0 +1,83 @@
+#include "series.h"
+
+GHashTable *gslapt_series_map_init(void)
+{
+ GHashTable *map = g_hash_table_new(g_str_hash, g_str_equal);
+
+ return map;
+}
+
+void gslapt_series_map_free(GHashTable *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;
+
+ 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;
+ }
+
+ 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);
+
+ return 0;
+}
+
+char *gslapt_series_map_lookup(GHashTable *map, const char *key)
+{
+ char *value = NULL, *converted = NULL;
+ void *v = g_hash_table_lookup (map, key);
+ if (v != NULL) {
+ value = (char *)v;
+ } else {
+ value = g_path_get_basename(key);
+ }
+
+ converted = g_convert(value, strlen(value), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+ if (converted != NULL)
+ value = converted;
+
+ return value;
+}
+
diff --git a/src/series.h b/src/series.h
new file mode 100644
index 0000000..7a48124
--- /dev/null
+++ b/src/series.h
@@ -0,0 +1,14 @@
+#ifndef GSLAPT_SERIES_HEADER
+#define GSLAPT_SERIES_HEADER
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include "config.h"
+
+GHashTable *gslapt_series_map_init(void);
+void gslapt_series_map_free(GHashTable *map);
+int gslapt_series_map_fill(GHashTable *map);
+char *gslapt_series_map_lookup(GHashTable *map, const char *key);
+
+#endif