Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
five-or-more
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
five-or-more
Commits
231da2d1
Commit
231da2d1
authored
Mar 20, 2018
by
Ruxandra Simion
Committed by
Robert Roth
Mar 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use libgnome-games-support
parent
8d25c941
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
90 additions
and
2157 deletions
+90
-2157
configure.ac
configure.ac
+1
-0
meson.build
meson.build
+2
-1
po/POTFILES.in
po/POTFILES.in
+0
-1
src/Makefile.am
src/Makefile.am
+0
-8
src/five-or-more-app.c
src/five-or-more-app.c
+78
-32
src/five-or-more-app.h
src/five-or-more-app.h
+1
-4
src/five-or-more.c
src/five-or-more.c
+0
-1
src/game-area.c
src/game-area.c
+3
-8
src/games-gridframe.c
src/games-gridframe.c
+0
-276
src/games-gridframe.h
src/games-gridframe.h
+0
-61
src/games-score.c
src/games-score.c
+0
-164
src/games-score.h
src/games-score.h
+0
-66
src/games-scores-backend.c
src/games-scores-backend.c
+0
-339
src/games-scores-backend.h
src/games-scores-backend.h
+0
-61
src/games-scores-dialog.c
src/games-scores-dialog.c
+0
-507
src/games-scores-dialog.h
src/games-scores-dialog.h
+0
-80
src/games-scores.c
src/games-scores.c
+0
-445
src/games-scores.h
src/games-scores.h
+0
-89
src/meson.build
src/meson.build
+5
-14
No files found.
configure.ac
View file @
231da2d1
...
@@ -27,6 +27,7 @@ PKG_CHECK_MODULES(FIVE_OR_MORE, [
...
@@ -27,6 +27,7 @@ PKG_CHECK_MODULES(FIVE_OR_MORE, [
glib-2.0 >= $GLIB_REQUIRED
glib-2.0 >= $GLIB_REQUIRED
gio-2.0 >= $GLIB_REQUIRED
gio-2.0 >= $GLIB_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
libgnome-games-support-1
librsvg-2.0 >= $RSVG_REQUIRED
librsvg-2.0 >= $RSVG_REQUIRED
])
])
...
...
meson.build
View file @
231da2d1
...
@@ -15,11 +15,12 @@ pkgdata_dir = join_paths (data_dir, 'five-or-more')
...
@@ -15,11 +15,12 @@ pkgdata_dir = join_paths (data_dir, 'five-or-more')
# Dependencies
# Dependencies
glib_min_version = '2.32'
glib_min_version = '2.32'
librsvg = dependency('librsvg-2.0', version: '>= 2.32.0')
gio = dependency('gio-2.0', version: '>= ' + glib_min_version)
gio = dependency('gio-2.0', version: '>= ' + glib_min_version)
glib = dependency('glib-2.0', version: '>= ' + glib_min_version)
glib = dependency('glib-2.0', version: '>= ' + glib_min_version)
gmodule_export = dependency('gmodule-export-2.0')
gmodule_export = dependency('gmodule-export-2.0')
gtk = dependency('gtk+-3.0', version: '>= 3.20.0')
gtk = dependency('gtk+-3.0', version: '>= 3.20.0')
libgnome_games_support = dependency('libgnome-games-support-1')
librsvg = dependency('librsvg-2.0', version: '>= 2.32.0')
# Libraries
# Libraries
cc = meson.get_compiler('c')
cc = meson.get_compiler('c')
...
...
po/POTFILES.in
View file @
231da2d1
...
@@ -8,7 +8,6 @@ data/menu.ui
...
@@ -8,7 +8,6 @@ data/menu.ui
data/org.gnome.five-or-more.gschema.xml
data/org.gnome.five-or-more.gschema.xml
data/translatable_themes.h
data/translatable_themes.h
src/five-or-more.c
src/five-or-more.c
src/games-scores-dialog.c
src/five-or-more-app.c
src/five-or-more-app.c
src/game-area.c
src/game-area.c
src/balls-preview.c
src/balls-preview.c
src/Makefile.am
View file @
231da2d1
...
@@ -8,14 +8,6 @@ five_or_more_SOURCES = \
...
@@ -8,14 +8,6 @@ five_or_more_SOURCES = \
games-gridframe.h
\
games-gridframe.h
\
games-preimage.c
\
games-preimage.c
\
games-preimage.h
\
games-preimage.h
\
games-score.h
\
games-score.c
\
games-scores.c
\
games-scores.h
\
games-scores-dialog.c
\
games-scores-dialog.h
\
games-scores-backend.c
\
games-scores-backend.h
\
five-or-more-app.h
\
five-or-more-app.h
\
five-or-more-app.c
\
five-or-more-app.c
\
balls-preview.c
\
balls-preview.c
\
...
...
src/five-or-more-app.c
View file @
231da2d1
...
@@ -33,12 +33,10 @@
...
@@ -33,12 +33,10 @@
#include <gtk/gtk.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkkeysyms.h>
#include <libgnome-games-support.h>
#include "games-file-list.h"
#include "games-file-list.h"
#include "games-preimage.h"
#include "games-preimage.h"
#include "games-gridframe.h"
#include "games-scores.h"
#include "games-scores-dialog.h"
#include "game-area.h"
#include "game-area.h"
#include "five-or-more-app.h"
#include "five-or-more-app.h"
#include "balls-preview.h"
#include "balls-preview.h"
...
@@ -50,7 +48,12 @@
...
@@ -50,7 +48,12 @@
#define KEY_BACKGROUND_COLOR "background-color"
#define KEY_BACKGROUND_COLOR "background-color"
#define KEY_BALL_THEME "ball-theme"
#define KEY_BALL_THEME "ball-theme"
static
const
GamesScoresCategory
scorecats
[]
=
{
typedef
struct
{
gchar
*
key
;
gchar
*
name
;
}
key_value
;
static
const
key_value
scorecats
[]
=
{
{
"Small"
,
NC_
(
"board size"
,
"Small"
)
},
{
"Small"
,
NC_
(
"board size"
,
"Small"
)
},
{
"Medium"
,
NC_
(
"board size"
,
"Medium"
)
},
{
"Medium"
,
NC_
(
"board size"
,
"Medium"
)
},
{
"Large"
,
NC_
(
"board size"
,
"Large"
)
}
{
"Large"
,
NC_
(
"board size"
,
"Large"
)
}
...
@@ -77,7 +80,11 @@ static GtkWidget *size_radio_s, *size_radio_m, *size_radio_l;
...
@@ -77,7 +80,11 @@ static GtkWidget *size_radio_s, *size_radio_m, *size_radio_l;
static
int
move_timeout
=
100
;
static
int
move_timeout
=
100
;
static
gboolean
window_is_fullscreen
=
FALSE
,
window_is_maximized
=
FALSE
;
static
gboolean
window_is_fullscreen
=
FALSE
,
window_is_maximized
=
FALSE
;
static
gint
window_width
=
0
,
window_height
=
0
;
static
gint
window_width
=
0
,
window_height
=
0
;
static
GamesScores
*
highscores
;
static
gint
no_categories
=
3
;
static
gchar
*
score_current_category
=
NULL
;
static
GamesScoresContext
*
highscores
;
static
GSettings
*
settings
;
static
GSettings
*
settings
;
static
GtkBuilder
*
builder
;
static
GtkBuilder
*
builder
;
static
GtkBuilder
*
builder_preferences
;
static
GtkBuilder
*
builder_preferences
;
...
@@ -93,12 +100,6 @@ get_settings ()
...
@@ -93,12 +100,6 @@ get_settings ()
return
&
settings
;
return
&
settings
;
}
}
const
GamesScoresCategory
*
get_scorecats
()
{
return
scorecats
;
}
gint
*
gint
*
get_game_size
()
get_game_size
()
{
{
...
@@ -129,12 +130,6 @@ get_move_timeout ()
...
@@ -129,12 +130,6 @@ get_move_timeout ()
return
move_timeout
;
return
move_timeout
;
}
}
GamesScores
*
get_highscores
()
{
return
highscores
;
}
void
void
update_score
(
guint
value
)
update_score
(
guint
value
)
{
{
...
@@ -170,9 +165,11 @@ set_backgnd_color (const gchar * str)
...
@@ -170,9 +165,11 @@ set_backgnd_color (const gchar * str)
}
}
static
void
static
void
show_scores
(
gint
pos
)
show_scores
()
{
{
static
GtkWidget
*
dialog
;
games_scores_context_run_dialog
(
highscores
);
/* static GtkWidget *dialog;
if (dialog == NULL) {
if (dialog == NULL) {
dialog = games_scores_dialog_new (GTK_WINDOW (app), highscores, _("Five or More Scores"));
dialog = games_scores_dialog_new (GTK_WINDOW (app), highscores, _("Five or More Scores"));
...
@@ -186,7 +183,7 @@ show_scores (gint pos)
...
@@ -186,7 +183,7 @@ show_scores (gint pos)
gtk_window_present (GTK_WINDOW (dialog));
gtk_window_present (GTK_WINDOW (dialog));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_hide
(
dialog
);
gtk_widget_hide (dialog);
*/
}
}
static
void
static
void
...
@@ -205,15 +202,46 @@ load_properties (void)
...
@@ -205,15 +202,46 @@ load_properties (void)
load_theme
();
load_theme
();
}
}
static
void
add_score_cb
(
GObject
*
source_object
,
GAsyncResult
*
res
,
gpointer
user_data
)
{
GamesScoresContext
*
context
=
GAMES_SCORES_CONTEXT
(
source_object
);
GError
*
error
=
NULL
;
games_scores_context_add_score_finish
(
context
,
res
,
&
error
);
if
(
error
!=
NULL
)
{
g_warning
(
"Failed to add score: %s"
,
error
->
message
);
g_error_free
(
error
);
}
}
const
gchar
*
category_name_from_key
(
const
gchar
*
key
)
{
int
i
;
for
(
i
=
0
;
i
<
no_categories
;
i
++
)
{
if
(
g_strcmp0
(
scorecats
[
i
].
key
,
key
)
==
0
)
return
scorecats
[
i
].
name
;
}
return
NULL
;
}
void
void
game_over
(
void
)
game_over
(
void
)
{
{
int
pos
;
set_status_message
(
_
(
"Game Over!"
));
set_status_message
(
_
(
"Game Over!"
));
if
(
score
>
0
)
if
(
score
>
0
)
{
pos
=
games_scores_add_plain_score
(
highscores
,
score
);
const
gchar
*
name
=
category_name_from_key
(
score_current_category
);
show_scores
(
pos
);
GamesScoresCategory
*
current_category
=
games_scores_category_new
(
score_current_category
,
name
);
games_scores_context_add_score
(
highscores
,
score
,
current_category
,
NULL
,
add_score_cb
,
NULL
);
}
show_scores
();
}
}
static
void
static
void
...
@@ -263,6 +291,8 @@ conf_value_changed_cb (GSettings *settings, gchar *key)
...
@@ -263,6 +291,8 @@ conf_value_changed_cb (GSettings *settings, gchar *key)
if
(
size_tmp
!=
game_size
)
{
if
(
size_tmp
!=
game_size
)
{
set_sizes
(
size_tmp
);
set_sizes
(
size_tmp
);
score_current_category
=
scorecats
[
size_tmp
-
1
].
key
;
reset_game
();
reset_game
();
start_game
();
start_game
();
}
}
...
@@ -282,6 +312,7 @@ init_config (void)
...
@@ -282,6 +312,7 @@ init_config (void)
game_size
=
CLAMP
(
game_size
,
SMALL
,
MAX_SIZE
-
1
);
game_size
=
CLAMP
(
game_size
,
SMALL
,
MAX_SIZE
-
1
);
set_sizes
(
game_size
);
set_sizes
(
game_size
);
score_current_category
=
scorecats
[
game_size
-
1
].
key
;
}
}
static
gboolean
static
gboolean
...
@@ -318,7 +349,7 @@ game_top_ten_callback (GSimpleAction *action,
...
@@ -318,7 +349,7 @@ game_top_ten_callback (GSimpleAction *action,
GVariant
*
parameter
,
GVariant
*
parameter
,
gpointer
user_data
)
gpointer
user_data
)
{
{
show_scores
(
0
);
show_scores
();
}
}
...
@@ -561,6 +592,16 @@ game_quit_callback (GSimpleAction *action,
...
@@ -561,6 +592,16 @@ game_quit_callback (GSimpleAction *action,
g_application_quit
(
G_APPLICATION
(
user_data
));
g_application_quit
(
G_APPLICATION
(
user_data
));
}
}
static
GamesScoresCategory
*
create_category_from_key
(
const
char
*
key
,
gpointer
user_data
)
{
const
gchar
*
name
=
category_name_from_key
(
key
);
if
(
name
==
NULL
)
return
NULL
;
return
games_scores_category_new
(
key
,
name
);
}
void
void
startup_cb
(
GApplication
*
application
)
startup_cb
(
GApplication
*
application
)
{
{
...
@@ -570,6 +611,7 @@ startup_cb (GApplication *application)
...
@@ -570,6 +611,7 @@ startup_cb (GApplication *application)
GtkWidget
*
new_game_button
;
GtkWidget
*
new_game_button
;
guint
i
;
guint
i
;
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
GamesScoresDirectoryImporter
*
importer
;
GActionEntry
app_actions
[]
=
{
GActionEntry
app_actions
[]
=
{
{
"new-game"
,
game_new_callback
},
{
"new-game"
,
game_new_callback
},
...
@@ -588,11 +630,6 @@ startup_cb (GApplication *application)
...
@@ -588,11 +630,6 @@ startup_cb (GApplication *application)
settings
=
g_settings_new
(
"org.gnome.five-or-more"
);
settings
=
g_settings_new
(
"org.gnome.five-or-more"
);
highscores
=
games_scores_new
(
"five-or-more"
,
scorecats
,
G_N_ELEMENTS
(
scorecats
),
"board size"
,
NULL
,
0
/* default category */
,
GAMES_SCORES_STYLE_PLAIN_DESCENDING
);
init_config
();
init_config
();
builder
=
gtk_builder_new
();
builder
=
gtk_builder_new
();
ui_path
=
g_build_filename
(
DATA_DIRECTORY
,
"menu.ui"
,
NULL
);
ui_path
=
g_build_filename
(
DATA_DIRECTORY
,
"menu.ui"
,
NULL
);
...
@@ -644,13 +681,22 @@ startup_cb (GApplication *application)
...
@@ -644,13 +681,22 @@ startup_cb (GApplication *application)
GtkWidget
*
draw_area
=
game_area_init
();
GtkWidget
*
draw_area
=
game_area_init
();
gridframe
=
games_grid_frame_new
(
get_hfieldsize
(),
get_vfieldsize
(
));
gridframe
=
GTK_WIDGET
(
games_grid_frame_new
(
get_hfieldsize
(),
get_vfieldsize
()
));
games_grid_frame_set_padding
(
GAMES_GRID_FRAME
(
gridframe
),
1
,
1
);
games_grid_frame_set_padding
(
GAMES_GRID_FRAME
(
gridframe
),
1
,
1
);
gtk_container_add
(
GTK_CONTAINER
(
gridframe
),
draw_area
);
gtk_container_add
(
GTK_CONTAINER
(
gridframe
),
draw_area
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
gridframe
,
TRUE
,
TRUE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
gridframe
,
TRUE
,
TRUE
,
0
);
new_game_button
=
GTK_WIDGET
(
gtk_builder_get_object
(
builder
,
"new_game_button"
));
new_game_button
=
GTK_WIDGET
(
gtk_builder_get_object
(
builder
,
"new_game_button"
));
importer
=
games_scores_directory_importer_new
();
highscores
=
games_scores_context_new_with_importer
(
"five-or-more"
,
_
(
"Board Size: "
),
GTK_WINDOW
(
app
),
create_category_from_key
,
NULL
,
GAMES_SCORES_STYLE_POINTS_GREATER_IS_BETTER
,
GAMES_SCORES_IMPORTER
(
importer
));
load_properties
();
load_properties
();
gtk_builder_connect_signals
(
builder
,
NULL
);
gtk_builder_connect_signals
(
builder
,
NULL
);
...
@@ -692,4 +738,4 @@ set_application_callbacks(GtkApplication *application)
...
@@ -692,4 +738,4 @@ set_application_callbacks(GtkApplication *application)
g_signal_connect
(
application
,
"startup"
,
G_CALLBACK
(
startup_cb
),
NULL
);
g_signal_connect
(
application
,
"startup"
,
G_CALLBACK
(
startup_cb
),
NULL
);
g_signal_connect
(
application
,
"activate"
,
G_CALLBACK
(
activate_cb
),
NULL
);
g_signal_connect
(
application
,
"activate"
,
G_CALLBACK
(
activate_cb
),
NULL
);
g_signal_connect
(
application
,
"shutdown"
,
G_CALLBACK
(
shutdown_cb
),
NULL
);
g_signal_connect
(
application
,
"shutdown"
,
G_CALLBACK
(
shutdown_cb
),
NULL
);
}
}
\ No newline at end of file
src/five-or-more-app.h
View file @
231da2d1
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#define FIVE_OR_MORE_APP_H
#define FIVE_OR_MORE_APP_H
#include <gtk/gtk.h>
#include <gtk/gtk.h>
#include "games-scores.h"
typedef
struct
_background
background
;
typedef
struct
_background
background
;
struct
_background
{
struct
_background
{
...
@@ -33,7 +32,6 @@ struct _background{
...
@@ -33,7 +32,6 @@ struct _background{
gint
set
;
gint
set
;
}
;
}
;
GamesScores
*
get_highscores
();
GtkWidget
*
get_gridframe
();
GtkWidget
*
get_gridframe
();
char
*
get_ball_filename
();
char
*
get_ball_filename
();
background
get_backgnd
();
background
get_backgnd
();
...
@@ -41,11 +39,10 @@ void set_status_message (gchar * message);
...
@@ -41,11 +39,10 @@ void set_status_message (gchar * message);
void
game_over
(
void
);
void
game_over
(
void
);
void
set_application_callbacks
(
GtkApplication
*
application
);
void
set_application_callbacks
(
GtkApplication
*
application
);
gint
*
get_game_size
();
gint
*
get_game_size
();
const
GamesScoresCategory
*
get_scorecats
();
GSettings
**
get_settings
();
GSettings
**
get_settings
();
int
get_move_timeout
();
int
get_move_timeout
();
void
game_props_callback
(
GSimpleAction
*
action
,
void
game_props_callback
(
GSimpleAction
*
action
,
GVariant
*
parameter
,
GVariant
*
parameter
,
gpointer
user_data
);
gpointer
user_data
);
void
update_score
(
guint
value
);
void
update_score
(
guint
value
);
#endif
#endif
\ No newline at end of file
src/five-or-more.c
View file @
231da2d1
...
@@ -51,7 +51,6 @@ main (int argc, char *argv[])
...
@@ -51,7 +51,6 @@ main (int argc, char *argv[])
bind_textdomain_codeset
(
GETTEXT_PACKAGE
,
"UTF-8"
);
bind_textdomain_codeset
(
GETTEXT_PACKAGE
,
"UTF-8"
);
textdomain
(
GETTEXT_PACKAGE
);
textdomain
(
GETTEXT_PACKAGE
);
games_scores_startup
();
GRand
**
rgen
=
get_rgen
();
GRand
**
rgen
=
get_rgen
();
*
rgen
=
g_rand_new
();
*
rgen
=
g_rand_new
();
...
...
src/game-area.c
View file @
231da2d1
...
@@ -33,8 +33,8 @@
...
@@ -33,8 +33,8 @@
#include <gtk/gtk.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkkeysyms.h>
#include <libgnome-games-support.h>
#include "games-gridframe.h"
#include "game-area.h"
#include "game-area.h"
#include "five-or-more-app.h"
#include "five-or-more-app.h"
#include "balls-preview.h"
#include "balls-preview.h"
...
@@ -82,8 +82,7 @@ static const gint field_sizes[MAX_SIZE][4] = {
...
@@ -82,8 +82,7 @@ static const gint field_sizes[MAX_SIZE][4] = {
};
};
static
scoretable
sctab
[]
=
static
scoretable
sctab
[]
=
{
{
5
,
10
},
{
6
,
12
},
{
7
,
18
},
{
8
,
28
},
{
9
,
42
},
{
10
,
82
},
{
11
,
108
},
{
12
,
{
{
5
,
10
},
{
6
,
12
},
{
7
,
18
},
{
8
,
28
},
{
9
,
42
},
{
10
,
82
},
{
11
,
108
},
{
12
,
138
},
138
},
{
13
,
172
},
{
14
,
210
},
{
0
,
0
}
};
{
13
,
172
},
{
14
,
210
},
{
0
,
0
}
};
static
gchar
*
warning_message
=
NULL
;
static
gchar
*
warning_message
=
NULL
;
...
@@ -98,8 +97,6 @@ set_sizes (gint size)
...
@@ -98,8 +97,6 @@ set_sizes (gint size)
npieces
=
field_sizes
[
size
][
3
];
npieces
=
field_sizes
[
size
][
3
];
gint
*
game_size
=
get_game_size
();
gint
*
game_size
=
get_game_size
();
*
game_size
=
size
;
*
game_size
=
size
;
GamesScoresCategory
*
scorecats
=
get_scorecats
();
games_scores_set_category
(
get_highscores
(),
scorecats
[
size
-
1
].
key
);
g_settings_set_int
(
*
(
get_settings
()),
KEY_SIZE
,
size
);
g_settings_set_int
(
*
(
get_settings
()),
KEY_SIZE
,
size
);
GtkWidget
*
gridframe
=
get_gridframe
();
GtkWidget
*
gridframe
=
get_gridframe
();
...
@@ -321,7 +318,6 @@ check_gameover (void)
...
@@ -321,7 +318,6 @@ check_gameover (void)
static
int
static
int
addscore
(
int
num
)
addscore
(
int
num
)
{
{
gchar
string
[
20
];
int
i
=
0
;
int
i
=
0
;
int
retval
;
int
retval
;
...
@@ -670,7 +666,6 @@ cell_clicked (GtkWidget * widget, int fx, int fy)
...
@@ -670,7 +666,6 @@ cell_clicked (GtkWidget * widget, int fx, int fy)
static
gint
static
gint
button_press_event
(
GtkWidget
*
widget
,
GdkEvent
*
event
)
button_press_event
(
GtkWidget
*
widget
,
GdkEvent
*
event
)
{
{
int
x
,
y
;
int
fx
,
fy
;
int
fx
,
fy
;
if
(
inmove
)
if
(
inmove
)
...
@@ -1054,4 +1049,4 @@ game_area_init (void)
...
@@ -1054,4 +1049,4 @@ game_area_init (void)
gtk_widget_set_can_focus
(
draw_area
,
TRUE
);
gtk_widget_set_can_focus
(
draw_area
,
TRUE
);
gtk_widget_grab_focus
(
draw_area
);
gtk_widget_grab_focus
(
draw_area
);
return
draw_area
;
return
draw_area
;
}
}
\ No newline at end of file
src/games-gridframe.c
deleted
100644 → 0
View file @
8d25c941
/* games-gridframe.c: Create a container that guarantees that the internal
* allocated space is a fixed multiple of an integer.
*
* Copyright 2004 by Callum McKenzie
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
/* A lot of this was written by following the sorce for GtkFrame and
* GtkAspectFrame. */
#include <config.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "games-gridframe.h"
enum
{
PROP_0
,
PROP_X_PADDING
,
PROP_Y_PADDING
,
PROP_WIDTH
,
PROP_HEIGHT
,
PROP_X_ALIGN
,
PROP_Y_ALIGN
};
G_DEFINE_TYPE
(
GamesGridFrame
,
games_grid_frame
,
GTK_TYPE_BIN
)
struct
GamesGridFramePrivate
{
gint
xmult
;
gint
ymult
;
gint
xpadding
;
gint
ypadding
;
gfloat
xalign
;
gfloat
yalign
;
GtkAllocation
old_allocation
;
};
void
games_grid_frame_set
(
GamesGridFrame
*
frame
,
gint
newxmult
,
gint
newymult
)
{
if
(
newxmult
>
0
)
frame
->
priv
->
xmult
=
newxmult
;
if
(
newymult
>
0
)
frame
->
priv
->
ymult
=
newymult
;
gtk_widget_queue_resize
(
GTK_WIDGET
(
frame
));
}
void
games_grid_frame_set_padding
(
GamesGridFrame
*
frame
,
gint
newxpadding
,
gint
newypadding
)
{
if
(
newxpadding
>=
0
)
frame
->
priv
->
xpadding
=
newxpadding
;
if
(
newypadding
>=
0
)
frame
->
priv
->
ypadding
=
newypadding
;
gtk_widget_queue_resize
(
GTK_WIDGET
(
frame
));
}
void
games_grid_frame_set_alignment
(
GamesGridFrame
*
frame
,
gfloat
xalign
,
gfloat
yalign
)
{
if
(
xalign
<
0
.
0
)
xalign
=
0
.
0
;
else
if
(
xalign
>
1
.
0
)
xalign
=
1
.
0
;
if
(
yalign
<
0
.
0
)
yalign
=
0
.
0
;
else
if
(
yalign
>
1
.
0
)
yalign
=
1
.
0
;
frame
->
priv
->
xalign
=
xalign
;
frame
->
priv
->
yalign
=
yalign
;
gtk_widget_queue_resize
(
GTK_WIDGET
(
frame
));
}
static
void
games_grid_frame_set_property
(
GObject
*
object
,
guint
prop_id
,
const
GValue
*
value
,
GParamSpec
*
pspec
)
{
GamesGridFrame
*
frame
=
GAMES_GRID_FRAME
(
object
);
switch
(
prop_id
)
{
case
PROP_X_PADDING
:
games_grid_frame_set_padding
(
frame
,
g_value_get_int
(
value
),
-
1
);
break
;
case
PROP_Y_PADDING
:
games_grid_frame_set_padding
(
frame
,
-
1
,
g_value_get_int
(
value
));
break
;
case
PROP_X_ALIGN
:
games_grid_frame_set_alignment
(
frame
,
g_value_get_float
(
value
),
frame
->
priv
->
yalign
);
break
;
case
PROP_Y_ALIGN
:
games_grid_frame_set_alignment
(
frame
,
frame
->
priv
->
xalign
,