[gnome-builder/wip/chergert/perspective] libide: add back support log generation



commit 3e2a83716c5b588352a20a89d266458ba2457478
Author: Christian Hergert <chergert redhat com>
Date:   Sat Nov 28 01:28:59 2015 -0800

    libide: add back support log generation

 libide/Makefile.am                                 |    3 +++
 libide/ide-application-actions.c                   |    5 ++---
 libide/ide-application-private.h                   |    2 ++
 libide/ide-application.c                           |   16 ++++++++++++++++
 libide/ide-application.h                           |    1 +
 .../gb-support.c => libide/support/ide-support.c   |   14 ++++++--------
 .../gb-support.h => libide/support/ide-support.h   |   10 +++++-----
 7 files changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 6419cfd..c5f1a83 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -360,6 +360,8 @@ libide_1_0_la_SOURCES = \
        search/ide-omni-search-group.h \
        search/ide-omni-search-row.c \
        search/ide-omni-search-row.h \
+       support/ide-support.c \
+       support/ide-support.h \
        theatrics/ide-box-theatric.c \
        theatrics/ide-box-theatric.h \
        util/ide-cairo.c \
@@ -410,6 +412,7 @@ libide_1_0_la_includes = \
        -I$(srcdir)/modelines \
        -I$(srcdir)/preferences \
        -I$(srcdir)/resources \
+       -I$(srcdir)/support \
        -I$(srcdir)/theatrics \
        -I$(srcdir)/util \
        $(NULL)
diff --git a/libide/ide-application-actions.c b/libide/ide-application-actions.c
index 1e08653..5da8ce9 100644
--- a/libide/ide-application-actions.c
+++ b/libide/ide-application-actions.c
@@ -28,6 +28,7 @@
 #include "ide-application-private.h"
 #include "ide-debug.h"
 #include "ide-shortcuts-window.h"
+#include "ide-support.h"
 #include "ide-workbench.h"
 
 static void
@@ -68,7 +69,6 @@ ide_application_actions_preferences (GSimpleAction *action,
   IDE_EXIT;
 }
 
-#if 0
 static void
 ide_application_actions_support (GSimpleAction *action,
                                  GVariant      *parameter,
@@ -119,7 +119,6 @@ cleanup:
   g_free (str);
   g_free (log_path);
 }
-#endif
 
 static void
 ide_application_actions_quit (GSimpleAction *action,
@@ -337,7 +336,7 @@ static const GActionEntry IdeApplicationActions[] = {
   { "preferences",  ide_application_actions_preferences },
   { "quit",         ide_application_actions_quit },
   { "shortcuts",    ide_application_actions_shortcuts },
-  //{ "support",      ide_application_actions_support },
+  { "support",      ide_application_actions_support },
 };
 
 void
diff --git a/libide/ide-application-private.h b/libide/ide-application-private.h
index 911d350..622bd74 100644
--- a/libide/ide-application-private.h
+++ b/libide/ide-application-private.h
@@ -48,6 +48,8 @@ struct _IdeApplication
   IdeKeybindings      *keybindings;
 
   IdeRecentProjects   *recent_projects;
+
+  GDateTime           *started_at;
 };
 
 void     ide_application_discover_plugins   (IdeApplication   *self) G_GNUC_INTERNAL;
diff --git a/libide/ide-application.c b/libide/ide-application.c
index 3de8c19..bf13736 100644
--- a/libide/ide-application.c
+++ b/libide/ide-application.c
@@ -352,6 +352,7 @@ ide_application_finalize (GObject *object)
 
   g_clear_pointer (&self->dbus_address, g_free);
   g_clear_pointer (&self->tool_arguments, g_strfreev);
+  g_clear_pointer (&self->started_at, g_date_time_unref);
   g_clear_object (&self->worker_manager);
   g_clear_object (&self->keybindings);
   g_clear_object (&self->recent_projects);
