Commit 4b4e08ce authored by Paolo Borelli's avatar Paolo Borelli

app: use new G_DECLARE macros

parent b1642967
......@@ -150,8 +150,10 @@ ensure_window (GeditAppOSX *app,
@end
struct _GeditAppOSXPrivate
struct _GeditAppOSX
{
GeditApp parent_instance;
GeditMenuExtension *recent_files_menu;
gulong recent_manager_changed_id;
......@@ -161,40 +163,38 @@ struct _GeditAppOSXPrivate
GeditRecentConfiguration recent_config;
};
G_DEFINE_TYPE_WITH_PRIVATE (GeditAppOSX, gedit_app_osx, GEDIT_TYPE_APP)
G_DEFINE_TYPE (GeditAppOSX, gedit_app_osx, GEDIT_TYPE_APP)
static void
remove_recent_actions (GeditAppOSX *app)
{
GeditAppOSXPrivate *priv = app->priv;
while (priv->recent_actions)
while (app->recent_actions)
{
gchar *action_name = priv->recent_actions->data;
gchar *action_name = app->recent_actions->data;
g_action_map_remove_action (G_ACTION_MAP (app), action_name);
g_free (action_name);
priv->recent_actions = g_list_delete_link (priv->recent_actions, priv->recent_actions);
app->recent_actions = g_list_delete_link (app->recent_actions,
app->recent_actions);
}
}
static void
gedit_app_osx_finalize (GObject *object)
{
GeditAppOSX *app_osx;
GeditAppOSX *app = GEDIT_APP_OSX (object);
app_osx = GEDIT_APP_OSX (object);
g_object_unref (app_osx->priv->recent_files_menu);
g_object_unref (app->recent_files_menu);
remove_recent_actions (app_osx);
remove_recent_actions (app);
g_signal_handler_disconnect (app_osx->priv->recent_config.manager,
app_osx->priv->recent_manager_changed_id);
g_signal_handler_disconnect (app->recent_config.manager,
app->recent_manager_changed_id);
gedit_recent_configuration_destroy (&app_osx->priv->recent_config);
gedit_recent_configuration_destroy (&app->recent_config);
[app_osx->priv->app_delegate release];
[app->app_delegate release];
G_OBJECT_CLASS (gedit_app_osx_parent_class)->finalize (object);
}
......@@ -330,15 +330,15 @@ recent_file_activated (GAction *action,
}
static void
recent_files_menu_populate (GeditAppOSX *app_osx)
recent_files_menu_populate (GeditAppOSX *app)
{
GList *items;
gint i = 0;
gedit_menu_extension_remove_items (app_osx->priv->recent_files_menu);
remove_recent_actions (app_osx);
gedit_menu_extension_remove_items (app->recent_files_menu);
remove_recent_actions (app);
items = gedit_recent_get_items (&app_osx->priv->recent_config);
items = gedit_recent_get_items (&app->recent_config);
while (items)
{
......@@ -356,7 +356,7 @@ recent_files_menu_populate (GeditAppOSX *app_osx)
action = g_simple_action_new (acname, NULL);
finfo = g_slice_new (RecentFileInfo);
finfo->app = g_object_ref (app_osx);
finfo->app = g_object_ref (app);
finfo->info = gtk_recent_info_ref (info);
g_signal_connect_data (action,
......@@ -366,16 +366,15 @@ recent_files_menu_populate (GeditAppOSX *app_osx)
recent_file_info_free,
0);
g_action_map_add_action (G_ACTION_MAP (app_osx), G_ACTION (action));
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (action));
g_object_unref (action);
acfullname = g_strdup_printf ("app.%s", acname);
app_osx->priv->recent_actions = g_list_prepend (app_osx->priv->recent_actions,
acname);
app->recent_actions = g_list_prepend (app->recent_actions, acname);
mitem = g_menu_item_new (name, acfullname);
gedit_menu_extension_append_menu_item (app_osx->priv->recent_files_menu, mitem);
gedit_menu_extension_append_menu_item (app->recent_files_menu, mitem);
g_free (acfullname);
......@@ -388,9 +387,9 @@ recent_files_menu_populate (GeditAppOSX *app_osx)
static void
recent_manager_changed (GtkRecentManager *manager,
GeditAppOSX *app_osx)
GeditAppOSX *app)
{
recent_files_menu_populate (app_osx);
recent_files_menu_populate (app);
}
static void
......@@ -420,8 +419,6 @@ update_open_sensitivity (GeditAppOSX *app)
static void
gedit_app_osx_startup (GApplication *application)
{
GeditAppOSX *app_osx;
const gchar *replace_accels[] = {
"<Primary><Alt>F",
NULL
......@@ -437,10 +434,11 @@ gedit_app_osx_startup (GApplication *application)
NULL
};
GeditAppOSX *app = GEDIT_APP_OSX (application);
G_APPLICATION_CLASS (gedit_app_osx_parent_class)->startup (application);
app_osx = GEDIT_APP_OSX (application);
app_osx->priv->app_delegate = [[[GeditAppOSXDelegate alloc] initWithApp:app_osx] retain];
app->app_delegate = [[[GeditAppOSXDelegate alloc] initWithApp:app] retain];
g_action_map_add_action_entries (G_ACTION_MAP (application),
app_entries,
......@@ -459,21 +457,20 @@ gedit_app_osx_startup (GApplication *application)
"win.fullscreen",
fullscreen_accels);
gedit_recent_configuration_init_default (&app_osx->priv->recent_config);
gedit_recent_configuration_init_default (&app->recent_config);
app_osx->priv->recent_files_menu = _gedit_app_extend_menu (GEDIT_APP (application),
"recent-files-section");
app->recent_files_menu = _gedit_app_extend_menu (GEDIT_APP (application),
"recent-files-section");
app_osx->priv->recent_manager_changed_id =
g_signal_connect (app_osx->priv->recent_config.manager,
"changed",
G_CALLBACK (recent_manager_changed),
app_osx);
app->recent_manager_changed_id = g_signal_connect (app->recent_config.manager,
"changed",
G_CALLBACK (recent_manager_changed),
app);
recent_files_menu_populate (app_osx);
recent_files_menu_populate (app);
g_application_hold (application);
update_open_sensitivity (app_osx);
update_open_sensitivity (app);
}
static void
......@@ -589,8 +586,6 @@ gedit_app_osx_class_init (GeditAppOSXClass *klass)
static void
gedit_app_osx_init (GeditAppOSX *app)
{
app->priv = gedit_app_osx_get_instance_private (app);
/* This is required so that Cocoa is not going to parse the
command line arguments by itself and generate OpenFile events.
We already parse the command line ourselves, so this is needed
......
......@@ -27,40 +27,17 @@
G_BEGIN_DECLS
#define GEDIT_TYPE_APP_OSX (gedit_app_osx_get_type ())
#define GEDIT_APP_OSX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_OSX, GeditAppOSX))
#define GEDIT_APP_OSX_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_OSX, GeditAppOSX const))
#define GEDIT_APP_OSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_APP_OSX, GeditAppOSXClass))
#define GEDIT_IS_APP_OSX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_APP_OSX))
#define GEDIT_IS_APP_OSX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP_OSX))
#define GEDIT_APP_OSX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_APP_OSX, GeditAppOSXClass))
#define GEDIT_TYPE_APP_OSX (gedit_app_osx_get_type ())
typedef struct _GeditAppOSX GeditAppOSX;
typedef struct _GeditAppOSXClass GeditAppOSXClass;
typedef struct _GeditAppOSXPrivate GeditAppOSXPrivate;
G_DECLARE_FINAL_TYPE (GeditAppOSX, gedit_app_osx, GEDIT, APP_OSX, GeditApp)
struct _GeditAppOSX
{
GeditApp parent;
void gedit_app_osx_set_window_title (GeditAppOSX *app,
GeditWindow *window,
const gchar *title,
GeditDocument *document);
/*< private > */
GeditAppOSXPrivate *priv;
};
struct _GeditAppOSXClass
{
GeditAppClass parent_class;
};
GType gedit_app_osx_get_type (void) G_GNUC_CONST;
void gedit_app_osx_set_window_title (GeditAppOSX *app,
GeditWindow *window,
const gchar *title,
GeditDocument *document);
gboolean gedit_app_osx_show_url (GeditAppOSX *app,
const gchar *url);
gboolean gedit_app_osx_show_url (GeditAppOSX *app,
const gchar *url);
G_END_DECLS
......
......@@ -33,6 +33,10 @@
#define DATADIR SAVE_DATADIR
#undef SAVE_DATADIR
struct _GeditAppWin32
{
GeditApp parent_instance;
};
G_DEFINE_TYPE (GeditAppWin32, gedit_app_win32, GEDIT_TYPE_APP)
......
......@@ -27,29 +27,9 @@
G_BEGIN_DECLS
#define GEDIT_TYPE_APP_WIN32 (gedit_app_win32_get_type ())
#define GEDIT_APP_WIN32(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_WIN32, GeditAppWin32))
#define GEDIT_APP_WIN32_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_WIN32, GeditAppWin32 const))
#define GEDIT_APP_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_APP_WIN32, GeditAppWin32Class))
#define GEDIT_IS_APP_WIN32(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_APP_WIN32))
#define GEDIT_IS_APP_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP_WIN32))
#define GEDIT_APP_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_APP_WIN32, GeditAppWin32Class))
typedef struct _GeditAppWin32 GeditAppWin32;
typedef struct _GeditAppWin32Class GeditAppWin32Class;
typedef struct _GeditAppWin32Private GeditAppWin32Private;
struct _GeditAppWin32
{
GeditApp parent;
};
struct _GeditAppWin32Class
{
GeditAppClass parent_class;
};
GType gedit_app_win32_get_type (void) G_GNUC_CONST;
#define GEDIT_TYPE_APP_WIN32 (gedit_app_win32_get_type ())
G_DECLARE_FINAL_TYPE (GeditAppWin32, gedit_app_win32, GEDIT, APP_WIN32, GeditApp)
G_END_DECLS
......
......@@ -26,6 +26,11 @@
#include <gdk/gdkx.h>
#endif
struct _GeditAppX11
{
GeditApp parent_instance;
};
G_DEFINE_TYPE (GeditAppX11, gedit_app_x11, GEDIT_TYPE_APP)
/* This should go in GtkApplication at some point... */
......
......@@ -28,28 +28,8 @@
G_BEGIN_DECLS
#define GEDIT_TYPE_APP_X11 (gedit_app_x11_get_type ())
#define GEDIT_APP_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_X11, GeditAppX11))
#define GEDIT_APP_X11_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_X11, GeditAppX11 const))
#define GEDIT_APP_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_APP_X11, GeditAppX11Class))
#define GEDIT_IS_APP_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_APP_X11))
#define GEDIT_IS_APP_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP_X11))
#define GEDIT_APP_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_APP_X11, GeditAppX11Class))
typedef struct _GeditAppX11 GeditAppX11;
typedef struct _GeditAppX11Class GeditAppX11Class;
typedef struct _GeditAppX11Private GeditAppX11Private;
struct _GeditAppX11
{
GeditApp parent;
};
struct _GeditAppX11Class
{
GeditAppClass parent_class;
};
GType gedit_app_x11_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (GeditAppX11, gedit_app_x11, GEDIT, APP_X11, GeditApp)
G_END_DECLS
......
This diff is collapsed.
......@@ -28,52 +28,34 @@
G_BEGIN_DECLS
#define GEDIT_TYPE_APP (gedit_app_get_type())
#define GEDIT_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_APP, GeditApp))
#define GEDIT_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_APP, GeditAppClass))
#define GEDIT_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_APP))
#define GEDIT_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP))
#define GEDIT_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_APP, GeditAppClass))
typedef struct _GeditApp GeditApp;
typedef struct _GeditAppClass GeditAppClass;
typedef struct _GeditAppPrivate GeditAppPrivate;
struct _GeditApp
{
GtkApplication parent;
#define GEDIT_TYPE_APP (gedit_app_get_type())
/*< private > */
GeditAppPrivate *priv;
};
G_DECLARE_DERIVABLE_TYPE (GeditApp, gedit_app, GEDIT, APP, GtkApplication)
struct _GeditAppClass
{
GtkApplicationClass parent_class;
gboolean (*show_help) (GeditApp *app,
gboolean (*show_help) (GeditApp *app,
GtkWindow *parent,
const gchar *name,
const gchar *link_id);
gchar *(*help_link_id) (GeditApp *app,
gchar *(*help_link_id) (GeditApp *app,
const gchar *name,
const gchar *link_id);
void (*set_window_title) (GeditApp *app,
void (*set_window_title) (GeditApp *app,
GeditWindow *window,
const gchar *title);
GeditWindow *(*create_window) (GeditApp *app);
GeditWindow *(*create_window) (GeditApp *app);
gboolean (*process_window_event) (GeditApp *app,
GeditWindow *window,
GdkEvent *event);
gboolean (*process_window_event) (GeditApp *app,
GeditWindow *window,
GdkEvent *event);
};
/*
* Lockdown mask definition
*/
typedef enum
{
GEDIT_LOCKDOWN_COMMAND_LINE = 1 << 0,
......@@ -85,9 +67,6 @@ typedef enum
/* We need to define this here to avoid problems with bindings and gsettings */
#define GEDIT_LOCKDOWN_ALL 0xF
/* Public methods */
GType gedit_app_get_type (void) G_GNUC_CONST;
GeditWindow *gedit_app_create_window (GeditApp *app,
GdkScreen *screen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment