Added bubble tool. Removed bubbles from doodle tool
authordanigm <dani@danigm.net>
Sat, 15 May 2010 20:03:32 +0000 (22:03 +0200)
committerdanigm <dani@danigm.net>
Sat, 15 May 2010 20:03:32 +0000 (22:03 +0200)
12 files changed:
README
data/icons/bubble.svg [new file with mode: 0644]
data/ui/tbo-toolbar-ui.xml
src/custom-stock.c
src/custom-stock.h
src/doodle-tool.c
src/doodle-tool.h
src/doodle-treeview.c
src/doodle-treeview.h
src/ui-drawing.c
src/ui-toolbar.c
src/ui-toolbar.h

diff --git a/README b/README
index fd4979c..521706f 100644 (file)
--- a/README
+++ b/README
@@ -24,6 +24,8 @@ the frame with "selector" tool. In frame view you can draw:
 
  * You can add some doodle with doodle-tool, selecting what you want
    from tool-area and drag&drop it into drawing area.
+ * You can add some bubbles with bubble-tool, selecting what you want
+   from tool-area and drag&drop it into drawing area.
  * You can add text to doodle with text-tool
  * You can select/Move/resize/rotate objects in frame with select-tool
  * You can resize an object using "<" and ">" keys.
diff --git a/data/icons/bubble.svg b/data/icons/bubble.svg
new file mode 100644 (file)
index 0000000..f06c95c
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="24"
+   height="24"
+   id="svg6003"
+   sodipodi:version="0.32"
+   inkscape:version="0.47 r22583"
+   version="1.0"
+   sodipodi:docname="bubble.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <defs
+     id="defs6005">
+    <linearGradient
+       id="linearGradient5740">
+      <stop
+         id="stop5742"
+         offset="0.0000000"
+         style="stop-color:#ffffff;stop-opacity:1.0000000;" />
+      <stop
+         id="stop5744"
+         offset="1.0000000"
+         style="stop-color:#98b6d3;stop-opacity:1.0000000;" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective6011" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient5740"
+       id="linearGradient2832"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1.13356,0,0,1.133368,320.43084,96.81233)"
+       x1="101.09393"
+       y1="221.06877"
+       x2="112.20101"
+       y2="234.00311" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient5740"
+       id="linearGradient2834"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.809546,0,0,0.809417,323.85544,224.09401)"
+       x1="144.08243"
+       y1="157.82079"
+       x2="176.86269"
+       y2="188.41277" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="13.541667"
+     inkscape:cx="12"
+     inkscape:cy="12"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1024"
+     inkscape:window-height="551"
+     inkscape:window-x="0"
+     inkscape:window-y="26"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata6008">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Capa 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-430.85714,-343.21933)">
+    <rect
+       style="fill:none;stroke:none;stroke-width:1.00000012;marker:none;display:inline"
+       id="rect4167"
+       width="24"
+       height="24"
+       x="430.85715"
+       y="343.21933" />
+    <rect
+       style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"
+       id="draw_rect1"
+       width="18.991671"
+       height="18.991779"
+       x="433.36545"
+       y="345.72754" />
+    <rect
+       style="fill:url(#linearGradient2832);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient2834);stroke-width:0.99999982;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"
+       id="rect5872"
+       width="17"
+       height="17"
+       x="434.35715"
+       y="346.71933" />
+    <path
+       style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.00835216;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+       d="m 442.79464,348.78183 c -3.94038,0 -7.125,2.37835 -7.125,5.3125 0,2.93415 3.18462,5.31249 7.125,5.31249 0.40272,0 0.80298,-0.0148 1.1875,-0.0625 l 2.6875,2.34375 -0.34375,-2.96875 c 2.15369,-0.91446 3.625,-2.64677 3.625,-4.625 0,-2.93415 -3.21587,-5.3125 -7.15625,-5.3125 z"
+       id="path2828" />
+  </g>
+</svg>
index 147e36a..9d1cc1f 100644 (file)
@@ -16,6 +16,7 @@
        <separator/>
        <toolitem name="doodle" action="Doodle"/>
        <toolitem name="text" action="Text"/>
+       <toolitem name="bubble" action="Bubble"/>
        <toolitem name="pix" action="Pix"/>
        <separator/>
        <toolitem name="zoom100" action="Zoom100"/>
index e900f8b..859da20 100644 (file)
@@ -23,6 +23,7 @@ void load_custom_stock ()
         {DATA_DIR ICONDIR "doodle.svg", TBO_STOCK_DOODLE},
         {DATA_DIR ICONDIR "text.svg", TBO_STOCK_TEXT},
         {DATA_DIR ICONDIR "pix.svg", TBO_STOCK_PIX},
+        {DATA_DIR ICONDIR "bubble.svg", TBO_STOCK_BUBBLE},
     };
 
     int i;
index c6532f4..e005189 100644 (file)
@@ -6,6 +6,7 @@
 #define TBO_STOCK_DOODLE "tbo-doodle"
 #define TBO_STOCK_TEXT "tbo-text"
 #define TBO_STOCK_PIX "tbo-pix"
