summaryrefslogtreecommitdiff
path: root/capplets/time-admin/src/time-share.c
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2019-06-10 15:08:04 +0800
committerraveit65 <[email protected]>2019-06-14 12:05:04 +0200
commit6cb1deca1340a8b47d7b041bb3510fbe92da9580 (patch)
treee735c2f782843d334be64bbab602d560cb9e04e4 /capplets/time-admin/src/time-share.c
parent72dabd15f2495ff92310b265c10f6b30f58589c7 (diff)
downloadmate-control-center-6cb1deca1340a8b47d7b041bb3510fbe92da9580.tar.bz2
mate-control-center-6cb1deca1340a8b47d7b041bb3510fbe92da9580.tar.xz
add time-admin source code
Diffstat (limited to 'capplets/time-admin/src/time-share.c')
-rw-r--r--capplets/time-admin/src/time-share.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/capplets/time-admin/src/time-share.c b/capplets/time-admin/src/time-share.c
new file mode 100644
index 00000000..12bd8801
--- /dev/null
+++ b/capplets/time-admin/src/time-share.c
@@ -0,0 +1,154 @@
+/* time-admin
+* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+
+* 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, see <https://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "time-share.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)
+{
+ GtkWidget *dialog = NULL;
+ int nRet;
+
+ switch(nType)
+ {
+ case ERROR:
+ {
+ dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s",Title);
+ break;
+ }
+ case WARING:
+ {
+ dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "%s",Title);
+ break;
+ }
+ case INFOR:
+ {
+ dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "%s",Title);
+ break;
+ }
+ case QUESTION:
+ {
+ dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ 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(GTK_WINDOW(WindowLogin),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "%s",Title);
+ break;
+ }
+ default :
+ break;
+
+ }
+ gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),
+ TYPEMSG,
+ Msg);
+ gtk_window_set_title(GTK_WINDOW(dialog),("Message"));
+ nRet = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+
+ return nRet;
+}
+void SetLableFontType(GtkWidget *Lable ,const char *Color,int FontSzie,const char *Word)
+{
+ char LableTypeBuf[200] = { 0 };
+
+ sprintf(LableTypeBuf,
+ "<span foreground=\'%s\'weight=\'light\'font_desc=\'%d\'>%s</span>",
+ Color,FontSzie,Word);
+ gtk_label_set_markup(GTK_LABEL(Lable),LableTypeBuf);
+
+}
+void QuitApp(TimeAdmin *ta)
+{
+ if(ta->UpdateTimeId > 0)
+ {
+ g_source_remove (ta->UpdateTimeId);
+ }
+ if(ta->ApplyId > 0)
+ {
+ g_source_remove(ta->ApplyId);
+ }
+
+ gtk_main_quit();
+}
+GtkWidget* DialogAddButtonWithIconName (GtkDialog *dialog,
+ const gchar *button_text,
+ const gchar *icon_name,
+ gint response_id)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_with_mnemonic (button_text);
+ gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+ gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+ gtk_widget_set_can_default (button, TRUE);
+// gtk_widget_show (button);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+ return button;
+}
+void SetTooltip(GtkWidget*box,gboolean mode)
+{
+ if(!mode)
+ {
+ gtk_widget_set_tooltip_markup(box,
+ _("Network time synchronization has been set up.prohibit Modification Time"));
+ }
+ else
+ {
+ gtk_widget_set_tooltip_markup(box,NULL);
+ }
+}