summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--capplets/time-admin/src/main.c12
-rw-r--r--capplets/time-admin/src/time-share.c83
-rw-r--r--capplets/time-admin/src/time-share.h12
-rw-r--r--capplets/time-admin/src/time-tool.c8
4 files changed, 24 insertions, 91 deletions
diff --git a/capplets/time-admin/src/main.c b/capplets/time-admin/src/main.c
index 4a18c5fd..f635c31c 100644
--- a/capplets/time-admin/src/main.c
+++ b/capplets/time-admin/src/main.c
@@ -175,7 +175,7 @@ static int RecordPid(void)
fd = open(LOCKFILE,O_WRONLY|O_CREAT|O_TRUNC,0777);
if(fd < 0)
{
- MessageReport(_("open file"),_("Create pid file failed"),ERROR);
+ ErrorMessage (_("open file"), _("Create pid file failed"));
return -1;
}
chmod(LOCKFILE,0777);
@@ -184,7 +184,7 @@ static int RecordPid(void)
Length = write(fd,WriteBuf,strlen(WriteBuf));
if(Length <= 0 )
{
- MessageReport(_("write file"),_("write pid file failed"),ERROR);
+ ErrorMessage (_("write file"), _("write pid file failed"));
return -1;
}
close(fd);
@@ -218,12 +218,12 @@ static gboolean ProcessRuning(void)
fd = open(LOCKFILE,O_RDONLY);
if(fd < 0)
{
- MessageReport(_("open file"),_("open pid file failed"),ERROR);
+ ErrorMessage (_("open file"), _("open pid file failed"));
return TRUE;
}
if(read(fd,ReadBuf,sizeof(ReadBuf)) <= 0)
{
- MessageReport(_("read file"),_("read pid file failed"),ERROR);
+ ErrorMessage (_("read file"), _("read pid file failed"));
goto ERROREXIT;
}
pid = atoi(ReadBuf);
@@ -249,7 +249,7 @@ static gboolean InitDbusProxy(TimeAdmin *ta)
ta->Connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if(ta->Connection == NULL)
{
- MessageReport(_("g_bus_get_sync"),error->message,ERROR);
+ ErrorMessage (_("g_bus_get_sync"), error->message);
goto EXIT;
}
ta->proxy = g_dbus_proxy_new_sync (ta->Connection,
@@ -262,7 +262,7 @@ static gboolean InitDbusProxy(TimeAdmin *ta)
&error);
if(ta->proxy == NULL)
{
- MessageReport(_("g_bus_proxy_new"),error->message,ERROR);
+ ErrorMessage (_("g_bus_proxy_new"), error->message);
goto EXIT;
}
diff --git a/capplets/time-admin/src/time-share.c b/capplets/time-admin/src/time-share.c
index b5038779..e4069415 100644
--- a/capplets/time-admin/src/time-share.c
+++ b/capplets/time-admin/src/time-share.c
@@ -21,82 +21,23 @@
#include "time-share.h"
#include <glib/gi18n.h>
-/******************************************************************************
- * Function: MessageReport
- *
- * Explain: Prompt information dialog
- *
- * Input: @Title Message title
- * @Msg Message content
- * @nType Message type
- * Output:
- *
- * Author: zhuyaliang 25/05/2018
- ******************************************************************************/
-int MessageReport(const char *Title,
- const char *Msg,
- int nType)
+int ErrorMessage (const char *Title,
+ const char *Msg)
{
- GtkWidget *dialog = NULL;
int nRet;
+ GtkWidget *dialog;
- switch(nType)
- {
- case ERROR:
- {
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "%s", Title);
- break;
- }
- case WARING:
- {
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "%s", Title);
- break;
- }
- case INFOR:
- {
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK,
- "%s", Title);
- break;
- }
- case QUESTION:
- {
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- "%s", Title);
- gtk_dialog_add_button (GTK_DIALOG (dialog),("_Return"),
- GTK_RESPONSE_ACCEPT);
- break;
- }
- case QUESTIONNORMAL:
- {
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- "%s", Title);
- break;
- }
- default :
- break;
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", Title);
- }
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", Msg);
- nRet = gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+
+ nRet = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
return nRet;
}
diff --git a/capplets/time-admin/src/time-share.h b/capplets/time-admin/src/time-share.h
index e6057687..5e1c86c4 100644
--- a/capplets/time-admin/src/time-share.h
+++ b/capplets/time-admin/src/time-share.h
@@ -33,13 +33,6 @@
#include <libintl.h>
#include <gio/gio.h>
-#define ERROR 1
-#define WARING 2
-#define INFOR 3
-#define QUESTION 4
-#define QUESTIONNORMAL 5
-
-
int TimeoutFlag;
typedef struct
{
@@ -70,9 +63,8 @@ typedef struct
}TimeAdmin;
-int MessageReport (const char *Title,
- const char *Msg,
- int nType);
+int ErrorMessage (const char *Title,
+ const char *Msg);
void QuitApp (TimeAdmin *ta);
diff --git a/capplets/time-admin/src/time-tool.c b/capplets/time-admin/src/time-tool.c
index 5491ac6a..2fc18e95 100644
--- a/capplets/time-admin/src/time-tool.c
+++ b/capplets/time-admin/src/time-tool.c
@@ -132,7 +132,7 @@ gboolean GetNtpState(TimeAdmin *ta)
return g_variant_get_boolean (ntp);
EXIT:
- MessageReport(_("GetNtpState"),error->message,ERROR);
+ ErrorMessage (_("GetNtpState"), error->message);
g_error_free(error);
return FALSE;
@@ -195,7 +195,7 @@ void SetTimeZone(GDBusProxy *proxy,const char *zone)
if(ret == NULL)
{
- MessageReport(_("Set time zone"),error->message,ERROR);
+ ErrorMessage (_("Set time zone"), error->message);
}
}
@@ -226,7 +226,7 @@ gboolean ChangeNtpSync (GtkSwitch *widget, gboolean state, gpointer data)
if (ret == NULL)
{
- MessageReport(_("Set Ntp sync"),error->message,ERROR);
+ ErrorMessage (_("Set Ntp sync"), error->message);
g_error_free(error);
return TRUE;
}
@@ -273,7 +273,7 @@ SetTime (GDBusProxy *proxy, gint64 TimeSec)
if(ret == NULL)
{
- MessageReport(_("Set Ntp sync"),error->message,ERROR);
+ ErrorMessage (_("Set Ntp sync"), error->message);
g_error_free(error);
return FALSE;
}