+#define TBO_STOCK_BUBBLE "tbo-bubble"
 
 void load_custom_stock ();
 
index fc05704..19fa3af 100644 (file)
 #include "doodle-treeview.h"
 #include "doodle-tool.h"
 
+static gboolean BUBBLE_MODE = FALSE;
+
+void
+doodle_tool_bubble_on_select (TboWindow *tbo)
+{
+    BUBBLE_MODE = TRUE;
+    doodle_tool_on_select (tbo);
+}
+
+void
+doodle_tool_bubble_on_unselect (TboWindow *tbo)
+{
+    doodle_tool_on_unselect (tbo);
+    BUBBLE_MODE = FALSE;
+}
+
 void
 doodle_tool_on_select (TboWindow *tbo)
 {
     GtkWidget *tree;
 
-    tree = doodle_setup_tree (tbo);
+    tree = doodle_setup_tree (tbo, BUBBLE_MODE);
+
     gtk_widget_show_all (tree);
 
     tbo_empty_tool_area (tbo);
index 38aef50..a2db8df 100644 (file)
@@ -13,4 +13,7 @@ void doodle_tool_on_release (GtkWidget *widget, GdkEventButton *event, TboWindow
 void doodle_tool_on_key (GtkWidget *widget, GdkEventKey *event, TboWindow *tbo);
 void doodle_tool_drawing (cairo_t *cr);
 
+void doodle_tool_bubble_on_select (TboWindow *tbo);
+void doodle_tool_bubble_on_unselect (TboWindow *tbo);
+
 #endif
index 4a556b6..199ad2c 100644 (file)
@@ -62,7 +62,7 @@ free_gstring_array (GArray *arr)
 }
 
 GArray *
-get_files (gchar *base_dir, gboolean isdir)
+get_files (gchar *base_dir, gboolean isdir, gboolean bubble_mode)
 {
     GError *error = NULL;
     gchar complete_dir[255];
@@ -83,6 +83,11 @@ get_files (gchar *base_dir, gboolean isdir)
         snprintf (complete_dir, strsize, "%s/%s", base_dir, filename);
         st = stat (complete_dir, &filestat);
 
+        if (isdir && bubble_mode && strcmp (filename, "bubble"))
+            continue;
+        if (!strcmp (filename, "bubble") && !bubble_mode)
+            continue;
+
         if (isdir && S_ISDIR (filestat.st_mode))
         {
             GString *dirname_to_append = g_string_new (complete_dir);
@@ -115,7 +120,7 @@ doodle_add_images (gchar *dir)
 
     dirname = dir;
 
-    GArray *arr = get_files (dirname, FALSE);
+    GArray *arr = get_files (dirname, FALSE, FALSE);
 
     r = (arr->len / c) + 1;
     table = gtk_table_new (r, c, TRUE);
@@ -175,7 +180,7 @@ doodle_add_dir_images (gchar *dir, GtkWidget *box)
     gtk_container_add (GTK_CONTAINER (box), expander);
 }
 
-void
+gboolean
 on_expand_cb (GtkExpander *expander, GString *str)
 {
     GString *mystr2;
@@ -184,7 +189,7 @@ on_expand_cb (GtkExpander *expander, GString *str)
     int numofchilds = g_list_length (gtk_container_get_children (GTK_CONTAINER (vbox)));
     if (numofchilds == 0)
     {
-        GArray *subdir = get_files (str->str, TRUE);
+        GArray *subdir = get_files (str->str, TRUE, FALSE);
         for (i=0; i<subdir->len; i++)
         {
             mystr2 = g_array_index (subdir, GString*, i);
@@ -194,10 +199,11 @@ on_expand_cb (GtkExpander *expander, GString *str)
         g_string_free (str, TRUE);
     }
     gtk_widget_show_all (GTK_WIDGET (vbox));
+    return FALSE;
 }
 
 GtkWidget *
-doodle_setup_tree (TboWindow *tbo)
+doodle_setup_tree (TboWindow *tbo, gboolean bubble_mode)
 {
     GtkWidget *expander;
     GtkWidget *vbox;
@@ -218,7 +224,7 @@ doodle_setup_tree (TboWindow *tbo)
     char **possible_dirs = tbo_files_get_dirs ();
     for (k=0; possible_dirs[k]; k++)
     {
-        arr = get_files (possible_dirs[k], TRUE);
+        arr = get_files (possible_dirs[k], TRUE, bubble_mode);
         if (!arr) continue;
 
         for (i=0; i<arr->len; i++)
@@ -235,6 +241,12 @@ doodle_setup_tree (TboWindow *tbo)
 
             mystr2 = g_string_new (mystr->str);
             g_signal_connect (GTK_EXPANDER (expander), "activate", G_CALLBACK (on_expand_cb), mystr2);
+
+            if (bubble_mode)
+            {
+                gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
+                on_expand_cb (GTK_EXPANDER (expander), mystr2);
+            }
         }
         free_gstring_array (arr);
     }
index 3b76345..889438b 100644 (file)
@@ -4,7 +4,7 @@
 #include <gtk/gtk.h>
 #include "tbo-window.h"
 
-GtkWidget * doodle_setup_tree (TboWindow *tbo);
+GtkWidget * doodle_setup_tree (TboWindow *tbo, gboolean bubble_mode);
 void doodle_free_all ();
 
 #endif
index 321c686..baf42d6 100644 (file)
@@ -128,6 +128,9 @@ on_key_cb (GtkWidget    *widget,
             case GDK_d:
                 set_selected_tool_and_action (DOODLE, tbo);
                 break;
+            case GDK_b:
+                set_selected_tool_and_action (BUBBLE, tbo);
+                break;
             case GDK_f:
                 set_selected_tool_and_action (FRAME, tbo);
                 break;
@@ -207,6 +210,7 @@ on_click_cb (GtkWidget    *widget,
     tool = get_selected_tool ();
     switch (tool)
     {
+        case BUBBLE:
         case DOODLE:
             set_selected_tool_and_action (SELECTOR, tbo);
             tool = SELECTOR;
index d913df7..3fc3687 100644 (file)
@@ -51,6 +51,15 @@ static ToolStruct TOOLS[] =
      doodle_tool_on_key,
      doodle_tool_drawing},
 
+    {BUBBLE,
+     doodle_tool_bubble_on_select,
+     doodle_tool_bubble_on_unselect,
+     doodle_tool_on_move,
+     doodle_tool_on_click,
+     doodle_tool_on_release,
+     doodle_tool_on_key,
+     doodle_tool_drawing},
+
     {TEXT,
      text_tool_on_select,
      text_tool_on_unselect,
@@ -125,6 +134,7 @@ update_toolbar (TboWindow *tbo)
     GtkAction *delete;
 
     GtkAction *doodle;
+    GtkAction *bubble;
     GtkAction *text;
     GtkAction *new_frame;
     GtkAction *pix;
@@ -153,6 +163,7 @@ update_toolbar (TboWindow *tbo)
 
     // Frame view disabled in page view
     doodle = gtk_action_group_get_action (ACTION_GROUP, "Doodle");
+    bubble = gtk_action_group_get_action (ACTION_GROUP, "Bubble");
     text = gtk_action_group_get_action (ACTION_GROUP, "Text");
     new_frame = gtk_action_group_get_action (ACTION_GROUP, "NewFrame");
     pix = gtk_action_group_get_action (ACTION_GROUP, "Pix");
@@ -160,6 +171,7 @@ update_toolbar (TboWindow *tbo)
     if (get_frame_view() == NULL)
     {
         gtk_action_set_sensitive (doodle, FALSE);
+        gtk_action_set_sensitive (bubble, FALSE);
         gtk_action_set_sensitive (text, FALSE);
         gtk_action_set_sensitive (pix, FALSE);
         gtk_action_set_sensitive (new_frame, TRUE);
@@ -167,6 +179,7 @@ update_toolbar (TboWindow *tbo)
     else
     {
         gtk_action_set_sensitive (doodle, TRUE);
+        gtk_action_set_sensitive (bubble, TRUE);
         gtk_action_set_sensitive (text, TRUE);
         gtk_action_set_sensitive (pix, TRUE);
         gtk_action_set_sensitive (new_frame, FALSE);
@@ -347,19 +360,22 @@ static const GtkActionEntry tbo_tools_entries [] = {
 
 static const GtkToggleActionEntry tbo_tools_toogle_entries [] = {
     // Page view tools
-    { "NewFrame", TBO_STOCK_FRAME, N_("New _Frame"), "<control>F",
+    { "NewFrame", TBO_STOCK_FRAME, N_("New _Frame"), "f",
       N_("New Frame"),
       G_CALLBACK (select_tool), FALSE },
 
-    { "Selector", TBO_STOCK_SELECTOR, N_("Selector"), "",
+    { "Selector", TBO_STOCK_SELECTOR, N_("Selector"), "s",
       N_("Selector"),
       G_CALLBACK (select_tool), FALSE },
 
     // Frame view tools
-    { "Doodle", TBO_STOCK_DOODLE, N_("Doodle"), "",
+    { "Doodle", TBO_STOCK_DOODLE, N_("Doodle"), "d",
       N_("Doodle"),
       G_CALLBACK (select_tool), FALSE },
-    { "Text", TBO_STOCK_TEXT, N_("Text"), "",
+    { "Bubble", TBO_STOCK_BUBBLE, N_("Booble"), "b",
+      N_("Bubble"),
+      G_CALLBACK (select_tool), FALSE },
+    { "Text", TBO_STOCK_TEXT, N_("Text"), "t",
       N_("Text"),
       G_CALLBACK (select_tool), FALSE },
 };
@@ -368,6 +384,7 @@ static const tool_and_action tools_actions [] = {
     {FRAME, "NewFrame"},
     {SELECTOR, "Selector"},
     {DOODLE, "Doodle"},
+    {BUBBLE, "Bubble"},
     {TEXT, "Text"},
 };
 
index ad9bbdd..8025fd1 100644 (file)
@@ -21,6 +21,7 @@ enum Tool
     SELECTOR,
     FRAME,
     DOODLE,
+    BUBBLE,
     TEXT,
 };