Commit 2147e502 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

tools/Makefile.am tools/shooter.c some minor cleanups, removed unused

2005-04-20  Sven Neumann  <sven@gimp.org>

	* tools/Makefile.am
	* tools/shooter.c
	* tools/widgets.[ch]: some minor cleanups, removed unused includes,
	made code multihead-safe.
parent 794eaedf
Makefile
Makefile.in
.deps
.libs
doc-shooter
*.png
INCLUDES = \
## Process this file with automake to produce Makefile.in
libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
INCLUDES = \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
`pkg-config --cflags gdk-2.0` -I$(top_srcdir)
$(GTK_CFLAGS)
LDADDS = $(GTK_LIBS) $(top_builddir)/libgimp/libgimpui-2.0.la $(top_builddir)/libgimpwidgets/libgimpwidgets-2.0.la
LDADDS = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpconfig) \
$(libgimpmath) \
$(libgimp) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS)
noinst_PROGRAMS = \
doc-shooter
noinst_PROGRAMS = doc-shooter
doc_shooter_SOURCES= \
doc_shooter_SOURCES = \
shadow.c \
shadow.h \
shooter.c \
......@@ -17,5 +34,6 @@ doc_shooter_SOURCES= \
doc_shooter_LDADD = $(LDADDS)
clean-local:
rm -f *.png
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <stdio.h>
#include <errno.h>
#include <sys/wait.h>
#include "config.h"
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <X11/extensions/shape.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <locale.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets.h"
#include "shadow.h"
#define MAXIMUM_WM_REPARENTING_DEPTH 4
#ifndef _
#define _(x) (x)
#endif
static Window
find_toplevel_window (Window xid)
find_toplevel_window (Display *display,
Window xid)
{
Window root, parent, *children;
int nchildren;
Window root, parent, *children;
gint nchildren;
do
{
if (XQueryTree ( gdk_x11_get_default_xdisplay (), xid, &root,
&parent, &children, &nchildren) == 0)
if (XQueryTree (display, xid,
&root, &parent, &children, &nchildren) == 0)
{
g_warning ("Couldn't find window manager window");
return 0;
......@@ -72,18 +66,22 @@ static GdkPixbuf *
remove_shaped_area (GdkPixbuf *pixbuf,
Window window)
{
GdkPixbuf *retval;
Display *display;
GdkPixbuf *retval;
XRectangle *rectangles;
int rectangle_count, rectangle_order;
int i;
gint rectangle_count, rectangle_order;
gint i;
retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
gdk_pixbuf_fill (retval, 0);
rectangles = XShapeGetRectangles ( gdk_x11_get_default_xdisplay(), window,
ShapeBounding, &rectangle_count, &rectangle_order);
display = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
rectangles = XShapeGetRectangles (display, window, ShapeBounding,
&rectangle_count, &rectangle_order);
for (i = 0; i < rectangle_count; i++)
{
......@@ -120,25 +118,25 @@ static GdkPixbuf *
take_window_shot (Window child,
gboolean include_decoration)
{
GdkWindow *window;
Display *disp;
Window w, xid;
gint x_orig, y_orig;
gint x = 0, y = 0;
gint width, height;
GdkPixbuf *tmp, *tmp2;
GdkPixbuf *retval;
disp = gdk_x11_get_default_xdisplay ();
w = gdk_x11_get_default_root_xwindow ();
GdkDisplay *display;
GdkScreen *screen;
GdkWindow *window;
Window xid;
gint x_orig, y_orig;
gint x = 0, y = 0;
gint width, height;
GdkPixbuf *tmp, *tmp2;
GdkPixbuf *retval;
display = gdk_display_get_default ();
screen = gdk_screen_get_default ();
if (include_decoration)
xid = find_toplevel_window (child);
xid = find_toplevel_window (gdk_x11_display_get_xdisplay (display), child);
else
xid = child;
window = gdk_window_foreign_new (xid);
window = gdk_window_foreign_new_for_display (display, xid);
gdk_drawable_get_size (window, &width, &height);
gdk_window_get_origin (window, &x_orig, &y_orig);
......@@ -157,11 +155,11 @@ take_window_shot (Window child,
y_orig = 0;
}
if (x_orig + width > gdk_screen_width ())
width = gdk_screen_width () - x_orig;
if (x_orig + width > gdk_screen_get_width (screen))
width = gdk_screen_get_width (screen) - x_orig;
if (y_orig + height > gdk_screen_height ())
height = gdk_screen_height () - y_orig;
if (y_orig + height > gdk_screen_get_height (screen))
height = gdk_screen_get_height (screen) - y_orig;
tmp = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
x, y, 0, 0, width, height);
......@@ -178,16 +176,17 @@ take_window_shot (Window child,
return retval;
}
int main (int argc, char **argv)
int
main (int argc, char **argv)
{
GList *toplevels;
GdkPixbuf *screenshot = NULL;
GList *node;
GList *toplevels;
GList *node;
/* If there's no DISPLAY, we silently error out. We don't want to break
* headless builds. */
if (! gtk_init_check (&argc, &argv))
return 0;
return EXIT_SUCCESS;
gimp_stock_init ();
......@@ -207,7 +206,7 @@ int main (int argc, char **argv)
window = info->window->window;
gtk_widget_show_now (info->window);
gtk_widget_draw (info->window, &(info->window->allocation));
gtk_widget_queue_draw (info->window);
while (gtk_events_pending ())
{
......@@ -228,5 +227,5 @@ int main (int argc, char **argv)
gtk_widget_hide (info->window);
}
return 0;
return EXIT_SUCCESS;
}
#include <gdk/gdkkeysyms.h>
#include <X11/Xatom.h>
#include "config.h"
#include <gdk/gdkx.h>
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "widgets.h"
......@@ -13,29 +16,6 @@
#define LARGE_WIDTH 240
#define LARGE_HEIGHT 240
static Window
find_toplevel_window (Window xid)
{
Window root, parent, *children;
int nchildren;
do
{
if (XQueryTree (gdk_display (), xid, &root,
&parent, &children, &nchildren) == 0)
{
g_warning ("Couldn't find window manager window");
return None;
}
if (root == parent)
return xid;
xid = parent;
}
while (TRUE);
}
static gboolean
adjust_size_callback (WidgetInfo *info)
......@@ -254,7 +234,7 @@ create_combo_box_entry (void)
{
GtkWidget *widget;
GtkWidget *align;
gtk_rc_parse_string ("style \"combo-box-entry-style\" {\n"
" GtkComboBox::appears-as-list = 1\n"
"}\n"
......@@ -272,7 +252,7 @@ create_combo_box (void)
{
GtkWidget *widget;
GtkWidget *align;
gtk_rc_parse_string ("style \"combo-box-style\" {\n"
" GtkComboBox::appears-as-list = 0\n"
"}\n"
......@@ -516,11 +496,11 @@ create_colorsel (void)
color.blue = 0x9595;
gtk_color_selection_set_previous_color (colorsel, &color);
color.red = 0x7d7d;
color.green = 0x9393;
color.blue = 0xc3c3;
gtk_color_selection_set_current_color (colorsel, &color);
info = new_widget_info ("colorsel", widget, ASIS);
......@@ -552,9 +532,9 @@ create_filesel (void)
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
NULL);
gtk_window_set_default_size (GTK_WINDOW (widget), 505, 305);
info = new_widget_info ("filechooser", widget, ASIS);
info->include_decorations = TRUE;
......@@ -634,7 +614,7 @@ create_notebook (void)
widget = gtk_notebook_new ();
gtk_notebook_append_page (GTK_NOTEBOOK (widget),
gtk_notebook_append_page (GTK_NOTEBOOK (widget),
gtk_label_new ("Notebook"),
NULL);
gtk_notebook_append_page (GTK_NOTEBOOK (widget), gtk_event_box_new (), NULL);
......@@ -672,7 +652,7 @@ create_scrolledwindow (void)
scrolledwin = gtk_scrolled_window_new (NULL, NULL);
label = gtk_label_new ("Scrolled Window");
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwin),
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwin),
label);
return new_widget_info ("scrolledwindow", scrolledwin, MEDIUM);
......
#ifndef __WIDGETS_H__
#define __WIDGETS_H__
#include <gtk/gtk.h>
typedef enum
{
......@@ -14,14 +12,14 @@ typedef enum
typedef struct WidgetInfo
{
GtkWidget *window;
gchar *name;
gboolean no_focus;
gboolean include_decorations;
WidgetSize size;
GtkWidget *window;
gchar *name;
gboolean no_focus;
gboolean include_decorations;
WidgetSize size;
} WidgetInfo;
GList *get_all_widgets (void);
GList * get_all_widgets (void);
#endif /* __WIDGETS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment