]> Dogcows Code - chaz/tint2/commitdiff
freespace.patch
authorMishael A Sibiryakov <mishael.sb.fallback@gmail.com>
Wed, 27 Mar 2013 17:43:30 +0000 (11:43 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 27 Mar 2013 17:43:30 +0000 (11:43 -0600)
http://code.google.com/p/tint2/issues/detail?id=382

CMakeLists.txt
src/freespace/freespace.c [new file with mode: 0644]
src/freespace/freespace.h [new file with mode: 0644]
src/panel.c
src/panel.h

index 3b5a0f30ce92d620ebb1620e823b6c78420a6b42..dda1f1a13ec092611b2d449d77b99e30bd4250f9 100644 (file)
@@ -32,6 +32,7 @@ include_directories( ${PROJECT_BINARY_DIR}
                      src/taskbar
                      src/launcher
                      src/tooltip
+                                        src/freespace
                      src/util
                      ${X11_INCLUDE_DIRS}
                      ${PANGOCAIRO_INCLUDE_DIRS}
@@ -55,6 +56,7 @@ set( SOURCES src/config.c
              src/taskbar/taskbar.c
              src/taskbar/taskbarname.c
              src/tooltip/tooltip.c
+             src/freespace/freespace.c
              src/util/area.c
              src/util/common.c
              src/util/timer.c
diff --git a/src/freespace/freespace.c b/src/freespace/freespace.c
new file mode 100644 (file)
index 0000000..6ff9615
--- /dev/null
@@ -0,0 +1,100 @@
+/**************************************************************************
+*
+* Tint2 : freespace
+*
+* Copyright (C) 2011 Mishael A Sibiryakov (death@junki.org)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License version 2
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+**************************************************************************/
+
+
+#include <string.h>
+#include <stdio.h>
+#include <cairo.h>
+#include <cairo-xlib.h>
+#include <pango/pangocairo.h>
+#include <stdlib.h>
+
+#include "window.h"
+#include "server.h"
+#include "panel.h"
+#include "freespace.h"
+#include "common.h"
+
+typedef enum {
+       COUNT_WIDTH,
+       COUNT_HEIGHT
+} SpaceType ;
+
+void init_freespace_panel(void *p)
+{
+       Panel *panel =(Panel*)p;
+       FreeSpace *fsp= &panel->freespace;
+
+       if (fsp->area.bg == 0)
+               fsp->area.bg = &g_array_index(backgrounds, Background, 0);
+       fsp->area.parent = p;
+       fsp->area.panel = p;
+       fsp->area.size_mode = SIZE_BY_CONTENT;
+       fsp->area.resize = 1;
+       fsp->area.on_screen = 1;
+       fsp->area._resize = resize_freespace;
+}
+
+int freespace_get_max_size(Panel *p, SpaceType t) {
+
+       GSList *walk;
+       Area *a;
+       int sz = 0;
+
+       // Get space used by every element except the freespace
+       for (walk = p->area.list; walk; walk = g_slist_next(walk)) {
+               a = (Area *)walk->data;
+
+               // Skip self
+               if (a->_resize == resize_freespace)
+                       continue;
+
+               if (t == COUNT_WIDTH)
+                       sz += a->width + (a->bg->border.width * 2) + p->area.paddingx;
+
+               if (t == COUNT_HEIGHT)
+                       sz += a->height + (a->bg->border.width * 2) + p->area.paddingy;
+       }
+
+       if (t == COUNT_WIDTH)
+               sz = p->area.width - sz - (p->area.bg->border.width * 2) - p->area.paddingxlr;
+
+       if (t == COUNT_HEIGHT)
+               sz = p->area.height - sz - (p->area.bg->border.width * 2) - p->area.paddingxlr; // Not sure about paddingxlr
+
+       return sz;
+}
+
+int resize_freespace(void *obj) {
+
+       FreeSpace *fsp= (FreeSpace *)obj;
+       Panel *panel = (Panel *)fsp->area.panel;
+
+       fsp->area.redraw = 1;
+
+       if (panel_horizontal)
+               fsp->area.width = freespace_get_max_size(panel, COUNT_WIDTH);
+       else
+               fsp->area.height= freespace_get_max_size(panel, COUNT_HEIGHT);
+
+       // Always resize
+       fsp->area.resize = 1;
+
+       return 1;
+}
diff --git a/src/freespace/freespace.h b/src/freespace/freespace.h
new file mode 100644 (file)
index 0000000..053e963
--- /dev/null
@@ -0,0 +1,20 @@
+/**************************************************************************
+* Copyright (C) 2011 Mishael A Sibiryakov (death@junki.org)
+**************************************************************************/
+
+#ifndef FREESPACE_H
+#define FREESPACE_H
+
+#include "common.h"
+#include "area.h"
+
+typedef struct FreeSpace {
+       Area area;
+} FreeSpace;
+
+void cleanup_freespace();
+void init_freespace_panel(void *panel);
+
+int resize_freespace(void *obj);
+
+#endif
index b136ff34bf11404194f75c1c1b7853111fef8be2..2a442b9b877218b5eda9f1afa860769363e19450 100644 (file)
@@ -190,6 +190,9 @@ void init_panel()
                        }
                        if (panel_items_order[k] == 'C')
                                init_clock_panel(p);
+
+                       if (panel_items_order[k] == 'F')
+                               init_freespace_panel(p);
                }
                set_panel_items_order(p);
 
@@ -409,6 +412,9 @@ void set_panel_items_order(Panel *p)
                }
                if (panel_items_order[k] == 'C')
                        p->area.list = g_slist_append(p->area.list, &p->clock);
+
+               if (panel_items_order[k] == 'F')
+                       p->area.list = g_slist_append(p->area.list, &p->freespace);
        }
        init_rendering(&p->area, 0);
 }
index 86e7e1adbe48be4b7a55cb1812288760cd6d6a34..010a758a411f0ca4e9c4391cc65cce85ee6083fd 100644 (file)
@@ -20,6 +20,7 @@
 #include "taskbar.h"
 #include "systraybar.h"
 #include "launcher.h"
+#include "freespace.h"
 
 #ifdef ENABLE_BATTERY
 #include "battery.h"
@@ -114,6 +115,8 @@ typedef struct {
 
        Launcher launcher;
 
+       FreeSpace freespace;
+
        // autohide
        int is_hidden;
        int hidden_width, hidden_height;
This page took 0.027 seconds and 4 git commands to generate.