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