Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various minor adjustments to the code and preparation for GTK+ 3 #11

Merged
merged 9 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,14 @@ Unpack the distribution using the following command:
Change the directory to the source directory:
cd screentest-<version>
Set it up for your system:
./configure
You can run "./configure --help" for details of the configuration process.
meson setup builddir
TobiX marked this conversation as resolved.
Show resolved Hide resolved

### 2. COMPILING THE PROGRAM

Run "make" (On BSD systems, you might want to use "gmake"). This will compile
the "screentest" program. Since the program is mostly standalone, you can now
verify their function by running them in the current directory (calling
"./screentest").
Run "meson compile". This will compile the "screentest" program. Since the
program is mostly standalone, you can now verify their function by running them
in the current directory (calling "./screentest").

### 3. INSTALLING

Run "make install".
Run "meson install".
5 changes: 5 additions & 0 deletions callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/

#ifndef SCREENTEST_CALLBACKS_H
TobiX marked this conversation as resolved.
Show resolved Hide resolved
#define SCREENTEST_CALLBACKS_H

#include <gtk/gtk.h>

struct test_ops {
Expand Down Expand Up @@ -47,3 +50,5 @@ extern GdkGC *gc, *backgc;
extern GdkColor fgcolors[];
extern GdkColor *fg_color;
extern GdkColor grays[];

#endif // SCREENTEST_CALLBACKS_H
6 changes: 3 additions & 3 deletions gettext.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
#ifndef SCREENTEST_LIBGETTEXT_H
#define SCREENTEST_LIBGETTEXT_H 1

/* NLS can be disabled through the configure --disable-nls option. */
#if ENABLE_NLS
Expand Down Expand Up @@ -279,4 +279,4 @@ inline
return (n == 1 ? msgid : msgid_plural);
}

#endif /* _LIBGETTEXT_H */
#endif // SCREENTEST_LIBGETTEXT_H
6 changes: 3 additions & 3 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/

#ifndef _MAIN_H
#define _MAIN_H 1
TobiX marked this conversation as resolved.
Show resolved Hide resolved
#ifndef SCREENTEST_MAIN_H
#define SCREENTEST_MAIN_H 1

#include <gtk/gtk.h>

extern GtkBuilder *builder;

#endif /* _MAIN_H */
#endif // SCREENTEST_MAIN_H
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ screentest_srcs = [
executable(
meson.project_name(),
'main.c',
c_args: '-DGSEAL_ENABLE -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When switching to GTK+ 3 I'd drop these again. They only serve to highlight the progress of the migration.

dependencies: screentest_deps,
install: true,
sources: screentest_srcs,
Expand Down
3 changes: 2 additions & 1 deletion test_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ static void basic_draw(GtkWidget *widget) {
N_("Right Button - menu"),
};

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

for (i = ((w - 1) % BASIC_STEP) / 2; i < w; i += BASIC_STEP)
gdk_draw_line(win, gc, i, 0, i, h - 1);
Expand Down
7 changes: 4 additions & 3 deletions test_blink.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ static void blink_draw(GtkWidget *widget) {
gint w, h;
GdkGC *gc1, *gc2;

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

if (blink_step) {
gc1 = backgc;
Expand Down Expand Up @@ -66,13 +67,13 @@ static gboolean blink_timeout(gpointer data) {
static void blink_init(GtkWidget *widget) {
blink_type = 0;
blink_step = 0;
timeout = gtk_timeout_add(1000, blink_timeout, widget);
timeout = g_timeout_add(1000, blink_timeout, widget);
}

void blink_cycle(G_GNUC_UNUSED GtkWidget *widget) { blink_type = !blink_type; }

static void blink_close(G_GNUC_UNUSED GtkWidget *widget) {
gtk_timeout_remove(timeout);
g_source_remove(timeout);
}

G_MODULE_EXPORT struct test_ops blink_ops = {.init = blink_init,
Expand Down
4 changes: 3 additions & 1 deletion test_bright_pixels.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ static void bright_pixels_draw(GtkWidget *widget) {
GdkWindow *win = gtk_widget_get_window(widget);
gint w, h;

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

gdk_gc_set_rgb_fg_color(gc, &fgcolors[color_cycle[current_color_idx]]);
gdk_draw_rectangle(win, gc, 1, 0, 0, w, h);

Expand Down
3 changes: 2 additions & 1 deletion test_grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static void grid_draw(GtkWidget *widget) {
gint i;
gint d;
TobiX marked this conversation as resolved.
Show resolved Hide resolved

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

d = w / 4;
if (d > h / 4)
Expand Down
3 changes: 2 additions & 1 deletion test_horizontal.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static void horizontal_draw(GtkWidget *widget) {
gint i;
gint d;

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

d = w / 4;
if (d > h / 4)
Expand Down
3 changes: 2 additions & 1 deletion test_lcdalign.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ static void lcdalign_draw(GtkWidget *widget) {
gint i;
gint8 d[] = {1, 1};

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

/* Border */
gdk_draw_line(win, gc, 0, 0, w - 1, 0);
Expand Down
3 changes: 2 additions & 1 deletion test_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ static void text_draw(GtkWidget *widget) {
gint w, h;
gint x, y;

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

x = w + textwidth;
for (y = 0; y < h; y += baselineskip)
Expand Down
3 changes: 2 additions & 1 deletion test_vertical.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static void vertical_draw(GtkWidget *widget) {
gint i;
gint d;

gdk_drawable_get_size(win, &w, &h);
h = gdk_window_get_height(win);
w = gdk_window_get_width(win);

d = w / 4;
if (d > h / 4)
Expand Down