[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] Actions for window fullscreen



Hi!

well it's not a unified diff - so it'll have to be rejected (ie  a diff with the
+'s and -'s at the start of lines). also please attach diffs to mails - not
inline them :)

Took the liberty of an inline cvs diff as it was meant only for
viewing :) Sorry anyway... Here's the diff -Naur for e_actions.c
against v1.70 attached..

Regards,
Ramkumar.

--
April 1: This is the day upon which we are reminded of
what we are on the other three hundred and sixty-four.
         -- Mark Twain, "Pudd'nhead Wilson's Calendar"
--- e_actions.c.orig	2006-06-20 20:59:49.791174768 +0530
+++ e_actions.c	2006-06-19 22:10:52.583990632 +0530
@@ -353,6 +353,67 @@
 }
 
 /***************************************************************************/
+ACT_FN_GO(window_fullscreen_toggle)
+{
+   if (!obj) obj = E_OBJECT(e_border_focused_get());
+   if (!obj) return;
+   if (obj->type != E_BORDER_TYPE)
+     {
+	obj = E_OBJECT(e_border_focused_get());
+	if (!obj) return;
+     }
+   if (!((E_Border *)obj)->lock_user_fullscreen)
+     {
+	E_Border *bd;
+	bd = (E_Border *)obj;
+	if (bd->fullscreen)
+	  e_border_unfullscreen(bd);
+	else if (params == 0 || *params == '\0')
+	  e_border_fullscreen(bd, e_config->fullscreen_policy);
+	else if (! strcmp(params, "resize"))
+	  e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
+	else if (! strcmp(params, "zoom"))
+	  e_border_fullscreen(bd, E_FULLSCREEN_ZOOM);
+     }
+}
+
+/***************************************************************************/
+ACT_FN_GO(window_fullscreen)
+{
+   if (!obj) obj = E_OBJECT(e_border_focused_get());
+   if (!obj) return;
+   if (obj->type != E_BORDER_TYPE)
+     {
+	obj = E_OBJECT(e_border_focused_get());
+	if (!obj) return;
+     }
+   if (!((E_Border *)obj)->lock_user_fullscreen)
+     {
+	E_Border *bd;
+	bd = (E_Border *)obj;
+	if (params)
+	  {
+	     int v;
+	     char buf[32];
+	     if (sscanf(params, "%i %20s", &v, buf) == 2)
+	       {
+		  if (v == 1)
+		    {
+		      if (buf == 0 || *buf == '\0')
+			e_border_fullscreen(bd, e_config->fullscreen_policy);
+		      else if (! strcmp(buf, "resize"))
+			e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
+		      else if (! strcmp(buf, "zoom"))
+			e_border_fullscreen(bd, E_FULLSCREEN_ZOOM);
+		    }
+		  else if (v == 0)
+		    e_border_unfullscreen(bd);
+	       }
+	  }
+     }
+}
+
+/***************************************************************************/
 ACT_FN_GO(window_maximized_toggle)
 {
    if (!obj) obj = E_OBJECT(e_border_focused_get());
@@ -1201,6 +1262,97 @@
      }
 }
 
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#define UNIX_PATH_MAX 108
+
+#include <netinet/in.h>
+#include <netdb.h>
+
+ACT_FN_GO(sock)
+{
+  if (params)
+    {
+      struct sockaddr* addr = NULL;
+      char *buf, *token, *type;
+      int fd, addrlen, flag = 0;
+      buf = strdup (params);
+      if (! (token = strtok (buf, " "))) goto final;
+      type = token;
+      if (! (token = strtok (NULL, " "))) goto final;
+      if ((! strncmp (type, "unix", 4) && (flag = 1)) ||
+	  (! strncmp (type, "unix-abs", 4) && (flag = 2)))
+	{
+	  struct sockaddr_un *caddr;
+	  if ((fd = socket (AF_UNIX, SOCK_DGRAM, 0)) < 0) goto final;
+	  caddr = (struct sockaddr_un*) malloc (sizeof (struct sockaddr_un));
+	  caddr->sun_family = AF_UNIX;
+	  if (flag == 1)
+	      strncpy (caddr->sun_path, token, UNIX_PATH_MAX);
+	  else
+	    {
+	      *(caddr->sun_path) = '\0';
+	      strncpy (caddr->sun_path + 1, token, UNIX_PATH_MAX - 1);
+	    }
+	  addr = (struct sockaddr*) caddr;
+	  addrlen = sizeof (struct sockaddr_un);
+	}
+      else if ((! strcmp (type, "udp") && (flag = 3)) ||
+	       (! strcmp (type, "tcp") && (flag = 4)))
+	{
+	  struct addrinfo hints;
+	  struct addrinfo* caddr, *ptr;
+	  char *colon;
+	  if (! (colon = strchr (token, ':'))) goto final;
+	  *colon = '\0';
+	  memset (&hints, 0, sizeof (struct addrinfo));
+	  hints.ai_family = AF_INET;
+	  hints.ai_socktype = ((flag == 3) ? SOCK_DGRAM : SOCK_STREAM);
+	  if (getaddrinfo (token, colon + 1, &hints, &caddr)) goto final;
+	  for (ptr = caddr; ptr; ptr = ptr->ai_next)
+	    {
+	      if (ptr->ai_family == hints.ai_family &&
+		  ptr->ai_socktype == hints.ai_socktype)
+		{
+		  if ((fd = socket (ptr->ai_family, ptr->ai_socktype,
+				    ptr->ai_protocol)) < 0)
+		    ptr = NULL;
+		  else
+		    {
+		      addrlen = ptr->ai_addrlen;
+		      addr = (struct sockaddr*) malloc (addrlen);
+		      memcpy (addr, ptr->ai_addr, addrlen);
+		    }
+		  break;
+		}
+	    }
+	  freeaddrinfo (caddr);
+	  if (! ptr) goto final;
+	}
+      else goto final;
+      if (connect (fd, addr, addrlen) < 0) goto finish;
+      token = strtok (NULL, "");
+      {
+	size_t towrite = strlen (token);
+	ssize_t res;
+	while (towrite)
+	  {
+	    int res = write (fd, token, towrite);
+	    if (res < 0 && errno == EINTR) continue;
+	    if (res <= 0) break;
+	    towrite -= res;
+	    token += res;
+	  }
+      }
+    finish:
+      close (fd);
+      free (addr);
+    final:
+      free (buf);
+    }
+}
+
 /***************************************************************************/
 ACT_FN_GO(app)
 {
@@ -1594,6 +1746,14 @@
    
    ACT_GO(window_iconic);
    
+   /* window_fullscreen_toggle */
+   ACT_GO(window_fullscreen_toggle);
+   e_register_action_predef_name(_("Window : State"), _("Fullscreen Mode Toggle"),
+				 "window_fullscreen_toggle", NULL,
+				 EDIT_RESTRICT_ACTION | EDIT_RESTRICT_PARAMS, 0);
+
+   ACT_GO(window_fullscreen);
+
    /* window_maximized_toggle */
    ACT_GO(window_maximized_toggle);
    e_register_action_predef_name(_("Window : State"), _("Maximize"), "window_maximized_toggle",
@@ -1795,6 +1955,11 @@
    e_register_action_predef_name(_("Launch"), _("Defined Command"), "exec", NULL,
 				 EDIT_RESTRICT_ACTION, 0);
 
+   /* sock */
+   ACT_GO(sock);
+   e_register_action_predef_name(_("Launch"), _("Output to socket"), "sock", NULL,
+				 EDIT_RESTRICT_ACTION, 0);
+
    /* app */
    ACT_GO(app);
    e_register_action_predef_name(_("Launch"), _("Application"), "app", NULL,