[Xfce4-commits] r23755 - in xarchiver/branches/xarchiver-psybsd: libxarchiver src
Stephan Arts
stephan at xfce.org
Mon Nov 6 10:25:13 CET 2006
Author: stephan
Date: 2006-11-06 09:25:13 +0000 (Mon, 06 Nov 2006)
New Revision: 23755
Added:
xarchiver/branches/xarchiver-psybsd/src/application.c
xarchiver/branches/xarchiver-psybsd/src/application.h
Modified:
xarchiver/branches/xarchiver-psybsd/libxarchiver/internals.c
xarchiver/branches/xarchiver-psybsd/src/Makefile.am
xarchiver/branches/xarchiver-psybsd/src/main_window.c
xarchiver/branches/xarchiver-psybsd/src/main_window.h
xarchiver/branches/xarchiver-psybsd/src/notebook.c
xarchiver/branches/xarchiver-psybsd/src/notebook.h
xarchiver/branches/xarchiver-psybsd/src/settings.c
Log:
added 'application' class.
made settings object a singleton.
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/internals.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/internals.c 2006-11-06 09:16:58 UTC (rev 23754)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/internals.c 2006-11-06 09:25:13 UTC (rev 23755)
@@ -165,7 +165,5 @@
_filenames = _filenames->next;
LXA_FREE(_concat_str);
}
- if(!filenames)
- return NULL;
return concat_str;
}
Modified: xarchiver/branches/xarchiver-psybsd/src/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/Makefile.am 2006-11-06 09:16:58 UTC (rev 23754)
+++ xarchiver/branches/xarchiver-psybsd/src/Makefile.am 2006-11-06 09:25:13 UTC (rev 23755)
@@ -15,6 +15,7 @@
xarchiver_SOURCES = \
main.c main.h \
+ application.c application.h \
main_window.c main_window.h \
navigation_bar.c navigation_bar.h \
notebook.c notebook.h \
Added: xarchiver/branches/xarchiver-psybsd/src/application.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/application.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/src/application.c 2006-11-06 09:25:13 UTC (rev 23755)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psybsd at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libxarchiver/libxarchiver.h>
+#include "settings.h"
+#include "archive_store.h"
+#include "navigation_bar.h"
+#include "main_window.h"
+#include "application.h"
+
+static void
+xa_application_class_init(XAApplicationClass *archive_class);
+
+static void
+xa_application_init(XAApplication *archive);
+static void
+xa_application_finalize(GObject *object);
+
+/* properties */
+enum {
+ XA_APPLICATION_NAV_HISTORY = 1
+};
+
+GType
+xa_application_get_type ()
+{
+ static GType xa_application_type = 0;
+
+ if (!xa_application_type)
+ {
+ static const GTypeInfo xa_application_info =
+ {
+ sizeof (XAApplicationClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) xa_application_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (XAApplication),
+ 0,
+ (GInstanceInitFunc) xa_application_init,
+ NULL
+ };
+
+ xa_application_type = g_type_register_static (GTK_TYPE_CONTAINER, "XAApplication", &xa_application_info, 0);
+ }
+ return xa_application_type;
+}
+
+static void
+xa_application_class_init(XAApplicationClass *application_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (application_class);
+ object_class->finalize = xa_application_finalize;
+}
+
+static void
+xa_application_init(XAApplication *application)
+{
+}
+
+static void
+xa_application_finalize(GObject *object)
+{
+}
+
+XAApplication *
+xa_application_new(GtkIconTheme *icon_theme)
+{
+ XAApplication *app;
+
+ app = g_object_new(XA_TYPE_APPLICATION, NULL);
+
+ app->icon_theme = icon_theme;
+
+ return app;
+}
+
+GtkWidget *
+xa_application_new_window(XAApplication *app)
+{
+ return xa_main_window_new(app->icon_theme);
+}
Added: xarchiver/branches/xarchiver-psybsd/src/application.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/application.h (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/src/application.h 2006-11-06 09:25:13 UTC (rev 23755)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psybsd at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XARCHIVER_APPLICATION_H__
+#define __XARCHIVER_APPLICATION_H__
+G_BEGIN_DECLS
+
+#define XA_TYPE_APPLICATION xa_application_get_type()
+
+#define XA_APPLICATION(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ XA_TYPE_APPLICATION, \
+ XAApplication))
+
+#define XA_IS_APPLICATION(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ XA_TYPE_APPLICATION))
+
+#define XA_APPLICATION_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ XA_TYPE_APPLICATION, \
+ XAApplicationClass))
+
+#define XA_IS_APPLICATION_CLASS(class) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ XA_TYPE_APPLICATION()))
+
+typedef struct _XAApplication XAApplication;
+
+struct _XAApplication
+{
+ GObject parent;
+ GtkIconTheme *icon_theme;
+ XASettings *settings;
+};
+
+typedef struct _XAApplicationClass XAApplicationClass;
+
+struct _XAApplicationClass
+{
+ GObjectClass parent_class;
+};
+
+GType xa_application_get_type();
+XAApplication *xa_application_new(GtkIconTheme *icon_theme);
+
+GtkWidget *xa_application_new_window(XAApplication *);
+
+G_END_DECLS
+#endif /* __XARCHIVER_APPLICATION_H__*/
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-11-06 09:16:58 UTC (rev 23754)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-11-06 09:25:13 UTC (rev 23755)
@@ -67,7 +67,7 @@
static void
cb_xa_main_window_notebook_page_switched(XANotebook *notebook, GtkNotebookPage *page, guint page_nr, gpointer data);
static void
-cb_xa_main_window_notebook_page_removed(XANotebook *notebook, GtkNotebookPage *page, guint page_nr, gpointer data);
+cb_xa_main_window_notebook_page_removed(XANotebook *notebook, gpointer data);
GType
@@ -236,7 +236,7 @@
/* main view */
window->notebook = xa_notebook_new(window->navigationbar);
g_signal_connect(G_OBJECT(window->notebook), "switch-page", G_CALLBACK(cb_xa_main_window_notebook_page_switched), window);
- g_signal_connect(G_OBJECT(window->notebook), "page-removed", G_CALLBACK(cb_xa_main_window_notebook_page_removed), window);
+ g_signal_connect(G_OBJECT(window->notebook), "archive-removed", G_CALLBACK(cb_xa_main_window_notebook_page_removed), window);
/* Statusbar */
window->statusbar = gtk_statusbar_new();
@@ -360,8 +360,6 @@
GtkWidget *dialog = NULL;
gchar *open_archive_path = NULL;
gint result = 0;
- LXAArchive *archive = NULL;
- LXAArchiveSupport *support = NULL;
XAMainWindow *window = XA_MAIN_WINDOW(userdata);
dialog = gtk_file_chooser_dialog_new(_("Open archive"),
@@ -378,11 +376,10 @@
if(result == GTK_RESPONSE_OK)
{
open_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
- if(!lxa_open_archive(open_archive_path, &archive))
- {
- support = lxa_get_support_for_mime(lxa_mime_info_get_name(archive->mime_info));
- xa_notebook_add_archive(XA_NOTEBOOK(window->notebook), archive, support);
- }
+ if(xa_notebook_get_multi_tab(XA_NOTEBOOK(window->notebook)))
+ xa_main_window_open_archive(window, open_archive_path, -1);
+ else
+ xa_main_window_open_archive(window, open_archive_path, 0);
gtk_widget_destroy(dialog);
}
}
@@ -462,7 +459,7 @@
}
static void
-cb_xa_main_window_notebook_page_removed(XANotebook *notebook, GtkNotebookPage *page, guint page_nr, gpointer data)
+cb_xa_main_window_notebook_page_removed(XANotebook *notebook, gpointer data)
{
XAMainWindow *window = XA_MAIN_WINDOW(data);
@@ -474,3 +471,20 @@
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_stop), FALSE);
}
}
+
+gint
+xa_main_window_open_archive(XAMainWindow *window, gchar *path, gint replace)
+{
+ LXAArchive *archive = NULL;
+ LXAArchiveSupport *support = NULL;
+
+ if(!lxa_open_archive(path, &archive))
+ {
+ support = lxa_get_support_for_mime(lxa_mime_info_get_name(archive->mime_info));
+ if(replace < 0)
+ xa_notebook_add_archive(XA_NOTEBOOK(window->notebook), archive, support);
+ /* else */
+ return 0;
+ }
+ return 1;
+}
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-11-06 09:16:58 UTC (rev 23754)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-11-06 09:25:13 UTC (rev 23755)
@@ -110,6 +110,8 @@
GtkWidget *xa_main_window_find_image(gchar *, GtkIconSize);
GType xa_main_window_get_type ();
+gint xa_main_window_open_archive(XAMainWindow *window, gchar *path, gint replace);
+
G_END_DECLS
#endif /* __XARCHIVER_MAIN_WINDOW_H__ */
Modified: xarchiver/branches/xarchiver-psybsd/src/notebook.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/notebook.c 2006-11-06 09:16:58 UTC (rev 23754)
+++ xarchiver/branches/xarchiver-psybsd/src/notebook.c 2006-11-06 09:25:13 UTC (rev 23755)
@@ -53,12 +53,14 @@
static void
cb_xa_notebook_page_switched(XANotebook *notebook, GtkNotebookPage *, guint page_nr, gpointer data);
static void
-cb_xa_notebook_page_removed(XANotebook *notebook, GtkNotebookPage *page, guint page_nr, gpointer data);
+cb_xa_notebook_page_removed(XANotebook *notebook, gpointer data);
enum {
XA_NOTEBOOK_MULTI_TAB = 1
};
+static gint xa_notebook_signals[2];
+
GType
xa_notebook_get_type ()
{
@@ -95,6 +97,17 @@
object_class->get_property = xa_notebook_get_property;
object_class->finalize = xa_notebook_finalize;
+ xa_notebook_signals[0] = g_signal_new("archive-removed",
+ G_TYPE_FROM_CLASS(notebook_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
pspec = g_param_spec_boolean("multi_tab",
"",
"",
@@ -108,7 +121,7 @@
xa_notebook_init(XANotebook *notebook)
{
g_signal_connect(G_OBJECT(notebook), "switch-page", G_CALLBACK(cb_xa_notebook_page_switched), NULL);
- g_signal_connect(G_OBJECT(notebook), "page-removed", G_CALLBACK(cb_xa_notebook_page_removed), NULL);
+ g_signal_connect(G_OBJECT(notebook), "archive-removed", G_CALLBACK(cb_xa_notebook_page_removed), NULL);
notebook->tool_tips = gtk_tooltips_new();
gtk_tooltips_enable(notebook->tool_tips);
gtk_notebook_set_tab_border(GTK_NOTEBOOK(notebook), 0);
@@ -137,6 +150,7 @@
}
notebook->props._show_icons = TRUE;
+ notebook->multi_tab = TRUE;
return (GtkWidget *)notebook;
}
@@ -163,6 +177,12 @@
}
}
+gboolean
+xa_notebook_get_multi_tab(XANotebook *notebook)
+{
+ return notebook->multi_tab;
+}
+
void
xa_notebook_set_navigation_bar(XANotebook *notebook, XANavigationBar *bar)
{
@@ -226,6 +246,7 @@
gint n = gtk_notebook_page_num(notebook, GTK_WIDGET(treeview));
gtk_notebook_remove_page(notebook, n);
+ g_signal_emit(G_OBJECT(notebook), xa_notebook_signals[0], 0, notebook);
}
void
@@ -316,7 +337,7 @@
}
static void
-cb_xa_notebook_page_removed(XANotebook *notebook, GtkNotebookPage *page, guint page_nr, gpointer data)
+cb_xa_notebook_page_removed(XANotebook *notebook, gpointer data)
{
if(!gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)))
xa_navigation_bar_set_store(notebook->navigation_bar, NULL);
@@ -341,3 +362,13 @@
return gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), n);
}
+
+void
+xa_notebook_page_set_archive(XANotebook *notebook, LXAArchive *archive, LXAArchiveSupport *support, gint n)
+{
+ GtkWidget *treeview = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), n);
+ GtkTreeModel *store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
+
+ xa_archive_store_set_archive(XA_ARCHIVE_STORE(store), archive);
+ xa_archive_store_set_support(XA_ARCHIVE_STORE(store), support);
+}
Modified: xarchiver/branches/xarchiver-psybsd/src/notebook.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/notebook.h 2006-11-06 09:16:58 UTC (rev 23754)
+++ xarchiver/branches/xarchiver-psybsd/src/notebook.h 2006-11-06 09:25:13 UTC (rev 23755)
@@ -68,9 +68,11 @@
void xa_notebook_set_navigation_bar(XANotebook *, XANavigationBar *);
void xa_notebook_add_archive(XANotebook *, LXAArchive *, LXAArchiveSupport *);
+void xa_notebook_page_set_archive(XANotebook *, LXAArchive *, LXAArchiveSupport *, gint n);
void xa_notebook_set_icon_theme(XANotebook *, GtkIconTheme *);
void xa_notebook_get_active_archive(XANotebook *, LXAArchive **, LXAArchiveSupport **);
GtkWidget * xa_notebook_get_active_child(XANotebook *notebook);
+gboolean xa_notebook_get_multi_tab(XANotebook *notebook);
G_END_DECLS
#endif /* __XARCHIVER_NOTEBOOK_H__ */
Modified: xarchiver/branches/xarchiver-psybsd/src/settings.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/settings.c 2006-11-06 09:16:58 UTC (rev 23754)
+++ xarchiver/branches/xarchiver-psybsd/src/settings.c 2006-11-06 09:25:13 UTC (rev 23755)
@@ -25,6 +25,8 @@
#include "settings.h"
+static XASettings *xa_global_settings = NULL;
+
static void
xa_settings_init(XASettings *);
static void
@@ -75,9 +77,10 @@
XASettings *
xa_settings_new()
{
- XASettings *object = g_object_new(XA_TYPE_SETTINGS, NULL);
+ if(!xa_global_settings)
+ xa_global_settings = g_object_new(XA_TYPE_SETTINGS, NULL);
- return object;
+ return xa_global_settings;
}
gboolean
More information about the Xfce4-commits
mailing list