@@ -378,6 +379,7 @@ ide_application_init (IdeApplication *self)
 {
   ide_set_program_name (PACKAGE_NAME);
 
+  self->started_at = g_date_time_new_now_utc ();
   self->mode = IDE_APPLICATION_MODE_PRIMARY;
 
   setlocale (LC_ALL, "");
@@ -575,3 +577,17 @@ ide_application_get_keybindings_mode (IdeApplication *self)
 
   return NULL;
 }
+
+/**
+ * ide_application_get_started_at:
+ * @self: A #IdeApplication.
+ *
+ * Gets the startup time of the application.
+ *
+ * Returns: (transfer none): A #GDateTime.
+ */
+GDateTime *
+ide_application_get_started_at (IdeApplication *self)
+{
+  return self->started_at;
+}
diff --git a/libide/ide-application.h b/libide/ide-application.h
index 35140fd..1d50245 100644
--- a/libide/ide-application.h
+++ b/libide/ide-application.h
@@ -39,6 +39,7 @@ typedef enum
 
 IdeApplicationMode  ide_application_get_mode             (IdeApplication       *self);
 IdeApplication     *ide_application_new                  (void);
+GDateTime          *ide_application_get_started_at       (IdeApplication       *self);
 IdeRecentProjects  *ide_application_get_recent_projects  (IdeApplication       *self);
 void                ide_application_show_projects_window (IdeApplication       *self);
 const gchar        *ide_application_get_keybindings_mode (IdeApplication       *self);
diff --git a/src/support/gb-support.c b/libide/support/ide-support.c
similarity index 95%
rename from src/support/gb-support.c
rename to libide/support/ide-support.c
index 2dfa785..f4bd03b 100644
--- a/src/support/gb-support.c
+++ b/libide/support/ide-support.c
@@ -1,4 +1,4 @@
-/* gb-support.c
+/* ide-support.c
  *
  * Copyright (C) 2014 Christian Hergert <christian hergert me>
  *
@@ -20,8 +20,9 @@
 #include <string.h>
 
 #include "egg-counter.h"
-#include "gb-application.h"
-#include "gb-support.h"
+
+#include "ide-application.h"
+#include "ide-support.h"
 
 static gchar *
 str_to_key (const gchar *str)
@@ -43,9 +44,8 @@ counter_arena_foreach_cb (EggCounter *counter,
 }
 
 gchar *
-gb_get_support_log (void)
+ide_get_support_log (void)
 {
-  GApplication *app;
   GChecksum *checksum;
   GDateTime *now;
   GDateTime *started_at;
@@ -55,8 +55,6 @@ gb_get_support_log (void)
   guint i;
   guint n_monitors;
 
-  app = g_application_get_default ();
-
   str = g_string_new (NULL);
 
   /*
@@ -77,7 +75,7 @@ gb_get_support_log (void)
   g_string_append_printf (str, "current_dir = \"%s\"\n", tmp);
   g_free (tmp);
 
-  started_at = gb_application_get_started_at (GB_APPLICATION (app));
+  started_at = ide_application_get_started_at (IDE_APPLICATION_DEFAULT);
   tmp = g_date_time_format (started_at, "%FT%H:%M:%SZ");
   g_string_append_printf (str, "started-at = \"%s\"\n", tmp);
   g_free (tmp);
diff --git a/src/support/gb-support.h b/libide/support/ide-support.h
similarity index 86%
rename from src/support/gb-support.h
rename to libide/support/ide-support.h
index 7ea7f2b..1a5da85 100644
--- a/src/support/gb-support.h
+++ b/libide/support/ide-support.h
@@ -1,4 +1,4 @@
-/* gb-support.h
+/* ide-support.h
  *
  * Copyright (C) 2014 Christian Hergert <christian hergert me>
  *
@@ -16,15 +16,15 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GB_SUPPORT_H
-#define GB_SUPPORT_H
+#ifndef IDE_SUPPORT_H
+#define IDE_SUPPORT_H
 
 #include <glib.h>
 
 G_BEGIN_DECLS
 
-gchar *gb_get_support_log (void);
+gchar *ide_get_support_log (void);
 
 G_END_DECLS
 
-#endif /* GB_SUPPORT_H */
+#endif /* IDE_SUPPORT_H */


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