11#include "nip4.h"
22
3- struct _Nip4App {
3+ struct _App {
44 GtkApplication parent ;
55};
66
7- G_DEFINE_TYPE (Nip4App , nip4_app , GTK_TYPE_APPLICATION );
7+ G_DEFINE_TYPE (App , app , GTK_TYPE_APPLICATION );
88
99static void
10- nip4_app_init ( Nip4App * app )
10+ app_init ( App * app )
1111{
1212}
1313
1414static void
15- nip4_app_activate (GApplication * app )
15+ app_activate (GApplication * gapp )
1616{
1717 MainWindow * win ;
1818
19- win = main_window_new (APP (app ));
19+ win = main_window_new (APP (gapp ));
2020 gtk_window_present (GTK_WINDOW (win ));
2121}
2222
2323static void
24- nip4_app_quit_activated (GSimpleAction * action ,
25- GVariant * parameter , gpointer app )
24+ app_quit_activated (GSimpleAction * action ,
25+ GVariant * parameter , gpointer user_data )
2626{
27- g_application_quit (G_APPLICATION (app ));
27+ g_application_quit (G_APPLICATION (user_data ));
2828}
2929
3030static void
31- nip4_app_new_activated (GSimpleAction * action ,
31+ app_new_activated (GSimpleAction * action ,
3232 GVariant * parameter , gpointer user_data )
3333{
34- nip4_app_activate (G_APPLICATION (user_data ));
34+ app_activate (G_APPLICATION (user_data ));
3535}
3636
3737static MainWindow *
38- nip4_app_win ( Nip4App * app )
38+ app_win ( App * app )
3939{
4040 GList * windows = gtk_application_get_windows (GTK_APPLICATION (app ));
4141
@@ -46,19 +46,19 @@ nip4_app_win(Nip4App *app)
4646}
4747
4848static void
49- nip4_app_about_activated (GSimpleAction * action ,
49+ app_about_activated (GSimpleAction * action ,
5050 GVariant * parameter , gpointer user_data )
5151{
52- Nip4App * app = APP (user_data );
53- MainWindow * win = nip4_app_win (app );
52+ App * app = APP (user_data );
53+ MainWindow * win = app_win (app );
5454
5555 static const char * authors [] = {
5656 "jcupitt" ,
5757 NULL
5858 };
5959
6060#ifdef DEBUG
61- printf ("nip4_app_about_activated :\n" );
61+ printf ("app_about_activated :\n" );
6262#endif /*DEBUG*/
6363
6464 gtk_show_about_dialog (win ? GTK_WINDOW (win ) : NULL ,
@@ -75,13 +75,13 @@ nip4_app_about_activated(GSimpleAction *action,
7575}
7676
7777static GActionEntry app_entries [] = {
78- { "quit" , nip4_app_quit_activated },
79- { "new" , nip4_app_new_activated },
80- { "about" , nip4_app_about_activated },
78+ { "quit" , app_quit_activated },
79+ { "new" , app_new_activated },
80+ { "about" , app_about_activated },
8181};
8282
8383static void
84- nip4_app_startup (GApplication * app )
84+ app_startup (GApplication * app )
8585{
8686 int i ;
8787 GtkSettings * settings ;
@@ -90,9 +90,11 @@ nip4_app_startup(GApplication *app)
9090 const gchar * action_and_target ;
9191 const gchar * accelerators [2 ];
9292 } accels [] = {
93+ // application wide accels
9394 { "app.quit" , { "<Primary>q" , NULL } },
9495 { "app.new" , { "<Primary>n" , NULL } },
9596
97+ // main window accels ... the "win." prefix is wired into gtk
9698 { "win.copy" , { "<Primary>c" , NULL } },
9799 { "win.paste" , { "<Primary>v" , NULL } },
98100 { "win.duplicate" , { "<Primary>d" , NULL } },
@@ -108,7 +110,7 @@ nip4_app_startup(GApplication *app)
108110 { "win.properties" , { "<Alt>Return" , NULL } },
109111 };
110112
111- G_APPLICATION_CLASS (nip4_app_parent_class )-> startup (app );
113+ G_APPLICATION_CLASS (app_parent_class )-> startup (app );
112114
113115 /* Image display programs are supposed to default to a dark theme,
114116 * according to the HIG.
@@ -132,16 +134,15 @@ nip4_app_startup(GApplication *app)
132134 MAIN_WINDOW_TYPE ;
133135
134136 g_action_map_add_action_entries (G_ACTION_MAP (app ),
135- app_entries , G_N_ELEMENTS (app_entries ),
136- app );
137+ app_entries , G_N_ELEMENTS (app_entries ), app );
137138
138139 for (i = 0 ; i < G_N_ELEMENTS (accels ); i ++ )
139140 gtk_application_set_accels_for_action (GTK_APPLICATION (app ),
140141 accels [i ].action_and_target , accels [i ].accelerators );
141142}
142143
143144static void
144- nip4_app_open (GApplication * app ,
145+ app_open (GApplication * app ,
145146 GFile * * files , int n_files , const char * hint )
146147{
147148 for (int i = 0 ; i < n_files ; i ++ ) {
@@ -153,34 +154,34 @@ nip4_app_open(GApplication *app,
153154}
154155
155156static void
156- nip4_app_shutdown (GApplication * app )
157+ app_shutdown (GApplication * app )
157158{
158159 MainWindow * win ;
159160
160161#ifdef DEBUG
161- printf ("nip4_app_shutdown :\n" );
162+ printf ("app_shutdown :\n" );
162163#endif /*DEBUG*/
163164
164165 /* Force down all our windows ... this will not happen automatically
165166 * on _quit().
166167 */
167- while ((win = nip4_app_win (APP (app ))))
168+ while ((win = app_win (APP (app ))))
168169 gtk_window_destroy (GTK_WINDOW (win ));
169170
170- G_APPLICATION_CLASS (nip4_app_parent_class )-> shutdown (app );
171+ G_APPLICATION_CLASS (app_parent_class )-> shutdown (app );
171172}
172173
173174static void
174- nip4_app_class_init ( Nip4AppClass * class )
175+ app_class_init ( AppClass * class )
175176{
176- G_APPLICATION_CLASS (class )-> startup = nip4_app_startup ;
177- G_APPLICATION_CLASS (class )-> activate = nip4_app_activate ;
178- G_APPLICATION_CLASS (class )-> open = nip4_app_open ;
179- G_APPLICATION_CLASS (class )-> shutdown = nip4_app_shutdown ;
177+ G_APPLICATION_CLASS (class )-> startup = app_startup ;
178+ G_APPLICATION_CLASS (class )-> activate = app_activate ;
179+ G_APPLICATION_CLASS (class )-> open = app_open ;
180+ G_APPLICATION_CLASS (class )-> shutdown = app_shutdown ;
180181}
181182
182- Nip4App *
183- nip4_app_new (void )
183+ App *
184+ app_new (void )
184185{
185186 return g_object_new (APP_TYPE ,
186187 "application-id" , APPLICATION_ID ,
0 commit comments