summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2010-01-13 15:59:18 +0000
committerJason Woodward2010-01-13 15:59:18 +0000
commit8ecb9616db7b29b6214c708e4d76448b59bfbddc (patch)
tree682a061282f4dc8e19eb18c5fa6bf3b43fdaa1cf
parentbcb4c16b68c29768858523978a277ddfc4c156e5 (diff)
downloadgslapt-8ecb9616db7b29b6214c708e4d76448b59bfbddc.tar.gz
also save/restore the position and size of the preferences and changelog windows
-rw-r--r--src/callbacks.c46
-rw-r--r--src/callbacks.h1
-rw-r--r--src/interface.c9
-rw-r--r--src/main.c13
-rw-r--r--src/settings.c40
-rw-r--r--src/settings.h2
6 files changed, 89 insertions, 22 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index b173b48..df5d7a5 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -96,6 +96,38 @@ 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_widget_get_name(GTK_WIDGET(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 {
+ fprintf(stderr, "need to handle widget name: %s\n", widget_name);
+ }
+
+ return FALSE;
+}
+
void on_gslapt_destroy (GtkObject *object, gpointer user_data)
{
slapt_free_transaction(trans);
@@ -160,6 +192,13 @@ void open_preferences (GtkMenuItem *menuitem, gpointer user_data)
preferences = (GtkWidget *)create_window_preferences();
+ 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(lookup_widget(preferences,"preferences_working_dir_entry"));
gtk_entry_set_text(working_dir,global_config->working_dir);
@@ -3737,6 +3776,13 @@ void view_changelogs (GtkMenuItem *menuitem, gpointer user_data)
GtkWidget *changelog_window = create_changelog_window();
GtkWidget *changelog_notebook = lookup_widget(changelog_window, "changelog_notebook");
+ 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);
+ }
+
for (i = 0; i < global_config->sources->count; ++i) {
char *changelog_filename, *changelog_data;
gchar *source_url, *path_and_file, *changelog_txt;
diff --git a/src/callbacks.h b/src/callbacks.h
index e4bb6ba..44a26b4 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -35,6 +35,7 @@ enum {
NUMBER_OF_COLUMNS
};
+gboolean gslapt_window_resized(GtkWindow *window, GdkEvent *event, gpointer data);
void on_gslapt_destroy (GtkObject *object, gpointer user_data);
void update_callback (GtkObject *object, gpointer user_data);
void upgrade_callback (GtkObject *object, gpointer user_data);
diff --git a/src/interface.c b/src/interface.c
index f209d84..4ea63af 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -421,6 +421,9 @@ create_window_preferences (void)
g_signal_connect ((gpointer) button7, "clicked",
G_CALLBACK (clean_callback),
NULL);
+ g_signal_connect ((gpointer) window_preferences, "configure-event",
+ G_CALLBACK (gslapt_window_resized),
+ NULL);
g_signal_connect_swapped ((gpointer) preferences_remove_exclude_button, "clicked",
G_CALLBACK (preferences_exclude_remove),
GTK_OBJECT (window_preferences));
@@ -1501,6 +1504,9 @@ create_gslapt (void)
g_signal_connect ((gpointer) gslapt, "destroy",
G_CALLBACK (on_gslapt_destroy),
NULL);
+ g_signal_connect ((gpointer) gslapt, "configure-event",
+ G_CALLBACK (gslapt_window_resized),
+ NULL);
g_signal_connect ((gpointer) update1, "activate",
G_CALLBACK (update_activate),
NULL);
@@ -2903,6 +2909,9 @@ create_changelog_window (void)
g_signal_connect ((gpointer) changelog_window, "destroy_event",
G_CALLBACK (gtk_widget_destroy),
NULL);
+ g_signal_connect ((gpointer) changelog_window, "configure-event",
+ G_CALLBACK (gslapt_window_resized),
+ NULL);
g_signal_connect_swapped ((gpointer) button12, "clicked",
G_CALLBACK (gtk_widget_destroy),
GTK_OBJECT (changelog_window));
diff --git a/src/main.c b/src/main.c
index d97b139..8ba943f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,15 +34,6 @@ slapt_transaction_t *trans = NULL;
char rc_location[1024];
GslaptSettings *gslapt_settings = NULL;
-static gboolean gslapt_resized(GtkWindow *window, GdkEvent *event, gpointer data)
-{
- gslapt_settings->x = event->configure.x;
- gslapt_settings->y = event->configure.y;
- gslapt_settings->width = event->configure.width;
- gslapt_settings->height = event->configure.height;
- return FALSE;
-}
-
int main (int argc, char *argv[]) {
GtkStatusbar *bar;
guint default_context_id;
@@ -185,10 +176,6 @@ int main (int argc, char *argv[]) {
gtk_widget_set_sensitive(lookup_widget(gslapt,"execute1"),FALSE);
gtk_widget_set_sensitive(lookup_widget(gslapt,"unmark_all1"),FALSE);
- gtk_widget_add_events(gslapt, GDK_CONFIGURE);
- g_signal_connect(G_OBJECT(gslapt), "configure-event",
- G_CALLBACK(gslapt_resized), NULL);
-
/* restore previous rc settings */
gslapt_settings = gslapt_read_rc();
if (gslapt_settings == NULL) {
diff --git a/src/settings.c b/src/settings.c
index 5199f3d..687a43f 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -17,7 +17,9 @@ char *gslapt_init_rc_dir (void)
GslaptSettings *gslapt_new_rc (void)
{
GslaptSettings *g = g_slice_new(GslaptSettings);
- g->x = g->y = g->width = g->height = 0;
+ 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;
return g;
}
@@ -64,10 +66,20 @@ GslaptSettings *gslapt_read_rc (void)
goto GSLAPT_READ_CONFIG_END;
}
- gslapt_settings->x = g_key_file_get_integer (keyfile, "window", "x", NULL);
- gslapt_settings->y = g_key_file_get_integer (keyfile, "window", "y", NULL);
- gslapt_settings->width = g_key_file_get_integer (keyfile, "window", "width", NULL);
- gslapt_settings->height = g_key_file_get_integer (keyfile, "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->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->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);
@@ -100,10 +112,20 @@ int gslapt_write_rc(GslaptSettings *gslapt_settings)
keyfile = g_key_file_new();
- g_key_file_set_integer (keyfile, "window", "x", gslapt_settings->x);
- g_key_file_set_integer (keyfile, "window", "y", gslapt_settings->y);
- g_key_file_set_integer (keyfile, "window", "width", gslapt_settings->width);
- g_key_file_set_integer (keyfile, "window", "height", gslapt_settings->height);
+ 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);
rc_data = g_key_file_to_data(keyfile, &length, NULL);
if (length != 0) {
diff --git a/src/settings.h b/src/settings.h
index 33c96a5..ada847b 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -8,6 +8,8 @@
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;
} GslaptSettings;
char *gslapt_init_rc_dir (void);