Add beginning of a screenshot window.
authorSoeren Sandmann <sandmann@redhat.com>
Tue, 8 Nov 2005 04:32:19 +0000 (04:32 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Tue, 8 Nov 2005 04:32:19 +0000 (04:32 +0000)
Mon Nov  7 23:42:26 2005  Soeren Sandmann  <sandmann@redhat.com>

        * sysprof.c: Add beginning of a screenshot
        window.

        * sysprof.glade: Add screenshot window plus menu items.

        * stackstash.c: Remove unused function stack_node_list_leaves()

        * xmlstore.c: Various crack

ChangeLog
profile.c
stackstash.c
stackstash.h
sysprof.c
sysprof.glade
xmlstore.c

index e7af2d3..985b3c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Mon Nov  7 23:42:26 2005  Soeren Sandmann  <sandmann@redhat.com>
+
+       * sysprof.c: Add beginning of a screenshot
+       window.
+
+       * sysprof.glade: Add screenshot window plus menu items.
+
+       * stackstash.c: Remove unused function stack_node_list_leaves()
+
+       * xmlstore.c: Various crack
+
 Sun Nov  6 23:03:49 2005  Soeren Sandmann  <sandmann@redhat.com>
 
        * profile.c (add_trace_to_tree): Test for !prev instead of !next.
index 7beded2..935c7cd 100644 (file)
--- a/profile.c
+++ b/profile.c
@@ -484,7 +484,8 @@ profile_get_objects (Profile *profile)
 {
     GList *objects = NULL;
     
-    stack_stash_foreach_by_address (profile->stash, build_object_list, &objects);
+    stack_stash_foreach_by_address (
+       profile->stash, build_object_list, &objects);
     
     /* FIXME: everybody still assumes that they don't have to free the
      * objects in the list, but these days they do, and so we are leaking.
index 3a285bc..cee0d2b 100644 (file)
@@ -138,6 +138,7 @@ do_callback (StackNode *node,
 
     if (trace)
        trace->prev = &link;
+
     link.next = trace;
     link.data = node->address;
     link.prev = NULL;
@@ -204,19 +205,6 @@ stack_stash_find_node (StackStash      *stash,
     return g_hash_table_lookup (stash->nodes_by_data, data);
 }
 
-void
-stack_node_list_leaves (StackNode  *node,
-                       GList     **leaves)
-{
-    StackNode *n;
-    
-    if (node->size > 0)
-       *leaves = g_list_prepend (*leaves, node);
-    
-    for (n = node->children; n != NULL; n = n->siblings)
-       stack_node_list_leaves (n, leaves);
-}
-
 typedef struct
 {
     StackNodeFunc func;
index 0be55c2..1faa5f9 100644 (file)
@@ -23,7 +23,6 @@
 #include <glib.h>
 
 typedef struct StackStash StackStash;
-
 typedef struct StackNode StackNode;
 
 struct StackNode
@@ -45,6 +44,9 @@ typedef void (* StackFunction) (GList   *trace,
                                gint     size,
                                gpointer data);
 
+typedef void (* StackNodeFunc) (StackNode *node,
+                               gpointer data);
+
 /* Stach */
 StackStash *stack_stash_new       (void);
 void        stack_stash_add_trace (StackStash      *stash,
@@ -59,11 +61,6 @@ void     stack_node_foreach_trace (StackNode *node,
                                      gpointer      data);
 StackNode  *stack_stash_find_node (StackStash      *stash,
                                   gpointer         address);
-/* FIXME: should probably return a list */
-void       stack_node_list_leaves (StackNode  *node,
-                                   GList     **leaves);
-typedef void (* StackNodeFunc) (StackNode *node,
-                               gpointer data);
 void       stack_stash_foreach_by_address (StackStash *stash,
                                            StackNodeFunc func,
                                            gpointer      data);
index 3fd7cab..27e57de 100644 (file)
--- a/sysprof.c
+++ b/sysprof.c
@@ -66,8 +66,14 @@ struct Application
     GtkWidget *                reset_item;
     GtkWidget *                save_as_item;
     GtkWidget *                open_item;
+    GtkWidget *                screenshot_item;
     
     GtkWidget *                samples_label;
+
+    gboolean           screenshot_window_visible;
+    GtkWidget *                screenshot_textview;
+    GtkWidget *                screenshot_close_button;
+    GtkWidget *         screenshot_window;
     
     Profile *          profile;
     ProfileDescendant * descendants;
@@ -227,6 +233,14 @@ update_sensitivity (Application *app)
     gtk_widget_set_sensitive (GTK_WIDGET (app->descendants_view), sensitive_tree_views);
     gtk_widget_set_sensitive (GTK_WIDGET (app->samples_label), sensitive_samples_label);
 
+    if (app->screenshot_window_visible)
+       gtk_widget_show (app->screenshot_window);
+    else
+       gtk_widget_hide (app->screenshot_window);
+
+    gtk_check_menu_item_set_active (
+       GTK_CHECK_MENU_ITEM (app->screenshot_item), app->screenshot_window_visible);
+    
     queue_show_samples (app);
 }
 
@@ -1107,6 +1121,34 @@ on_callers_row_activated (GtkTreeView *tree_view,
 }
 
 static void
+on_screenshot_activated (GtkCheckMenuItem *menu_item,
+                        Application      *app)
+{
+    app->screenshot_window_visible = gtk_check_menu_item_get_active (menu_item);
+
+    update_sensitivity (app);
+}
+
+static void
+on_screenshot_window_delete (GtkWidget   *window,
+                            GdkEvent    *event,
+                            Application *app)
+{
+    app->screenshot_window_visible = FALSE;
+
+    update_sensitivity (app);
+}
+
+static void
+on_screenshot_close_button_clicked (GtkWidget *widget,
+                                   Application *app)
+{
+    app->screenshot_window_visible = FALSE;
+
+    update_sensitivity (app);
+}
+
+static void
 set_sizes (GtkWindow *window,
           GtkWidget *hpaned,
           GtkWidget *vpaned)
@@ -1219,6 +1261,7 @@ build_gui (Application *app)
     app->reset_item = glade_xml_get_widget (xml, "reset_item");
     app->open_item = glade_xml_get_widget (xml, "open_item");
     app->save_as_item = glade_xml_get_widget (xml, "save_as_item");
+    app->screenshot_item = glade_xml_get_widget (xml, "screenshot_item");
     
     g_assert (app->start_item);
     g_assert (app->profile_item);
@@ -1240,6 +1283,9 @@ build_gui (Application *app)
     g_signal_connect (G_OBJECT (app->save_as_item), "activate",
                      G_CALLBACK (on_save_as_clicked), app);
 
+    g_signal_connect (G_OBJECT (app->screenshot_item), "activate",
+                     G_CALLBACK (on_screenshot_activated), app);
+
     g_signal_connect (G_OBJECT (glade_xml_get_widget (xml, "quit")), "activate",
                      G_CALLBACK (on_delete), NULL);
 
@@ -1277,10 +1323,24 @@ build_gui (Application *app)
     g_signal_connect (app->descendants_view, "row-activated",
                      G_CALLBACK (on_descendants_row_activated), app);
     gtk_tree_view_column_set_expand (col, TRUE);
-    
+
     gtk_widget_grab_focus (GTK_WIDGET (app->object_view));
+
+    /* Screenshot window */
+    app->screenshot_window = glade_xml_get_widget (xml, "screenshot_window");
+    app->screenshot_textview = glade_xml_get_widget (xml, "screenshot_textview");
+    app->screenshot_close_button = glade_xml_get_widget (xml, "screenshot_close_button");
+
+    g_signal_connect (app->screenshot_window, "delete_event",
+                     G_CALLBACK (on_screenshot_window_delete), app);
+
+    g_signal_connect (app->screenshot_close_button, "clicked",
+                     G_CALLBACK (on_screenshot_close_button_clicked), app);
+    
+    /* hide/show widgets */
     gtk_widget_show_all (app->main_window);
     gtk_widget_hide (app->dummy_button);
+    gtk_widget_hide (app->screenshot_window);
     
     queue_show_samples (app);
 
index 724e5b8..9251e61 100644 (file)
@@ -46,7 +46,7 @@
                      <signal name="activate" handler="on_start1_activate" last_modification_time="Thu, 04 Nov 2004 18:51:54 GMT"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image98">
+                       <widget class="GtkImage" id="image128">
                          <property name="visible">True</property>
                          <property name="stock">gtk-media-play</property>
                          <property name="icon_size">1</property>
@@ -67,7 +67,7 @@
                      <signal name="activate" handler="on_profile1_activate" last_modification_time="Thu, 04 Nov 2004 18:51:54 GMT"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image99">
+                       <widget class="GtkImage" id="image129">
                          <property name="visible">True</property>
                          <property name="stock">gtk-justify-left</property>
                          <property name="icon_size">1</property>
@@ -88,7 +88,7 @@
                      <signal name="activate" handler="on_reset_item_activate" last_modification_time="Fri, 05 Nov 2004 15:34:30 GMT"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image100">
+                       <widget class="GtkImage" id="image130">
                          <property name="visible">True</property>
                          <property name="stock">gtk-clear</property>
                          <property name="icon_size">1</property>
                      <accelerator key="o" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image101">
+                       <widget class="GtkImage" id="image131">
                          <property name="visible">True</property>
                          <property name="stock">gtk-open</property>
                          <property name="icon_size">1</property>
                      <accelerator key="s" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image102">
+                       <widget class="GtkImage" id="image132">
                          <property name="visible">True</property>
                          <property name="stock">gtk-save-as</property>
                          <property name="icon_size">1</property>
                      <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image103">
+                       <widget class="GtkImage" id="image133">
                          <property name="visible">True</property>
                          <property name="stock">gtk-quit</property>
                          <property name="icon_size">1</property>
          </child>
 
          <child>
+           <widget class="GtkMenuItem" id="view1">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_View</property>
+             <property name="use_underline">True</property>
+             <signal name="activate" handler="on_view1_activate" last_modification_time="Tue, 08 Nov 2005 04:06:22 GMT"/>
+
+             <child>
+               <widget class="GtkMenu" id="view1_menu">
+
+                 <child>
+                   <widget class="GtkCheckMenuItem" id="screenshot_item">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Screenshot Window</property>
+                     <property name="use_underline">True</property>
+                     <property name="active">False</property>
+                     <signal name="activate" handler="on_screenshot_item_activate" last_modification_time="Tue, 08 Nov 2005 00:40:14 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
            <widget class="GtkMenuItem" id="menuitem4">
              <property name="visible">True</property>
              <property name="label" translatable="yes">_Help</property>
                      <signal name="activate" handler="on_about_activate" last_modification_time="Wed, 31 Dec 2003 20:44:40 GMT"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image104">
+                       <widget class="GtkImage" id="image134">
                          <property name="visible">True</property>
                          <property name="stock">gtk-about</property>
                          <property name="icon_size">1</property>
   </child>
 </widget>
 
+<widget class="GtkWindow" id="screenshot_window">
+  <property name="title" translatable="yes">Screenshot</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_UTILITY</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+
+  <child>
+    <widget class="GtkVBox" id="vbox4">
+      <property name="border_width">12</property>
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">6</property>
+
+      <child>
+       <widget class="GtkFrame" id="frame1">
+         <property name="visible">True</property>
+         <property name="label_xalign">0</property>
+         <property name="label_yalign">0.5</property>
+         <property name="shadow_type">GTK_SHADOW_NONE</property>
+
+         <child>
+           <widget class="GtkAlignment" id="alignment2">
+             <property name="visible">True</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xscale">1</property>
+             <property name="yscale">1</property>
+             <property name="top_padding">3</property>
+             <property name="bottom_padding">0</property>
+             <property name="left_padding">12</property>
+             <property name="right_padding">0</property>
+
+             <child>
+               <widget class="GtkScrolledWindow" id="scrolledwindow4">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                 <property name="vscrollbar_policy">GTK_POLICY_NEVER</property>
+                 <property name="shadow_type">GTK_SHADOW_IN</property>
+                 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+                 <child>
+                   <widget class="GtkTextView" id="screenshot_textview">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="editable">False</property>
+                     <property name="overwrite">False</property>
+                     <property name="accepts_tab">True</property>
+                     <property name="justification">GTK_JUSTIFY_LEFT</property>
+                     <property name="wrap_mode">GTK_WRAP_NONE</property>
+                     <property name="cursor_visible">False</property>
+                     <property name="pixels_above_lines">0</property>
+                     <property name="pixels_below_lines">0</property>
+                     <property name="pixels_inside_wrap">0</property>
+                     <property name="left_margin">0</property>
+                     <property name="right_margin">0</property>
+                     <property name="indent">0</property>
+                     <property name="text" translatable="yes"></property>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label1">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">&lt;b&gt;Screenshot&lt;/b&gt;</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">True</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+             <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+             <property name="width_chars">-1</property>
+             <property name="single_line_mode">False</property>
+             <property name="angle">0</property>
+           </widget>
+           <packing>
+             <property name="type">label_item</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkHButtonBox" id="hbuttonbox1">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_END</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <widget class="GtkButton" id="screenshot_close_button">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="has_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-close</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
index 202b6dc..71aaa16 100644 (file)
@@ -1,5 +1,62 @@
 typedef struct ParsedItem ParsedItem;
 
+struct XmlItem
+{
+    gboolean is_element;
+
+    union
+    {
+       struct
+       {
+           const char *name;
+           guint sibling_index;
+       } element;
+
+       char text[1];
+    } u;
+};
+
+struct XmlStore
+{
+    GHashTable *names;
+    GArray *items;
+    
+    GList *stack;
+    guint last_index;
+};
+
+static guint
+add_item (GArray *array,
+         const XmlItem *item)
+{
+    
+}
+
+XmlStore *
+xml_store_new (void)
+{
+    XmlStore *store = g_new (XmlStore, 1);
+    store->names = g_hash_table_new (g_str_hash, g_str_equal);
+    store->stack = NULL;
+    store->items = g_array_new (TRUE, TRUE, sizeof (XmlItem));
+}
+
+void
+xml_store_append_begin (XmlStore *store,
+                       const char *element)
+{
+    XmlItem item;
+
+    item.is_element = TRUE;
+    item.element.name = canonical_name (store, element);
+    item.element.sibling = NULL;
+
+    if (store->last)
+       store->last->u.element.sibling = &result;
+    
+}
+
+
 typedef enum
 {
     BEGIN,
@@ -16,14 +73,14 @@ struct XmlItem
 struct XmlStore
 {
     XmlItem *  items;
-
+    
     GHashTable *user_data_map;
 };
 
 struct ParsedItem
 {
     XmlItemType        type;
-
+    
     union
     {
        struct
@@ -32,12 +89,12 @@ struct ParsedItem
            int    n_attrs;
            char **attr;
        } begin_item;
-
+       
        struct
        {
            char *text;
        } text_item;
-
+       
        struct
        {
            char *element;
@@ -77,18 +134,18 @@ parsed_item_new (XmlItem *item)
        parsed_item->type = BEGIN;
        parse_begin_item (item, parsed_item);
        break;
-
+       
     case END:
        parsed_item->type = END;
        parse_end_item (item, parsed_item);
        break;
-
+       
     case TEXT:
        parsed_item->type = TEXT;
        parse_text_item (item, parsed_item);
        break;
     }
-
+    
     return parsed_item;
 }