Code beautification

Truncate long lines. This is not finished yet, though!
This commit is contained in:
Gergely Polonkai 2014-07-10 23:47:39 +02:00
parent 6632e200a9
commit 4db1ecff96
4 changed files with 351 additions and 71 deletions

View File

@ -19,7 +19,10 @@ ag_app_peek_first_window(AgApp *app)
{
GList *l;
for (l = gtk_application_get_windows(GTK_APPLICATION(app)); l; l = g_list_next(l)) {
for (
l = gtk_application_get_windows(GTK_APPLICATION(app));
l;
l = g_list_next(l)) {
if (GTK_IS_WINDOW(l->data)) {
return GTK_WINDOW(l->data);
}
@ -89,14 +92,20 @@ about_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
const gchar **documentors = NULL;
const gchar *translator_credits = _("translator_credits");
/* i18n: Please don't translate "Astrognome" (it's marked as translatable for transliteration only */
/* i18n: Please don't translate "Astrognome" (it's marked as translatable
* for transliteration only */
gtk_show_about_dialog(NULL,
"name", _("Astrognome"),
"version", PACKAGE_VERSION,
"comments", _("Astrologers' software for GNOME"),
"authors", authors,
"documentors", documentors,
"translator_credits", ((strcmp(translator_credits, "translator_credits") != 0) ? translator_credits : NULL),
"translator_credits", ((strcmp(
translator_credits,
"translator_credits"
) != 0)
? translator_credits
: NULL),
"website", PACKAGE_URL,
"website-label", _("Astrognome Website"),
"logo-icon-name", PACKAGE_TARNAME,
@ -109,7 +118,10 @@ quit_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
GList *l;
while ((l = gtk_application_get_windows(GTK_APPLICATION(user_data)))) {
gtk_application_remove_window(GTK_APPLICATION(user_data), GTK_WINDOW(l->data));
gtk_application_remove_window(
GTK_APPLICATION(user_data),
GTK_WINDOW(l->data)
);
}
}
@ -213,7 +225,14 @@ show_help(const gchar *topic, GtkWindow *parent)
if (!gtk_show_uri(screen, uri, gtk_get_current_event_time(), &err)) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new(parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Unable to display help: %s", err->message);
dialog = gtk_message_dialog_new(
parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
"Unable to display help: %s",
err->message
);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
@ -240,19 +259,59 @@ static GActionEntry app_entries[] = {
static void
setup_actions(AgApp *app)
{
g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries, G_N_ELEMENTS(app_entries), app);
g_action_map_add_action_entries(
G_ACTION_MAP(app),
app_entries,
G_N_ELEMENTS(app_entries),
app
);
}
static void
setup_accelerators(AgApp *app)
{
gtk_application_add_accelerator(GTK_APPLICATION(app), "<Primary>w", "win.close", NULL);
gtk_application_add_accelerator(GTK_APPLICATION(app), "<Primary>s", "win.save", NULL);
gtk_application_add_accelerator(GTK_APPLICATION(app), "<Primary><Shift>s", "win.save-as", NULL);
gtk_application_add_accelerator(GTK_APPLICATION(app), "F10", "win.gear-menu", NULL);
gtk_application_add_accelerator(GTK_APPLICATION(app), "F1", "app.help", NULL);
gtk_application_add_accelerator(GTK_APPLICATION(app), "F5", "win.change-tab", g_variant_new_string("chart"));
gtk_application_add_accelerator(GTK_APPLICATION(app), "F9", "win.change-tab", g_variant_new_string("aspects"));
gtk_application_add_accelerator(
GTK_APPLICATION(app),
"<Primary>w",
"win.close",
NULL
);
gtk_application_add_accelerator(
GTK_APPLICATION(app),
"<Primary>s",
"win.save",
NULL
);
gtk_application_add_accelerator(
GTK_APPLICATION(app),
"<Primary><Shift>s",
"win.save-as",
NULL
);
gtk_application_add_accelerator(
GTK_APPLICATION(app),
"F10",
"win.gear-menu",
NULL
);
gtk_application_add_accelerator(
GTK_APPLICATION(app),
"F1",
"app.help",
NULL
);
gtk_application_add_accelerator(
GTK_APPLICATION(app),
"F5",
"win.change-tab",
g_variant_new_string("chart")
);
gtk_application_add_accelerator(
GTK_APPLICATION(app),
"F9",
"win.change-tab",
g_variant_new_string("aspects")
);
}
static void
@ -264,7 +323,11 @@ setup_menu(AgApp *app)
builder = gtk_builder_new();
if (!gtk_builder_add_from_resource(builder, "/eu/polonkai/gergely/Astrognome/ui/astrognome.ui", &err)) {
if (!gtk_builder_add_from_resource(
builder,
"/eu/polonkai/gergely/Astrognome/ui/astrognome.ui",
&err
)) {
g_error("%s", (err) ? err->message : "unknown error");
}
@ -297,7 +360,9 @@ ag_app_open(GApplication *gapp, GFile **files, gint n_files, const gchar *hint)
}
void
ag_app_run_action(AgApp *app, gboolean is_remote, const AstrognomeOptions *options)
ag_app_run_action(AgApp *app,
gboolean is_remote,
const AstrognomeOptions *options)
{
if (options && options->new_window) {
if (is_remote) {
@ -322,7 +387,8 @@ ag_app_new(void)
{
AgApp *app;
/* i18n: Please don't translate "Astrognome" (it's marked as translatable for transliteration only */
/* i18n: Please don't translate "Astrognome" (it's marked as translatable
* for transliteration only */
g_set_application_name(_("Astrognome"));
app = g_object_new(AG_TYPE_APP,
@ -330,7 +396,12 @@ ag_app_new(void)
"flags", G_APPLICATION_HANDLES_OPEN,
"register-session", TRUE,
NULL);
g_signal_connect(app, "activate", G_CALLBACK(application_activate_cb), NULL);
g_signal_connect(
app,
"activate",
G_CALLBACK(application_activate_cb),
NULL
);
return app;
}
@ -376,7 +447,9 @@ ag_app_class_init(AgAppClass *klass)
}
void
ag_app_message_dialog(GtkWidget *window, GtkMessageType message_type, gchar *fmt, ...)
ag_app_message_dialog(GtkWidget *window,
GtkMessageType message_type,
gchar *fmt, ...)
{
gchar *msg;
va_list args;
@ -386,7 +459,14 @@ ag_app_message_dialog(GtkWidget *window, GtkMessageType message_type, gchar *fmt
msg = g_strdup_vprintf(fmt, args);
va_end(args);
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, message_type, GTK_BUTTONS_OK, "%s", msg);
dialog = gtk_message_dialog_new(
GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
message_type,
GTK_BUTTONS_OK,
"%s",
msg
);
g_free(msg);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);

View File

@ -32,12 +32,18 @@ AgApp *ag_app_new(void);
GtkWindow *ag_app_peek_first_window(AgApp *self);
void ag_app_new_window(AgApp *self);
void ag_app_quit(AgApp *self);
void ag_app_raise(AgApp *self);
void ag_app_run_action(AgApp *app,
gboolean is_remote,
const AstrognomeOptions *options);
void ag_app_message_dialog(GtkWidget *window, GtkMessageType message_type, gchar *fmt, ...);
void ag_app_message_dialog(GtkWidget *window,
GtkMessageType message_type,
gchar *fmt, ...);
G_END_DECLS

View File

@ -52,29 +52,41 @@ G_DEFINE_TYPE_WITH_PRIVATE(AgWindow, ag_window, GTK_TYPE_APPLICATION_WINDOW);
static void recalculate_chart(AgWindow *window);
static void
ag_window_gear_menu_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
ag_window_gear_menu_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GVariant *state;
state = g_action_get_state(G_ACTION(action));
g_action_change_state(G_ACTION(action), g_variant_new_boolean(!g_variant_get_boolean(state)));
g_action_change_state(
G_ACTION(action),
g_variant_new_boolean(!g_variant_get_boolean(state))
);
g_variant_unref(state);
}
static void
ag_window_view_menu_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
ag_window_view_menu_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GVariant *state;
state = g_action_get_state(G_ACTION(action));
g_action_change_state(G_ACTION(action), g_variant_new_boolean(!g_variant_get_boolean(state)));
g_action_change_state(
G_ACTION(action),
g_variant_new_boolean(!g_variant_get_boolean(state))
);
g_variant_unref(state);
}
static void
ag_window_close_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
ag_window_close_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
AgWindow *window = user_data;
@ -97,10 +109,20 @@ ag_window_save_as(AgWindow *window, GError **err)
if (priv->chart == NULL) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Chart cannot be calculated."));
dialog = gtk_message_dialog_new(
GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Chart cannot be calculated.")
);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_set_error(err, AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART, "Chart is empty");
g_set_error(
err,
AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART,
"Chart is empty"
);
return;
}
@ -112,10 +134,20 @@ ag_window_save_as(AgWindow *window, GError **err)
g_free(name);
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("You must enter a name before saving a chart."));
dialog = gtk_message_dialog_new(
GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("You must enter a name before saving a chart.")
);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_set_error(err, AG_WINDOW_ERROR, AG_WINDOW_ERROR_NO_NAME, "No name specified");
g_set_error(
err,
AG_WINDOW_ERROR, AG_WINDOW_ERROR_NO_NAME,
"No name specified"
);
return;
}
@ -148,7 +180,9 @@ ag_window_save_as(AgWindow *window, GError **err)
}
static void
ag_window_save_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
ag_window_save_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gchar *uri;
AgWindow *window = AG_WINDOW(user_data);
@ -168,12 +202,18 @@ ag_window_save_action(GSimpleAction *action, GVariant *parameter, gpointer user_
}
if (err) {
ag_app_message_dialog(GTK_WIDGET(window), GTK_MESSAGE_ERROR, "%s", err->message);
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_MESSAGE_ERROR,
"%s", err->message
);
}
}
static void
ag_window_save_as_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
ag_window_save_as_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
AgWindow *window = AG_WINDOW(user_data);
GError *err = NULL;
@ -182,7 +222,11 @@ ag_window_save_as_action(GSimpleAction *action, GVariant *parameter, gpointer us
ag_window_save_as(window, &err);
if (err) {
ag_app_message_dialog(GTK_WIDGET(window), GTK_MESSAGE_ERROR, "%s", err->message);
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_MESSAGE_ERROR,
"%s", err->message
);
}
}
@ -201,10 +245,20 @@ ag_window_export_svg(AgWindow *window, GError **err)
if (priv->chart == NULL) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Chart cannot be calculated."));
dialog = gtk_message_dialog_new(
GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Chart cannot be calculated.")
);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_set_error(err, AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART, "Chart is empty");
g_set_error(
err,
AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART,
"Chart is empty"
);
return;
}
@ -526,23 +580,53 @@ void
ag_window_update_from_chart(AgWindow *window)
{
AgWindowPrivate *priv = ag_window_get_instance_private(window);
GsweTimestamp *timestamp = gswe_moment_get_timestamp(GSWE_MOMENT(priv->chart));
GsweCoordinates *coordinates = gswe_moment_get_coordinates(GSWE_MOMENT(priv->chart));
GsweTimestamp *timestamp = gswe_moment_get_timestamp(
GSWE_MOMENT(priv->chart)
);
GsweCoordinates *coordinates = gswe_moment_get_coordinates(
GSWE_MOMENT(priv->chart)
);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->year), gswe_timestamp_get_gregorian_year(timestamp, NULL));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->month), gswe_timestamp_get_gregorian_month(timestamp, NULL));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->day), gswe_timestamp_get_gregorian_day(timestamp, NULL));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->hour), gswe_timestamp_get_gregorian_hour(timestamp, NULL));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->minute), gswe_timestamp_get_gregorian_minute(timestamp, NULL));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->second), gswe_timestamp_get_gregorian_second(timestamp, NULL));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->timezone), gswe_timestamp_get_gregorian_timezone(timestamp));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->longitude), fabs(coordinates->longitude));
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->year),
gswe_timestamp_get_gregorian_year(timestamp, NULL)
);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->month),
gswe_timestamp_get_gregorian_month(timestamp, NULL)
);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->day),
gswe_timestamp_get_gregorian_day(timestamp, NULL)
);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->hour),
gswe_timestamp_get_gregorian_hour(timestamp, NULL)
);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->minute),
gswe_timestamp_get_gregorian_minute(timestamp, NULL)
);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->second),
gswe_timestamp_get_gregorian_second(timestamp, NULL));
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->timezone),
gswe_timestamp_get_gregorian_timezone(timestamp)
);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->longitude),
fabs(coordinates->longitude)
);
if (coordinates->longitude < 0.0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->west_long), TRUE);
}
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->latitude), fabs(coordinates->latitude));
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->latitude),
fabs(coordinates->latitude)
);
if (coordinates->latitude < 0.0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->south_lat), TRUE);
@ -552,7 +636,11 @@ ag_window_update_from_chart(AgWindow *window)
if (ag_chart_get_note(priv->chart)) {
// TODO: maybe setting length to -1 here is not that good of an idea…
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(priv->note_buffer), ag_chart_get_note(priv->chart), -1);
gtk_text_buffer_set_text(
GTK_TEXT_BUFFER(priv->note_buffer),
ag_chart_get_note(priv->chart),
-1
);
}
g_free(coordinates);
@ -693,12 +781,27 @@ ag_window_init(AgWindow *window)
priv->settings = ag_settings_get();
main_settings = ag_settings_peek_main_settings(priv->settings);
g_signal_connect(G_OBJECT(main_settings), "changed::planets-char", G_CALLBACK(ag_window_display_changed), window);
g_signal_connect(G_OBJECT(main_settings), "changed::aspects-char", G_CALLBACK(ag_window_display_changed), window);
g_signal_connect(
G_OBJECT(main_settings),
"changed::planets-char",
G_CALLBACK(ag_window_display_changed),
window
);
g_signal_connect(
G_OBJECT(main_settings),
"changed::aspects-char",
G_CALLBACK(ag_window_display_changed),
window
);
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack), "edit");
priv->current_tab = priv->tab_edit;
g_object_set(priv->year_adjust, "lower", (gdouble)G_MININT, "upper", (gdouble)G_MAXINT, NULL);
g_object_set(
priv->year_adjust,
"lower", (gdouble)G_MININT,
"upper", (gdouble)G_MAXINT,
NULL
);
priv->chart = NULL;
priv->uri = NULL;
@ -706,7 +809,12 @@ ag_window_init(AgWindow *window)
gtk_window_set_hide_titlebar_when_maximized(GTK_WINDOW(window), TRUE);
g_action_map_add_action_entries(G_ACTION_MAP(window), win_entries, G_N_ELEMENTS(win_entries), window);
g_action_map_add_action_entries(
G_ACTION_MAP(window),
win_entries,
G_N_ELEMENTS(win_entries),
window
);
accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
@ -730,46 +838,110 @@ ag_window_class_init(AgWindowClass *klass)
gobject_class->dispose = ag_window_dispose;
gtk_widget_class_set_template_from_resource(widget_class, "/eu/polonkai/gergely/Astrognome/ui/ag-window.ui");
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, header_bar);
gtk_widget_class_set_template_from_resource(
widget_class,
"/eu/polonkai/gergely/Astrognome/ui/ag-window.ui"
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
header_bar
);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, name);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, year);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, month);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, day);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, hour);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, minute);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, second);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, timezone);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, north_lat);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, south_lat);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, east_long);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, west_long);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, latitude);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, longitude);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, aspect_table);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, year_adjust);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
minute
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
second
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
timezone
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
north_lat
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
south_lat
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
east_long
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
west_long
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
latitude
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
longitude
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
tab_chart
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
aspect_table
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
year_adjust
);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, stack);
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, note_buffer);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
note_buffer
);
}
gboolean
ag_window_chart_context_cb(WebKitWebView *web_view, GtkWidget *default_menu, WebKitHitTestResult *hit_test_result, gboolean triggered_with_keyboard, gpointer user_data)
ag_window_chart_context_cb(WebKitWebView *web_view,
GtkWidget *default_menu,
WebKitHitTestResult *hit_test_result,
gboolean triggered_with_keyboard,
gpointer user_data)
{
return TRUE;
}
static gboolean
ag_window_configure_event_cb(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
ag_window_configure_event_cb(GtkWidget *widget,
GdkEventConfigure *event,
gpointer user_data)
{
AgWindow *window = AG_WINDOW(widget);
AgWindowPrivate *priv = ag_window_get_instance_private(window);
ag_window_settings_save(GTK_WINDOW(window), ag_settings_peek_window_settings(priv->settings));
ag_window_settings_save(
GTK_WINDOW(window),
ag_settings_peek_window_settings(priv->settings)
);
return FALSE;
}
@ -801,9 +973,17 @@ ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group)
gtk_window_set_application(GTK_WINDOW(window), GTK_APPLICATION(app));
gtk_window_set_icon_name(GTK_WINDOW(window), "astrognome");
g_signal_connect(window, "configure-event", G_CALLBACK(ag_window_configure_event_cb), NULL);
g_signal_connect(
window,
"configure-event",
G_CALLBACK(ag_window_configure_event_cb),
NULL
);
ag_window_settings_restore(GTK_WINDOW(window), ag_settings_peek_window_settings(priv->settings));
ag_window_settings_restore(
GTK_WINDOW(window),
ag_settings_peek_window_settings(priv->settings)
);
return GTK_WIDGET(window);
}
@ -814,7 +994,11 @@ ag_window_set_chart(AgWindow *window, AgChart *chart)
AgWindowPrivate *priv = ag_window_get_instance_private(window);
if (priv->chart != NULL) {
g_signal_handlers_disconnect_by_func(priv->chart, chart_changed, window);
g_signal_handlers_disconnect_by_func(
priv->chart,
chart_changed,
window
);
g_object_unref(priv->chart);
}

View File

@ -34,21 +34,31 @@ struct _AgWindowClass {
};
GType ag_window_get_type(void) G_GNUC_CONST;
GtkWidget *ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group);
void ag_window_set_chart(AgWindow *window,
AgChart *chart);
AgChart *ag_window_get_chart(AgWindow *window);
void ag_window_update_from_chart(AgWindow *window);
void ag_window_set_uri(AgWindow *window,
const gchar *uri);
gchar *ag_window_get_uri(AgWindow *window);
void ag_window_settings_restore(GtkWindow *window,
GSettings *settings);
void ag_window_settings_save(GtkWindow *window,
GSettings *settings);
void ag_window_change_tab(AgWindow *window, const gchar *tab_name);
#define AG_WINDOW_ERROR (ag_window_error_quark())
GQuark ag_window_error_quark(void);
G_END_DECLS