Enlightenment CVS committal

Author  : mekius
Project : e17
Module  : proto

Dir     : e17/proto/empower/src/bin


Modified Files:
        empower.c 


Log Message:
Split up code because i was bored.

===================================================================
RCS file: /cvs/e/e17/proto/empower/src/bin/empower.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- empower.c   4 Apr 2006 01:19:55 -0000       1.5
+++ empower.c   4 Apr 2006 02:46:44 -0000       1.6
@@ -1,83 +1,9 @@
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include "Ewl.h"
-
-#define WIDTH 250
-#define HEIGHT 100
-
-char buf[1024];
-Ewl_Widget *win = NULL;
-char password[1024];
-
-int xpos, ypos;
-
-void check_key(Ewl_Widget *w, void *event, void *data)
-{
-       Ewl_Event_Key_Down *ev;
-       
-       ev = event;
-       
-       if(!ev->modifiers)
-       {
-               if(strcmp(ev->keyname, "Escape") == 0)
-               {
-                       ewl_widget_destroy(win);
-                       ewl_main_quit();
-               }
-       }
-}
-
-void destroy_cb(Ewl_Widget *w, void *event, void *data)
-{
-       ewl_widget_destroy(win);
-       ewl_main_quit();
-}
-
-void reveal_cb(Ewl_Widget *w, void *event, void *data)
-{
-       ewl_window_move(EWL_WINDOW(win), xpos, ypos);
-}
-
-void pipe_to_sudo(Ewl_Widget *w, void *event, void *data)
-{      
-       FILE *sudo_pipe;
-       
-       const char *pass = ewl_password_text_get(EWL_PASSWORD(data));
-       
-       if(pass)
-       {
-               snprintf(password, 1024, "%s", pass);
-               
-               pid_t pid = fork();
-               
-               if(pid == 0)
-               {       
-                       ewl_window_keyboard_grab_set(EWL_WINDOW(win), 0);
-                       ewl_window_pointer_grab_set(EWL_WINDOW(win), 0);
-                       sudo_pipe = popen(buf, "w");
-                       fprintf(sudo_pipe, "%s\n", password);
-                       pclose(sudo_pipe);
-               }       
-               else
-               {               
-                       ewl_widget_destroy(win);
-                       wait(pid);
-               }
-       }
-       ewl_main_quit();
-}
+#include "Empower.h"
 
 int main(int argc, char** argv)
 {
        --argc; ++argv;
        
-       Ewl_Widget *entry = NULL;
-       Ewl_Widget *ok_button = NULL;
-       Ewl_Widget *cancel_button = NULL;
-       Ewl_Widget *progtext = NULL;
-       Ewl_Widget *vbox=NULL, *hbox = NULL;
-       
        if(argc)        //commands
        {
                pid_t id = fork();
@@ -106,98 +32,7 @@
                return 1;
        }
        
-       if(!ecore_x_init(NULL))
-       {
-               printf("Unable to init ecore\n");
-               return 1;
-       }
-       
-       if(!ewl_init(&argc, argv))
-       {
-               printf("Unable to init ewl\n");
-               return 1;
-       }
-       
-       int num_roots=0;
-       int root_w=0, root_h=0;
-       Ecore_X_Window *root_list = NULL;
-       root_list = ecore_x_window_root_list(&num_roots);
-       
-       /*FIXME: add checks for xinerama*/
-       ecore_x_window_size_get(root_list[0], &root_w, &root_h);
-       
-       free(root_list);
-       
-       xpos = (root_w/2)-(WIDTH/2);
-       ypos = (root_h/2)-(HEIGHT/2);
-       
-       win = ewl_window_new();
-       ewl_window_title_set(EWL_WINDOW(win), "Empower!");
-       ewl_window_name_set(EWL_WINDOW(win), "Empower!");
-       ewl_window_class_set(EWL_WINDOW(win), "Empower!");
-       ewl_object_size_request(EWL_OBJECT(win), WIDTH, HEIGHT);
-       ewl_window_move(EWL_WINDOW(win), xpos, ypos);
-       ewl_window_borderless_set(EWL_WINDOW(win));
-       ewl_window_raise(EWL_WINDOW(win));
-       ewl_window_keyboard_grab_set(EWL_WINDOW(win), 1);
-       ewl_window_pointer_grab_set(EWL_WINDOW(win), 1);
-       ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, destroy_cb, NULL);
-       ewl_callback_append(win, EWL_CALLBACK_REVEAL, reveal_cb, NULL);
-       ewl_callback_append(win, EWL_CALLBACK_KEY_DOWN, check_key, NULL);
-       ewl_widget_show(win);
-       
-       vbox = ewl_vbox_new();
-       ewl_container_child_append(EWL_CONTAINER(win), vbox);
-       ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
-       ewl_widget_show(vbox);
-       
-       hbox = ewl_hbox_new();
-       ewl_container_child_append(EWL_CONTAINER(vbox), hbox);
-       ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL);
-       ewl_widget_show(hbox);
-       
-       progtext = ewl_label_new();
-       ewl_label_text_set(EWL_LABEL(progtext), "Password: ");
-       ewl_object_padding_set(EWL_OBJECT(progtext),5,0,24,0);
-       ewl_container_child_append(EWL_CONTAINER(hbox), progtext);
-       ewl_object_maximum_size_set(EWL_OBJECT(progtext), 75, 20);
-       ewl_widget_show(progtext);
-       
-       entry = ewl_password_new();
-       ewl_container_child_append(EWL_CONTAINER(hbox), entry);
-       ewl_object_padding_set(EWL_OBJECT(entry),0,0,20,0);
-       ewl_object_size_request(EWL_OBJECT(entry), 50, 20);
-       ewl_callback_append(entry, EWL_CALLBACK_VALUE_CHANGED, pipe_to_sudo, 
entry);
-       ewl_widget_show(entry);
-       
-       Ewl_Widget *separator = ewl_hseparator_new();
-       ewl_container_child_append(EWL_CONTAINER(vbox), separator);
-       ewl_widget_color_set(EWL_WIDGET(separator),200,200,200,200);
-       ewl_widget_show(separator);
-       
-       hbox = ewl_hbox_new();
-       ewl_container_child_append(EWL_CONTAINER(vbox), hbox);
-       ewl_object_alignment_set(EWL_OBJECT(hbox), EWL_FLAG_ALIGN_RIGHT);
-       ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_SHRINK);
-       ewl_widget_show(hbox);
-       
-       ok_button = ewl_button_new();
-       ewl_button_stock_type_set(EWL_BUTTON(ok_button), EWL_STOCK_OK);
-       ewl_object_maximum_size_set(EWL_OBJECT(ok_button), 35, 15);
-       ewl_object_fill_policy_set(EWL_OBJECT(ok_button), EWL_FLAG_FILL_SHRINK);
-       ewl_container_child_append(EWL_CONTAINER(hbox), ok_button);
-       ewl_callback_append(ok_button, EWL_CALLBACK_CLICKED, pipe_to_sudo, 
entry);
-       ewl_widget_show(ok_button);
-       
-       cancel_button = ewl_button_new();
-       ewl_button_stock_type_set(EWL_BUTTON(cancel_button), EWL_STOCK_CANCEL);
-       ewl_object_maximum_size_set(EWL_OBJECT(cancel_button), 60, 15);
-       ewl_object_fill_policy_set(EWL_OBJECT(cancel_button), 
EWL_FLAG_FILL_SHRINK);
-       ewl_container_child_append(EWL_CONTAINER(hbox), cancel_button);
-       ewl_callback_append(cancel_button, EWL_CALLBACK_CLICKED, destroy_cb, 
NULL);
-       ewl_widget_show(cancel_button);
-
-       ewl_main();
+       display_window(argc, argv);
        
        return 0;
 }




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to