[Pkg-wmaker-commits] [wmshutdown] 91/173: * Apply patches from Debian: - Rename wmShutdown.* -> wmshutdown.*. - Rename shutdown.c -> wmshutdown-run.c. - Various other bugfixes. * Convert to GTK3.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Tue Aug 25 02:46:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmshutdown.
commit 77c5aab6424d9e8dfac8fddb792ed0ecdc27eae7
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Sat Jul 26 01:28:40 2014 -0500
* Apply patches from Debian:
- Rename wmShutdown.* -> wmshutdown.*.
- Rename shutdown.c -> wmshutdown-run.c.
- Various other bugfixes.
* Convert to GTK3.
---
wmShutdown.c | 170 ---------------------------------------
shutdown.c => wmshutdown-run.c | 32 ++++----
wmshutdown.c | 163 +++++++++++++++++++++++++++++++++++++
wmShutdown.xpm => wmshutdown.xpm | 0
4 files changed, 179 insertions(+), 186 deletions(-)
diff --git a/wmShutdown.c b/wmShutdown.c
deleted file mode 100644
index 7f7e14e..0000000
--- a/wmShutdown.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * wmShutdown.c
- *
- * (C) 2001 Rafael V. Aroca <rafael at linuxqos.cjb.net>
- *
- * This software is under GPL
- *
- * Based on foodock lib by Alexey Vyskubov <alexey at pepper.spb.ru>
- *
- */
-
-#include "wmShutdown.h"
-
-GtkWidget *dialog = NULL;
-
-GtkWidget *cria_dock(GtkWidget *mw, unsigned int s, int margc, char *margv[]) {
-
- GtkWidget *foobox;
- Window xmw;
- XWMHints *wm_hints;
-
- xmw = GDK_WINDOW_XWINDOW(mw->window);
-
- foobox = gtk_event_box_new();
- gtk_widget_set_usize(foobox, s, s);
- gtk_container_add (GTK_CONTAINER (mw), foobox);
- gtk_widget_realize(foobox);
-
- wm_hints = XAllocWMHints();
- wm_hints->window_group = xmw;
- wm_hints->icon_window = GDK_WINDOW_XWINDOW(foobox->window);
- wm_hints->icon_x = 0;
- wm_hints->icon_y = 0;
- wm_hints->initial_state = WithdrawnState;
- wm_hints->flags = StateHint |
- IconPositionHint |
- WindowGroupHint |
- IconWindowHint;
-
- XSetWMHints(GDK_DISPLAY(), xmw, wm_hints);
- XSetCommand(GDK_DISPLAY(), xmw, margv, margc);
-
- XFree(wm_hints);
-
- return foobox;
-}
-
-
-int fecha(void) {
- //gtk_exit(0);
- gtk_widget_destroy(dialog);
- dialog = NULL;
- //close();
-}
-
-int desliga(void) {
- FILE *output;
- char *teste;
-
- output = popen("/usr/local/bin/Shutdown -h", "r");
- teste = (char*) fgetc(output);
- while ((int)teste != EOF) {
- g_print("%c", teste);
- teste = (char*) fgetc(output);
- }
- pclose(output);
-}
-
-int reinicia(void) {
- FILE *output;
- char *teste;
-
- output = popen("/usr/local/bin/Shutdown -r", "r");
- teste = (char*) fgetc(output);
- while ((int)teste != EOF) {
- g_print("%c", teste);
- teste = (char*) fgetc(output);
- }
- pclose(output);
-}
-
-
-int button_press(GtkWidget *widget, GdkEvent *event) {
-
- GtkWidget *label;
- gchar *message;
- GtkWidget *halt_button;
- GtkWidget *reboot_button;
- GtkWidget *cancel_button;
-
- //Descomentar para debug
- //g_print("Evento ocorreu");
-
- if (event->type == GDK_BUTTON_PRESS) {
- GdkEventButton *bevent = (GdkEventButton *)event;
-
- switch (bevent->button) {
- case 1:
-
- if (dialog != NULL)
- return;
- message = "Shutdown confirmation";
- dialog = gtk_dialog_new();
- label = gtk_label_new (message);
-
- halt_button = gtk_button_new_with_label("Halt");
- reboot_button = gtk_button_new_with_label("Reboot");
- cancel_button = gtk_button_new_with_label("Cancel");
-
- gtk_signal_connect(GTK_OBJECT(dialog), "destroy", GTK_SIGNAL_FUNC(fecha), NULL);
-
- gtk_signal_connect_object (GTK_OBJECT (cancel_button), "clicked", GTK_SIGNAL_FUNC (fecha), (gpointer) dialog);
-
- gtk_signal_connect_object (GTK_OBJECT (halt_button), "clicked", GTK_SIGNAL_FUNC (desliga), (gpointer) dialog);
-
- gtk_signal_connect_object (GTK_OBJECT (reboot_button), "clicked", GTK_SIGNAL_FUNC (reinicia), (gpointer) dialog);
-
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), halt_button);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), reboot_button);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), cancel_button);
-
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label);
-
- gtk_widget_show_all (dialog);
- }
- }
-}
-
-
-int main(int argc, char *argv[]) {
-
- GtkWidget *gtkiw;
- GtkWidget *dockArea;
- GtkWidget *button;
- GtkWidget *box1;
- GtkWidget *icon;
- GtkWidget *pixmap;
- GdkBitmap *mask;
-
- gtk_init(&argc, &argv);
- gtk_set_locale();
-
- gtkiw = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (gtkiw), "ShutDockApp");
- gtk_widget_realize(gtkiw);
-
- dockArea = cria_dock(gtkiw, 47, argc, argv);
- gtk_widget_realize(dockArea);
-
- icon = (gpointer) gdk_pixmap_create_from_xpm (gtkiw->window, &mask,
- NULL, "/usr/share/pixmaps/wmShutdown.xpm");
-
- pixmap = gtk_pixmap_new((gpointer) icon, mask);
- gtk_widget_show(pixmap);
- gtk_container_add(GTK_CONTAINER(dockArea), pixmap);
-
- gtk_signal_connect(GTK_OBJECT(gtkiw),
- "event",
- GTK_SIGNAL_FUNC(button_press),
- NULL);
-
- gtk_widget_show(dockArea);
- gtk_widget_show(gtkiw);
-
- gtk_main ();
-
- return(0);
-}
-
-
diff --git a/shutdown.c b/wmshutdown-run.c
similarity index 59%
rename from shutdown.c
rename to wmshutdown-run.c
index 857c410..4cff380 100644
--- a/shutdown.c
+++ b/wmshutdown-run.c
@@ -1,7 +1,7 @@
/*
* shutdown.c
*
- * (C) 2001 Rafael V. Aroca <rafael at linuxqos.cjb.net>
+ * (C) 2001 Rafael V. Aroca <rafael at linuxqos.cjb.net>
*
*/
@@ -14,35 +14,35 @@ int main(int argc, char **argv) {
if (argv[1] != NULL) {
if (strcmp((char*)argv[1], "-r") == 0) {
- char *teste;
+ int ch;
FILE *output;
printf("Rebooting...\n");
output = popen("/sbin/shutdown now -r", "r");
- teste = (char*) fgetc(output);
- while ((int)teste != EOF) {
- printf("%c", teste);
- teste = (char*) fgetc(output);
+ ch = fgetc(output);
+ while (ch != EOF) {
+ printf("%c", ch);
+ ch = fgetc(output);
}
pclose(output);
- }
-
+ }
+
if (strcmp(argv[1], "-h") == 0) {
- char *teste;
+ int ch;
FILE *output;
printf("Halting...\n");
output = popen("/sbin/shutdown now -h", "r");
- teste = (char*) fgetc(output);
- while ((int)teste != EOF) {
- printf("%c", teste);
- teste = (char*) fgetc(output);
+ ch = fgetc(output);
+ while (ch != EOF) {
+ printf("%c", ch);
+ ch = fgetc(output);
}
pclose(output);
- }
+ }
- if (!strcmp(argv[1], "-h") == 0 && !strcmp(argv[1], "-r") == 0)
+ if (!strcmp(argv[1], "-h") == 0 && !strcmp(argv[1], "-r") == 0)
printf("Nothing done.\n");
- } else printf("Nothing done.\n");
+ } else printf("Nothing done.\n");
}
diff --git a/wmshutdown.c b/wmshutdown.c
new file mode 100644
index 0000000..3db66d5
--- /dev/null
+++ b/wmshutdown.c
@@ -0,0 +1,163 @@
+/*
+ * wmshutdown.c
+ *
+ * (C) 2001 Rafael V. Aroca <rafael at linuxqos.cjb.net>
+ *
+ * This software is under GPL
+ *
+ * Based on foodock lib by Alexey Vyskubov <alexey at pepper.spb.ru>
+ *
+ */
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+GtkWidget *dialog = NULL;
+
+/* gtk3 dockapp code based on wmpasman by Brad Jorsch
+ * <anomie at users.sourceforge.net>
+ * http://sourceforge.net/projects/wmpasman/
+ */
+GtkWidget *cria_dock(GtkWidget *mw, unsigned int s) {
+ GdkDisplay *display;
+ GtkWidget *foobox;
+
+ display = gdk_display_get_default();
+ foobox = gtk_window_new(GTK_WINDOW_POPUP);
+
+ gtk_window_set_wmclass(GTK_WINDOW(mw), g_get_prgname(), "DockApp");
+ gtk_widget_set_size_request(foobox, 47, 47);
+
+ gtk_widget_realize(mw);
+ gtk_widget_realize(foobox);
+
+ Display *d = GDK_DISPLAY_XDISPLAY(display);
+ Window mainwin = GDK_WINDOW_XID(gtk_widget_get_window(mw));
+ Window iw = GDK_WINDOW_XID(gtk_widget_get_window(foobox));
+ Window p, dummy1, *dummy2;
+ unsigned int dummy3;
+ XQueryTree(d, mainwin, &dummy1, &p, &dummy2, &dummy3);
+ if (dummy2) XFree(dummy2);
+ Window w = XCreateSimpleWindow(d, p, 0, 0, 1, 1, 0, 0, 0);
+ XReparentWindow(d, mainwin, w, 0, 0);
+ gtk_widget_show(mw);
+ gtk_widget_show(foobox);
+ XWMHints *wmHints = XGetWMHints(d, mainwin);
+ if (!wmHints) {
+ wmHints = XAllocWMHints();
+ }
+ wmHints->flags |= IconWindowHint;
+ wmHints->icon_window = iw;
+ XSetWMHints(d, mainwin, wmHints);
+ XFree(wmHints);
+ XReparentWindow(d, mainwin, p, 0, 0);
+ XDestroyWindow(d, w);
+
+ return foobox;
+}
+
+int fecha(void) {
+ gtk_widget_destroy(dialog);
+ dialog = NULL;
+}
+
+int desliga(void) {
+ FILE *output;
+ int ch;
+
+ output = popen("wmshutdown-run -h", "r");
+ ch = fgetc(output);
+ while (ch != EOF) {
+ printf("%c", ch);
+ ch = fgetc(output);
+ }
+ pclose(output);
+}
+
+int reinicia(void) {
+ FILE *output;
+ int ch;
+
+ output = popen("wmshutdown-run -r", "r");
+ ch = fgetc(output);
+ while (ch != EOF) {
+ g_print("%c", ch);
+ ch = fgetc(output);
+ }
+ pclose(output);
+}
+
+
+int button_press(GtkWidget *widget, GdkEvent *event) {
+ GtkWidget *label;
+ gchar *message;
+ GtkWidget *halt_button;
+ GtkWidget *reboot_button;
+ GtkWidget *cancel_button;
+
+ GdkEventButton *bevent = (GdkEventButton *)event;
+ switch (bevent->button) {
+ case 1:
+ if (dialog != NULL)
+ return 1;
+ message = "Shutdown confirmation";
+ dialog = gtk_dialog_new();
+ label = gtk_label_new(message);
+
+ halt_button = gtk_button_new_with_label("Halt");
+ reboot_button = gtk_button_new_with_label("Reboot");
+ cancel_button = gtk_button_new_with_label("Cancel");
+
+ g_signal_connect(dialog, "destroy", G_CALLBACK(fecha), NULL);
+ g_signal_connect(cancel_button,
+ "clicked",
+ G_CALLBACK(fecha),
+ (gpointer) dialog);
+ g_signal_connect(halt_button,
+ "clicked",
+ G_CALLBACK(desliga),
+ (gpointer) dialog);
+ g_signal_connect(reboot_button,
+ "clicked",
+ G_CALLBACK(reinicia),
+ (gpointer) dialog);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(
+ GTK_DIALOG(dialog))),
+ halt_button);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(
+ GTK_DIALOG(dialog))),
+ reboot_button);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(
+ GTK_DIALOG(dialog))),
+ cancel_button);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(
+ GTK_DIALOG(dialog))),
+ label);
+ gtk_widget_show_all(dialog);
+ }
+}
+
+int main(int argc, char *argv[]) {
+ GdkDisplay *display;
+ GtkWidget *gtkiw;
+ GtkWidget *dockArea;
+ GtkWidget *pixmap;
+
+ gtk_init(&argc, &argv);
+
+ gtkiw = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ dockArea = cria_dock(gtkiw, 47);
+
+
+ pixmap = gtk_image_new_from_file(DATADIR"/wmshutdown.xpm");
+ gtk_widget_show(pixmap);
+ gtk_container_add(GTK_CONTAINER(dockArea), pixmap);
+
+ gtk_widget_add_events(dockArea, GDK_BUTTON_PRESS_MASK);
+ g_signal_connect(dockArea, "button-press-event",
+ G_CALLBACK(button_press), NULL);
+
+ gtk_main();
+
+ return(0);
+}
diff --git a/wmShutdown.xpm b/wmshutdown.xpm
similarity index 100%
rename from wmShutdown.xpm
rename to wmshutdown.xpm
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmshutdown.git
More information about the Pkg-wmaker-commits
mailing list