xed-app: Clean up code styling
This commit is contained in:
parent
7417c54a94
commit
fb84d4bfc7
100
xed/xed-app.c
100
xed/xed-app.c
|
@ -75,9 +75,14 @@ xed_app_finalize (GObject *object)
|
|||
g_list_free (app->priv->windows);
|
||||
|
||||
if (app->priv->page_setup)
|
||||
{
|
||||
g_object_unref (app->priv->page_setup);
|
||||
}
|
||||
|
||||
if (app->priv->print_settings)
|
||||
{
|
||||
g_object_unref (app->priv->print_settings);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_app_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -173,9 +178,7 @@ get_page_setup_file (void)
|
|||
|
||||
if (config_dir != NULL)
|
||||
{
|
||||
setup = g_build_filename (config_dir,
|
||||
XED_PAGE_SETUP_FILE,
|
||||
NULL);
|
||||
setup = g_build_filename (config_dir, XED_PAGE_SETUP_FILE, NULL);
|
||||
g_free (config_dir);
|
||||
}
|
||||
|
||||
|
@ -192,13 +195,11 @@ load_page_setup (XedApp *app)
|
|||
|
||||
filename = get_page_setup_file ();
|
||||
|
||||
app->priv->page_setup = gtk_page_setup_new_from_file (filename,
|
||||
&error);
|
||||
app->priv->page_setup = gtk_page_setup_new_from_file (filename, &error);
|
||||
if (error)
|
||||
{
|
||||
/* Ignore file not found error */
|
||||
if (error->domain != G_FILE_ERROR ||
|
||||
error->code != G_FILE_ERROR_NOENT)
|
||||
if (error->domain != G_FILE_ERROR || error->code != G_FILE_ERROR_NOENT)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
}
|
||||
|
@ -210,8 +211,10 @@ load_page_setup (XedApp *app)
|
|||
|
||||
/* fall back to default settings */
|
||||
if (app->priv->page_setup == NULL)
|
||||
{
|
||||
app->priv->page_setup = gtk_page_setup_new ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
save_page_setup (XedApp *app)
|
||||
|
@ -220,13 +223,13 @@ save_page_setup (XedApp *app)
|
|||
GError *error = NULL;
|
||||
|
||||
if (app->priv->page_setup == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
filename = get_page_setup_file ();
|
||||
|
||||
gtk_page_setup_to_file (app->priv->page_setup,
|
||||
filename,
|
||||
&error);
|
||||
gtk_page_setup_to_file (app->priv->page_setup, filename, &error);
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
|
@ -246,9 +249,7 @@ get_print_settings_file (void)
|
|||
|
||||
if (config_dir != NULL)
|
||||
{
|
||||
settings = g_build_filename (config_dir,
|
||||
XED_PRINT_SETTINGS_FILE,
|
||||
NULL);
|
||||
settings = g_build_filename (config_dir, XED_PRINT_SETTINGS_FILE, NULL);
|
||||
g_free (config_dir);
|
||||
}
|
||||
|
||||
|
@ -265,13 +266,11 @@ load_print_settings (XedApp *app)
|
|||
|
||||
filename = get_print_settings_file ();
|
||||
|
||||
app->priv->print_settings = gtk_print_settings_new_from_file (filename,
|
||||
&error);
|
||||
app->priv->print_settings = gtk_print_settings_new_from_file (filename, &error);
|
||||
if (error)
|
||||
{
|
||||
/* Ignore file not found error */
|
||||
if (error->domain != G_FILE_ERROR ||
|
||||
error->code != G_FILE_ERROR_NOENT)
|
||||
if (error->domain != G_FILE_ERROR || error->code != G_FILE_ERROR_NOENT)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
}
|
||||
|
@ -283,8 +282,10 @@ load_print_settings (XedApp *app)
|
|||
|
||||
/* fall back to default settings */
|
||||
if (app->priv->print_settings == NULL)
|
||||
{
|
||||
app->priv->print_settings = gtk_print_settings_new ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
save_print_settings (XedApp *app)
|
||||
|
@ -293,13 +294,13 @@ save_print_settings (XedApp *app)
|
|||
GError *error = NULL;
|
||||
|
||||
if (app->priv->print_settings == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
filename = get_print_settings_file ();
|
||||
|
||||
gtk_print_settings_to_file (app->priv->print_settings,
|
||||
filename,
|
||||
&error);
|
||||
gtk_print_settings_to_file (app->priv->print_settings, filename, &error);
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
|
@ -342,11 +343,8 @@ xed_app_get_default (void)
|
|||
|
||||
app = XED_APP (g_object_new (XED_TYPE_APP, NULL));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (app),
|
||||
(gpointer) &app);
|
||||
g_object_weak_ref (G_OBJECT (app),
|
||||
app_weak_notify,
|
||||
NULL);
|
||||
g_object_add_weak_pointer (G_OBJECT (app), (gpointer) &app);
|
||||
g_object_weak_ref (G_OBJECT (app), app_weak_notify, NULL);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
@ -384,7 +382,9 @@ window_delete_event (XedWindow *window,
|
|||
(XED_WINDOW_STATE_SAVING |
|
||||
XED_WINDOW_STATE_PRINTING |
|
||||
XED_WINDOW_STATE_SAVING_SESSION))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_xed_cmd_file_quit (NULL, window);
|
||||
|
||||
|
@ -468,8 +468,7 @@ xed_app_create_window_real (XedApp *app,
|
|||
window = g_object_new (XED_TYPE_WINDOW, NULL);
|
||||
}
|
||||
|
||||
app->priv->windows = g_list_prepend (app->priv->windows,
|
||||
window);
|
||||
app->priv->windows = g_list_prepend (app->priv->windows, window);
|
||||
|
||||
xed_debug_message (DEBUG_APP, "Window created");
|
||||
|
||||
|
@ -507,23 +506,18 @@ xed_app_create_window_real (XedApp *app,
|
|||
}
|
||||
|
||||
if ((state & GDK_WINDOW_STATE_STICKY ) != 0)
|
||||
{
|
||||
gtk_window_stick (GTK_WINDOW (window));
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_window_unstick (GTK_WINDOW (window));
|
||||
}
|
||||
}
|
||||
|
||||
g_signal_connect (window,
|
||||
"focus_in_event",
|
||||
G_CALLBACK (window_focus_in_event),
|
||||
app);
|
||||
g_signal_connect (window,
|
||||
"delete_event",
|
||||
G_CALLBACK (window_delete_event),
|
||||
app);
|
||||
g_signal_connect (window,
|
||||
"destroy",
|
||||
G_CALLBACK (window_destroy),
|
||||
app);
|
||||
g_signal_connect (window, "focus_in_event", G_CALLBACK (window_focus_in_event), app);
|
||||
g_signal_connect (window, "delete_event", G_CALLBACK (window_delete_event), app);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (window_destroy), app);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
@ -546,7 +540,9 @@ xed_app_create_window (XedApp *app,
|
|||
window = xed_app_create_window_real (app, TRUE, NULL);
|
||||
|
||||
if (screen != NULL)
|
||||
{
|
||||
gtk_window_set_screen (GTK_WINDOW (window), screen);
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
@ -602,7 +598,9 @@ xed_app_get_active_window (XedApp *app)
|
|||
* first one shows its window.
|
||||
*/
|
||||
if (!gtk_widget_get_realized (GTK_WIDGET (app->priv->active_window)))
|
||||
{
|
||||
gtk_widget_realize (GTK_WIDGET (app->priv->active_window));
|
||||
}
|
||||
|
||||
return app->priv->active_window;
|
||||
}
|
||||
|
@ -637,12 +635,16 @@ is_in_viewport (XedWindow *window,
|
|||
n = gdk_screen_get_number (s);
|
||||
|
||||
if (strcmp (cur_name, name) != 0 || cur_n != n)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check for workspace match */
|
||||
ws = xed_utils_get_window_workspace (GTK_WINDOW (window));
|
||||
if (ws != workspace && ws != XED_ALL_WORKSPACES)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check for viewport match */
|
||||
gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
|
||||
|
@ -697,7 +699,9 @@ _xed_app_get_window_in_viewport (XedApp *app,
|
|||
g_return_val_if_fail (XED_IS_WINDOW (window), NULL);
|
||||
|
||||
if (is_in_viewport (window, screen, workspace, viewport_x, viewport_y))
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
/* otherwise try to see if there is a window on this workspace */
|
||||
for (l = app->priv->windows; l != NULL; l = l->next)
|
||||
|
@ -705,8 +709,10 @@ _xed_app_get_window_in_viewport (XedApp *app,
|
|||
window = l->data;
|
||||
|
||||
if (is_in_viewport (window, screen, workspace, viewport_x, viewport_y))
|
||||
{
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
||||
/* no window on this workspace... create a new one */
|
||||
return xed_app_create_window (app, screen);
|
||||
|
@ -733,9 +739,7 @@ xed_app_get_documents (XedApp *app)
|
|||
|
||||
while (windows != NULL)
|
||||
{
|
||||
res = g_list_concat (res,
|
||||
xed_window_get_documents (XED_WINDOW (windows->data)));
|
||||
|
||||
res = g_list_concat (res, xed_window_get_documents (XED_WINDOW (windows->data)));
|
||||
windows = g_list_next (windows);
|
||||
}
|
||||
|
||||
|
@ -763,9 +767,7 @@ xed_app_get_views (XedApp *app)
|
|||
|
||||
while (windows != NULL)
|
||||
{
|
||||
res = g_list_concat (res,
|
||||
xed_window_get_views (XED_WINDOW (windows->data)));
|
||||
|
||||
res = g_list_concat (res, xed_window_get_views (XED_WINDOW (windows->data)));
|
||||
windows = g_list_next (windows);
|
||||
}
|
||||
|
||||
|
@ -779,7 +781,9 @@ _xed_app_get_default_page_setup (XedApp *app)
|
|||
g_return_val_if_fail (XED_IS_APP (app), NULL);
|
||||
|
||||
if (app->priv->page_setup == NULL)
|
||||
{
|
||||
load_page_setup (app);
|
||||
}
|
||||
|
||||
return gtk_page_setup_copy (app->priv->page_setup);
|
||||
}
|
||||
|
@ -792,7 +796,9 @@ _xed_app_set_default_page_setup (XedApp *app,
|
|||
g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
|
||||
|
||||
if (app->priv->page_setup != NULL)
|
||||
{
|
||||
g_object_unref (app->priv->page_setup);
|
||||
}
|
||||
|
||||
app->priv->page_setup = g_object_ref (page_setup);
|
||||
}
|
||||
|
@ -804,7 +810,9 @@ _xed_app_get_default_print_settings (XedApp *app)
|
|||
g_return_val_if_fail (XED_IS_APP (app), NULL);
|
||||
|
||||
if (app->priv->print_settings == NULL)
|
||||
{
|
||||
load_print_settings (app);
|
||||
}
|
||||
|
||||
return gtk_print_settings_copy (app->priv->print_settings);
|
||||
}
|
||||
|
@ -817,7 +825,9 @@ _xed_app_set_default_print_settings (XedApp *app,
|
|||
g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
|
||||
|
||||
if (app->priv->print_settings != NULL)
|
||||
{
|
||||
g_object_unref (app->priv->print_settings);
|
||||
}
|
||||
|
||||
app->priv->print_settings = g_object_ref (settings);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue